X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/2c968d7bbf97b820439c6a997de08cc3411abb07..76849e4b3dcc3305edbe86b794b04a0bf4a8467c:/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 index 77315e6f7..4d979af0c 100755 --- a/apps/wolnelektury_core/static/js/base.js +++ b/apps/wolnelektury_core/static/js/base.js @@ -59,6 +59,7 @@ (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) { @@ -70,16 +71,29 @@ $current && $current.hide('fast'); $hidden.show('fast'); $current = $hidden; + if ($(this).hasClass('load-menu') && !menu_loaded) { + $.ajax({ + url: '/katalog/', + dataType: "json", + }).done(function(data) { + $.each(data, function(index, value) { + $('#menu-' + index).html(value); + }); + 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; - if (p.hasClass('hidden-box-trigger')) + if (p.hasClass('hidden-box-trigger') + || p.hasClass('simple-toggler')) return; p = p.parent(); } @@ -97,15 +111,6 @@ $('#themes-list-toggle').click(function(event) { }); -$('.open-player').click(function(event) { - event.preventDefault(); - window.open($(this).attr('href'), - 'player', - 'width=422, height=500' - ); -}); - - $('.book-list-index').click(function(){ $('.book-list-show-index').hide('slow'); if($(this).parent().next('ul:not(:hidden)').length == 0){ @@ -119,6 +124,19 @@ $('.open-player').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);