From 5f10badee90cadee42e051a10dbefb2a54045d5d Mon Sep 17 00:00:00 2001 From: 8chan Date: Mon, 5 Jan 2015 04:38:35 -0800 Subject: [PATCH] Make no-animated-gif.js trigger on new_post --- js/no-animated-gif.js | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/js/no-animated-gif.js b/js/no-animated-gif.js index 7036323c..42c841ab 100644 --- a/js/no-animated-gif.js +++ b/js/no-animated-gif.js @@ -11,7 +11,6 @@ * //$config['additional_javascript'][] = 'js/options/general.js'; * $config['additional_javascript'][] = 'js/no-animated-gif.js'; */ - function unanimate_gif(e) { if ($(e).closest('.thread').children('.thread-hidden').length > 0) return; @@ -36,13 +35,19 @@ function unanimate_gif(e) { $(e).addClass("unanimated").hide(); } +$(function(){ + +var gif_finder = 'img.post-image[src$=".gif"], img.thread-image[src$=".gif"]'; + function no_animated_gif() { - var anim_gifs = $('img.post-image[src$=".gif"], img.thread-image[src$=".gif"]'); + var anim_gifs = $(gif_finder); localStorage.no_animated_gif = true; $('#no-animated-gif>a').text(_('Animate GIFs')); $('#no-animated-gif>input').prop('checked', true); $.each(anim_gifs, function(i, e) {unanimate_gif(e)} ); + + $(document).on('new_post', new_post_handler); } function animated_gif() { @@ -51,10 +56,17 @@ function animated_gif() { localStorage.no_animated_gif = false; $('#no-animated-gif>a').text(_('Unanimate GIFs')); $('#no-animated-gif>input').prop('checked', false); + + $(document).off('new_post', new_post_handler); +} + +function new_post_handler(e, post) { + $(post).find(gif_finder).each(function(k, v) { + unanimate_gif(v); + }); } if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko' || active_page == 'catalog') { - $(function(){ var selector, event; if (window.Options && Options.get_tab('general')) { selector = '#no-animated-gif>input'; @@ -77,5 +89,6 @@ if (active_page == 'thread' || active_page == 'index' || active_page == 'ukko' | if (localStorage.no_animated_gif === 'true') no_animated_gif(); - }); } + +});