X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/68dbe44bdbc497a82064c6a47eeaecbb34463f64..0bd2c341a8b55f817c2e193a6c4658d52ef95961:/apps/wolnelektury_core/static/js/base.js diff --git a/apps/wolnelektury_core/static/js/base.js b/apps/wolnelektury_core/static/js/base.js old mode 100755 new mode 100644 index 7db29ab24..4b6c5d34e --- a/apps/wolnelektury_core/static/js/base.js +++ b/apps/wolnelektury_core/static/js/base.js @@ -77,7 +77,23 @@ dataType: "json", }).done(function(data) { $.each(data, function(index, value) { - $('#menu-' + index).html(value); + var $menuitem = $('#menu-' + index); + $menuitem.html(value); + var $minisearch = $(""); + $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; }); @@ -85,13 +101,16 @@ } }); }); + /* 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; - if (p.hasClass('hidden-box-trigger')) + if (p.hasClass('hidden-box-trigger') + || p.hasClass('simple-toggler') + || p.hasClass('mini-search')) return; p = p.parent(); } @@ -130,6 +149,19 @@ $('#themes-list-toggle').click(function(event) { $(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);