Experiments with new reader.
[wolnelektury.git] / apps / wolnelektury_core / static / js / book_text / box.js
diff --git a/apps/wolnelektury_core/static/js/book_text/box.js b/apps/wolnelektury_core/static/js/book_text/box.js
new file mode 100644 (file)
index 0000000..e26762c
--- /dev/null
@@ -0,0 +1,19 @@
+$(function() {
+    /* Toggle hidden box on click. */
+    $("nav a[data-box]").each(function() {
+        $("#" + $(this).attr("data-box")).hide();
+
+        $(this).click(function(e) {
+            e.preventDefault();
+            var showing = $(this).hasClass("active");
+            $("nav .active").each(function() {
+                $(this).removeClass("active");
+                $("#" + $(this).attr("data-box")).hide();
+            });
+            if (!showing) {
+                $(this).addClass("active");
+                $("#" + $(this).attr("data-box")).show();
+            }
+        });
+    });
+});