From 2382603b4d5864e5e687dab454f931aab893a65e Mon Sep 17 00:00:00 2001 From: czaks Date: Wed, 25 Dec 2013 18:12:00 +0100 Subject: [PATCH] fix hide-images.js interactions (should be STI-safe) --- js/expand.js | 2 +- js/hide-images.js | 23 ++++++++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/js/expand.js b/js/expand.js index a25b79ac..1d0d944d 100644 --- a/js/expand.js +++ b/js/expand.js @@ -27,7 +27,7 @@ $(document).ready(function(){ success: function(data) { var last_expanded = false; $(data).find('div.post.reply').each(function() { - thread.find('.hidden').remove(); + thread.find('div.hidden').remove(); var post_in_doc = thread.find('#' + $(this).attr('id')); if(post_in_doc.length == 0) { if(last_expanded) { diff --git a/js/hide-images.js b/js/hide-images.js index 365ebac6..39cfe2f5 100644 --- a/js/hide-images.js +++ b/js/hide-images.js @@ -16,8 +16,6 @@ $(document).ready(function(){ $('').appendTo($('head')); - var board = $('form input[name="board"]').val().toString(); - if (!localStorage.hiddenimages) localStorage.hiddenimages = '{}'; @@ -38,14 +36,16 @@ $(document).ready(function(){ } } - if (!hidden_data[board]) { - hidden_data[board] = {}; // id : timestamp - } - - $('div.post > a > img, div > a > img').each(function() { + var handle_images = function() { var img = this; var fileinfo = $(this).parent().prev(); var id = $(this).parent().parent().find('>p.intro>a.post_no:eq(1),>div.post.op>p.intro>a.post_no:eq(1)').text(); + + var board = $(this).parents('[id^="thread_"]').data("board"); + + if (!hidden_data[board]) { + hidden_data[board] = {}; // id : timestamp + } var replacement = $(''+_('File')+' ('+_('hide')+'): '); @@ -79,6 +79,11 @@ $(document).ready(function(){ if (hidden_data[board][id]) $(this).parent().prev().find('.hide-image-link').click(); - - }); + }; + + $('div.post > a > img, div > a > img').each(handle_images); + + $(document).bind('new_post', function(e, post) { + $(post).find('> a > img').each(handle_images); + }); });