if (active_page == 'index' || active_page == 'thread') $(function(){ var gallery_view = false; $('hr:first').before('
'); $('#gallery-view a').html(gallery_view ? _("Disable gallery mode") : _("Enable gallery mode")).click(function() { gallery_view = !gallery_view; $(this).html(gallery_view ? _("Disable gallery mode") : _("Enable gallery mode")); toggle_gview(document); }); var toggle_gview = function(elem) { if (gallery_view) { $(elem).find('img.post-image').parent().each(function() { this.oldonclick = this.onclick; this.onclick = handle_click; $(this).attr('data-galid', Math.random()); }); } else { $(elem).find('img.post-image').parent().each(function() { if (this.onclick == handle_click) this.onclick = this.oldonclick; }); } }; $(document).on('new_post', toggle_gview); var gallery_opened = false; var handle_click = function(e) { e.stopPropagation(); e.preventDefault(); if (!gallery_opened) open_gallery(); gallery_setimage($(this).attr('data-galid')); }; var handler, images, active, toolbar; var open_gallery = function() { $('body').css('overflow', 'hidden'); gallery_opened = true; handler = $("").hide().appendTo('body').css('text-align', 'left'); $("").click(close_gallery).appendTo(handler); images = $("").appendTo(handler); toolbar = $("").appendTo(handler); active = $("").appendTo(handler); active.on('click', function() { close_gallery(); }); $('img.post-image').parent().each(function() { var thumb = $(this).find('img').attr('src'); var i = $('