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