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();
9 if ($(this).hasClass('dropdown')) {
10 $($(this).attr('href')).slideUp('fast');
13 $("#box-underlay").hide();
16 function release_menu() {
17 /* Exits the menu. It only really disappears on small screens. */
19 $("body").removeClass("menu-showed");
23 $('#menu-toggle-on').click(function(e) {
26 /* Just stop hiding the menu. This way, after narrowing the browser,
27 * menu will still disappear normally. */
28 body.removeClass("menu-hidden");
29 /* Menu still not visible? Really open it then. */
30 if (!$("#menu").is(":visible")) {
31 body.addClass("menu-showed");
36 $('#menu-toggle-off').click(function(e) {
38 /* Just release the menu. This way, after widening the browser,
39 * menu will still appear normally. */
41 /* Menu still visible after releasing it? Really hide it then. */
42 if ($("#menu").is(":visible")) {
43 $("body").addClass("menu-hidden");
48 /* Exit menu by clicking anywhere else. */
49 $("#box-underlay").click(release_menu);
52 /* Toggle hidden box on click. */
53 $("#menu a").each(function() {
54 var boxid = $(this).attr("data-box");
56 $("#" + $(this).attr("data-box")).hide();
58 $(this).click(function(e) {
60 var showing = $(this).hasClass("active");
63 $("body").addClass("menu-showed");
64 $(this).addClass("active");
65 $("#box-underlay").show();
66 $("#" + $(this).attr("data-box")).show();
70 else if ($(this).hasClass('dropdown')) {
71 $(this).click(function(e) {
73 var showing = $(this).hasClass("active");
76 $("body").addClass("menu-showed");
77 $("#sponsors:not(:hidden)").fadeOut();
78 $(this).addClass("active");
79 $($(this).attr('href')).slideDown('fast');
83 else if (!$(this).hasClass('button')) {
84 $(this).click(release_menu);
89 /* Show menu item for other versions of text.
90 * It's only present if there are any. */
91 $("#menu-other").show();
94 /* Load other version of text. */
95 $(".display-other").click(function(e) {
99 $("#other-text").show();
100 $("body").addClass('with-other-text');
102 $.ajax($(this).attr('data-other'), {
103 success: function(text) {
104 $("#other-text-body").html(text);
105 $("#other-text-waiter").hide();
106 $("#other-text-body").show();
107 loaded_text($("#other-text-body"));
113 /* Remove other version of text. */
114 $(".other-text-close").click(function(e) {
117 $("#other-text").hide();
118 $("body").removeClass('with-other-text');
119 $("#other-text-body").html("");
123 /* Release menu after clicking inside TOC. */
124 $("#toc a").click(release_menu);
127 if ($('#nota_red').length > 0) {
128 $("#menu-nota_red").show();
131 /* Show themes menu item, if there are any. */
132 if ($('#themes li').length > 0) {
133 $("#menu-themes").show();
136 function loaded_text(text) {
137 /* Attach events to elements inside book texts here.
138 * This way they'll work for the other text when it's loaded. */
140 $(".theme-begin", text).click(function(e) {
142 if ($(this).css("overflow") == "hidden" || $(this).hasClass('showing')) {
143 $(this).toggleClass("showing");
148 loaded_text("#book-text");