fix in librarian
[wolnelektury.git] / apps / wolnelektury_core / static / js / base.js
old mode 100755 (executable)
new mode 100644 (file)
index 77315e6..f2a8e26
@@ -59,6 +59,7 @@
 
                (function() {
                        var $current = null;
 
                (function() {
                        var $current = null;
+            var menu_loaded = false;
                        $('.hidden-box-wrapper').each(function() {
                                var $hidden = $('.hidden-box', this);
                                $('.hidden-box-trigger', this).click(function(event) {
                        $('.hidden-box-wrapper').each(function() {
                                var $hidden = $('.hidden-box', this);
                                $('.hidden-box-trigger', this).click(function(event) {
                                                $current && $current.hide('fast');
                                                $hidden.show('fast');
                                                $current = $hidden;
                                                $current && $current.hide('fast');
                                                $hidden.show('fast');
                                                $current = $hidden;
+                        if ($(this).hasClass('load-menu') && !menu_loaded) {
+                            $.ajax({
+                                url: '/katalog/' + LANGUAGE_CODE + '.json',
+                                dataType: "json",
+                            }).done(function(data) {
+                                $.each(data, function(index, value) {
+                                    var $menuitem = $('#menu-' + index);
+                                    $menuitem.html(value);
+                                    var $minisearch = $("<input class='mini-search' style='margin-bottom: 1em' />");
+                                    $minisearch.keyup(function() {
+                                        var s = $(this).val().toLowerCase();
+                                        if (s) {
+                                            $("li", $menuitem).each(function() {
+                                                if ($("a", this).text().toLowerCase().indexOf(s) != -1)
+                                                    $(this).show();
+                                                else $(this).hide();
+                                            });
+                                        }
+                                        else {
+                                            $("li", $menuitem).css("display", "");
+                                        }
+                                    });
+                                    $menuitem.prepend($minisearch);
+                                });
+                                menu_loaded = true;
+                            });
+                        }
                                        } 
                                });
                        });
                                        } 
                                });
                        });
+                   /* this kinda breaks the whole page. */
                        $('body').click(function(e) {
                                if ($current == null) return;
                                var p = $(e.target);
                                while (p.length) {
                                        if (p == $current)
                                                return;
                        $('body').click(function(e) {
                                if ($current == null) return;
                                var p = $(e.target);
                                while (p.length) {
                                        if (p == $current)
                                                return;
-                                       if (p.hasClass('hidden-box-trigger'))
+                                       if (p.hasClass('hidden-box-trigger') 
+                                           || p.hasClass('simple-toggler')
+                        || p.hasClass('mini-search'))
                                                return;
                                        p = p.parent();
                                }
                                                return;
                                        p = p.parent();
                                }
                })();
                
 
                })();
                
 
-
-
-$('#themes-list-toggle').click(function(event) {
+$('#show-menu').click(function(event) {
     event.preventDefault();
     event.preventDefault();
-    $('#themes-list').toggle('slow');
+    $('#menu').toggle('slow');
+});
+$('#book-list-nav h2').click(function(event) {
+    event.preventDefault();
+    $('#book-list-nav-index').toggle();
 });
 
 
 });
 
 
-$('.open-player').click(function(event) {
+$('#themes-list-toggle').click(function(event) {
     event.preventDefault();
     event.preventDefault();
-    window.open($(this).attr('href'),
-        'player',
-        'width=422, height=500'
-        );
+    $('#themes-list').toggle('slow');
 });
 
 
 });
 
 
@@ -119,6 +149,19 @@ $('.open-player').click(function(event) {
        $(function(){
            $("#search").search();});
 
        $(function(){
            $("#search").search();});
 
+      $('body').on('click', '.simple-toggler' , function(ev) {
+       ev.preventDefault();
+       var scope = $(this).closest('.simple-toggler-scope');
+       scope.find('.simple-hidden-box').each(function(){ 
+         var $this = $(this);
+         if ($this.is(':hidden')) {
+           $this.show();
+         } else { 
+           $this.hide();
+         }
+         });
+      });
+
     });
 })(jQuery);
 
     });
 })(jQuery);