Don't use closures for event callbacks.
This commit is contained in:
parent
1bc2c17e41
commit
6b87f9c977
@ -2000,9 +2000,8 @@
|
|||||||
innerHTML: "<span>[ " + (type === 'hide' ? '-' : '+') + " ]</span>",
|
innerHTML: "<span>[ " + (type === 'hide' ? '-' : '+') + " ]</span>",
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
});
|
});
|
||||||
$.on(a, 'click', function() {
|
a.setAttribute('data-fullid', thread.fullID);
|
||||||
return ThreadHiding.toggle(thread);
|
$.on(a, 'click', ThreadHiding.toggle);
|
||||||
});
|
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
saveHiddenState: function(thread, makeStub) {
|
saveHiddenState: function(thread, makeStub) {
|
||||||
@ -2022,6 +2021,9 @@
|
|||||||
return localStorage.setItem("4chan-hide-t-" + g.BOARD, JSON.stringify(hiddenThreadsCatalog));
|
return localStorage.setItem("4chan-hide-t-" + g.BOARD, JSON.stringify(hiddenThreadsCatalog));
|
||||||
},
|
},
|
||||||
toggle: function(thread) {
|
toggle: function(thread) {
|
||||||
|
if (!(thread instanceof Thread)) {
|
||||||
|
thread = g.threads[this.dataset.fullid];
|
||||||
|
}
|
||||||
if (thread.isHidden) {
|
if (thread.isHidden) {
|
||||||
ThreadHiding.show(thread);
|
ThreadHiding.show(thread);
|
||||||
} else {
|
} else {
|
||||||
@ -2188,9 +2190,7 @@
|
|||||||
innerHTML: "<span>[ " + (type === 'hide' ? '-' : '+') + " ]</span>",
|
innerHTML: "<span>[ " + (type === 'hide' ? '-' : '+') + " ]</span>",
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
});
|
});
|
||||||
$.on(a, 'click', function() {
|
$.on(a, 'click', ReplyHiding.toggle);
|
||||||
return ReplyHiding.toggle(post);
|
|
||||||
});
|
|
||||||
return a;
|
return a;
|
||||||
},
|
},
|
||||||
saveHiddenState: function(post, isHiding, thisPost, makeStub, hideRecursively) {
|
saveHiddenState: function(post, isHiding, thisPost, makeStub, hideRecursively) {
|
||||||
@ -2214,7 +2214,9 @@
|
|||||||
}
|
}
|
||||||
return $.set("hiddenPosts." + g.BOARD, hiddenPosts);
|
return $.set("hiddenPosts." + g.BOARD, hiddenPosts);
|
||||||
},
|
},
|
||||||
toggle: function(post) {
|
toggle: function() {
|
||||||
|
var post;
|
||||||
|
post = Get.postFromNode(this);
|
||||||
if (post.isHidden) {
|
if (post.isHidden) {
|
||||||
ReplyHiding.show(post);
|
ReplyHiding.show(post);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -953,7 +953,8 @@ ThreadHiding =
|
|||||||
className: "#{type}-thread-button"
|
className: "#{type}-thread-button"
|
||||||
innerHTML: "<span>[ #{if type is 'hide' then '-' else '+'} ]</span>"
|
innerHTML: "<span>[ #{if type is 'hide' then '-' else '+'} ]</span>"
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on a, 'click', -> ThreadHiding.toggle thread
|
a.setAttribute 'data-fullid', thread.fullID
|
||||||
|
$.on a, 'click', ThreadHiding.toggle
|
||||||
a
|
a
|
||||||
|
|
||||||
saveHiddenState: (thread, makeStub) ->
|
saveHiddenState: (thread, makeStub) ->
|
||||||
@ -970,6 +971,8 @@ ThreadHiding =
|
|||||||
localStorage.setItem "4chan-hide-t-#{g.BOARD}", JSON.stringify hiddenThreadsCatalog
|
localStorage.setItem "4chan-hide-t-#{g.BOARD}", JSON.stringify hiddenThreadsCatalog
|
||||||
|
|
||||||
toggle: (thread) ->
|
toggle: (thread) ->
|
||||||
|
unless thread instanceof Thread
|
||||||
|
thread = g.threads[@dataset.fullid]
|
||||||
if thread.isHidden
|
if thread.isHidden
|
||||||
ThreadHiding.show thread
|
ThreadHiding.show thread
|
||||||
else
|
else
|
||||||
@ -1092,7 +1095,7 @@ ReplyHiding =
|
|||||||
className: "#{type}-reply-button"
|
className: "#{type}-reply-button"
|
||||||
innerHTML: "<span>[ #{if type is 'hide' then '-' else '+'} ]</span>"
|
innerHTML: "<span>[ #{if type is 'hide' then '-' else '+'} ]</span>"
|
||||||
href: 'javascript:;'
|
href: 'javascript:;'
|
||||||
$.on a, 'click', -> ReplyHiding.toggle post
|
$.on a, 'click', ReplyHiding.toggle
|
||||||
a
|
a
|
||||||
|
|
||||||
saveHiddenState: (post, isHiding, thisPost, makeStub, hideRecursively) ->
|
saveHiddenState: (post, isHiding, thisPost, makeStub, hideRecursively) ->
|
||||||
@ -1112,7 +1115,8 @@ ReplyHiding =
|
|||||||
delete hiddenPosts.threads[post.thread]
|
delete hiddenPosts.threads[post.thread]
|
||||||
$.set "hiddenPosts.#{g.BOARD}", hiddenPosts
|
$.set "hiddenPosts.#{g.BOARD}", hiddenPosts
|
||||||
|
|
||||||
toggle: (post) ->
|
toggle: ->
|
||||||
|
post = Get.postFromNode @
|
||||||
if post.isHidden
|
if post.isHidden
|
||||||
ReplyHiding.show post
|
ReplyHiding.show post
|
||||||
else
|
else
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user