소스 검색

Make no-animated-gif.js trigger on new_post

pull/47/head^2
8chan czaks 9 년 전
부모
커밋
5f10badee9
1개의 변경된 파일17개의 추가작업 그리고 4개의 파일을 삭제
  1. +17
    -4
      js/no-animated-gif.js

+ 17
- 4
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();
});
}

});

불러오는 중...
취소
저장