1 (function($){$(function(){
4 function hide_menu_boxes() {
5 /* Closes any open menu boxes. */
6 $("#menu .active").each(function() {
7 $(this).removeClass("active");
8 $("#" + $(this).attr("data-box")).hide();
10 $("#box-underlay").hide();
13 function release_menu() {
14 /* Exits the menu. It only really disappears on small screens. */
16 $("body").removeClass("menu-showed");
20 $('#menu-toggle-on').click(function(e) {
23 /* Just stop hiding the menu. This way, after narrowing the browser,
24 * menu will still disappear normally. */
25 body.removeClass("menu-hidden");
26 /* Menu still not visible? Really open it then. */
27 if (!$("#menu").is(":visible")) {
28 body.addClass("menu-showed");
33 $('#menu-toggle-off').click(function(e) {
35 /* Just release the menu. This way, after widening the browser,
36 * menu will still appear normally. */
38 /* Menu still visible after releasing it? Really hide it then. */
39 if ($("#menu").is(":visible")) {
40 $("body").addClass("menu-hidden");
45 /* Exit menu by clicking anywhere else. */
46 $("#box-underlay").click(release_menu);
49 /* Toggle hidden box on click. */
50 $("#menu a").each(function() {
51 var boxid = $(this).attr("data-box");
53 $("#" + $(this).attr("data-box")).hide();
55 $(this).click(function(e) {
57 var showing = $(this).hasClass("active");
60 $("body").addClass("menu-showed");
61 $(this).addClass("active");
62 $("#box-underlay").show();
63 $("#" + $(this).attr("data-box")).show();
68 $(this).click(release_menu);
73 /* Show menu item for other versions of text.
74 * It's only present if there are any. */
75 $("#menu-other").show();
78 /* Load other version of text. */
79 $(".display-other").click(function(e) {
83 $("#other-text").show();
84 $("body").addClass('with-other-text');
86 $.ajax($(this).attr('data-other'), {
87 success: function(text) {
88 $("#other-text-body").html(text);
89 $("#other-text-waiter").hide();
90 $("#other-text-body").show();
91 loaded_text($("#other-text-body"));
97 /* Remove other version of text. */
98 $(".other-text-close").click(function(e) {
101 $("#other-text").hide();
102 $("body").removeClass('with-other-text');
103 $("#other-text-body").html("");
107 /* Release menu after clicking inside TOC. */
108 $("#toc a").click(release_menu);
111 if ($('#nota_red').length > 0) {
112 $("#menu-nota_red").show();
115 /* Show themes menu item, if there are any. */
116 if ($('#themes li').length > 0) {
117 $("#menu-themes").show();
120 function loaded_text(text) {
121 /* Attach events to elements inside book texts here.
122 * This way they'll work for the other text when it's loaded. */
124 $(".theme-begin", text).click(function(e) {
126 if ($(this).css("overflow") == "hidden" || $(this).hasClass('showing')) {
127 $(this).toggleClass("showing");
132 loaded_text("#book-text");