Holy consistent implementations, Batman!

It would appear by making code blocks that are reusable that we can
reuse them!
This commit is contained in:
Zixaphir 2014-01-19 05:29:46 -07:00
parent bec7045024
commit 2184727cd7
4 changed files with 31 additions and 45 deletions

View File

@ -6294,7 +6294,7 @@
if (!Conf['Reply Hiding Buttons']) {
return;
}
return $.add($('.postInfo', this.nodes.post), PostHiding.makeButton(this, 'hide'));
return $.add($('.postInfo', this.nodes.post), PostHiding.makeButton('hide'));
},
menu: {
init: function() {
@ -6462,18 +6462,16 @@
$.event('CloseMenu');
}
},
makeButton: function(post, type) {
var a, span;
span = $.el('span', {
className: "fa",
textContent: "" + (type === 'hide' ? '\uf068' : '\uf067')
});
makeButton: function(type, noEvent) {
var a;
a = $.el('a', {
className: "" + type + "-reply-button",
href: 'javascript:;'
href: 'javascript:;',
innerHTML: "<span class=fa>" + (type === 'hide' ? '\uf068' : '\uf067') + "</span>"
});
$.add(a, span);
$.on(a, 'click', PostHiding.toggle);
if (!noEvent) {
$.on(a, 'click', PostHiding.toggle);
}
return a;
},
saveHiddenState: function(post, isHiding, thisPost, makeStub, hideRecursively) {
@ -6525,7 +6523,7 @@
post.nodes.root.hidden = true;
return;
}
a = PostHiding.makeButton(post, 'show');
a = PostHiding.makeButton('show');
postInfo = Conf['Anonymize'] ? 'Anonymous' : $('.nameBlock', post.nodes.info).textContent;
$.add(a, $.tn(" " + postInfo));
post.nodes.stub = $.el('div', {
@ -6819,11 +6817,8 @@
},
makeButton: function(thread, type) {
var a;
a = $.el('a', {
className: "" + type + "-thread-button",
innerHTML: "<span class=fa>" + (type === 'hide' ? '\uf068' : '\uf067') + "</span>",
href: 'javascript:;'
});
a = PostHiding.makeButton(type, true);
a.className = "" + type + "-thread-button";
a.dataset.fullID = thread.fullID;
$.on(a, 'click', ThreadHiding.toggle);
return a;

View File

@ -6297,7 +6297,7 @@
if (!Conf['Reply Hiding Buttons']) {
return;
}
return $.add($('.postInfo', this.nodes.post), PostHiding.makeButton(this, 'hide'));
return $.add($('.postInfo', this.nodes.post), PostHiding.makeButton('hide'));
},
menu: {
init: function() {
@ -6465,18 +6465,16 @@
$.event('CloseMenu');
}
},
makeButton: function(post, type) {
var a, span;
span = $.el('span', {
className: "fa",
textContent: "" + (type === 'hide' ? '\uf068' : '\uf067')
});
makeButton: function(type, noEvent) {
var a;
a = $.el('a', {
className: "" + type + "-reply-button",
href: 'javascript:;'
href: 'javascript:;',
innerHTML: "<span class=fa>" + (type === 'hide' ? '\uf068' : '\uf067') + "</span>"
});
$.add(a, span);
$.on(a, 'click', PostHiding.toggle);
if (!noEvent) {
$.on(a, 'click', PostHiding.toggle);
}
return a;
},
saveHiddenState: function(post, isHiding, thisPost, makeStub, hideRecursively) {
@ -6528,7 +6526,7 @@
post.nodes.root.hidden = true;
return;
}
a = PostHiding.makeButton(post, 'show');
a = PostHiding.makeButton('show');
postInfo = Conf['Anonymize'] ? 'Anonymous' : $('.nameBlock', post.nodes.info).textContent;
$.add(a, $.tn(" " + postInfo));
post.nodes.stub = $.el('div', {
@ -6822,11 +6820,8 @@
},
makeButton: function(thread, type) {
var a;
a = $.el('a', {
className: "" + type + "-thread-button",
innerHTML: "<span class=fa>" + (type === 'hide' ? '\uf068' : '\uf067') + "</span>",
href: 'javascript:;'
});
a = PostHiding.makeButton(type, true);
a.className = "" + type + "-thread-button";
a.dataset.fullID = thread.fullID;
$.on(a, 'click', ThreadHiding.toggle);
return a;

View File

@ -19,7 +19,7 @@ PostHiding =
Recursive.apply PostHiding.hide, @, data.makeStub, true
Recursive.add PostHiding.hide, @, data.makeStub, true
return unless Conf['Reply Hiding Buttons']
$.add $('.postInfo', @nodes.post), PostHiding.makeButton @, 'hide'
$.add $('.postInfo', @nodes.post), PostHiding.makeButton 'hide'
menu:
init: ->
@ -151,15 +151,12 @@ PostHiding =
$.event 'CloseMenu'
return
makeButton: (post, type) ->
span = $.el 'span',
className: "fa"
textContent: "#{if type is 'hide' then '\uf068' else '\uf067'}"
makeButton: (type, noEvent) ->
a = $.el 'a',
className: "#{type}-reply-button"
href: 'javascript:;'
$.add a, span
$.on a, 'click', PostHiding.toggle
innerHTML: "<span class=fa>#{if type is 'hide' then '\uf068' else '\uf067'}</span>"
$.on a, 'click', PostHiding.toggle unless noEvent
a
saveHiddenState: (post, isHiding, thisPost, makeStub, hideRecursively) ->
@ -196,7 +193,7 @@ PostHiding =
post.nodes.root.hidden = true
return
a = PostHiding.makeButton post, 'show'
a = PostHiding.makeButton 'show'
postInfo =
if Conf['Anonymize']
'Anonymous'

View File

@ -144,13 +144,12 @@ ThreadHiding =
return
makeButton: (thread, type) ->
a = $.el 'a',
className: "#{type}-thread-button"
innerHTML: "<span class=fa>#{if type is 'hide' then '\uf068' else '\uf067'}</span>"
href: 'javascript:;'
a = PostHiding.makeButton type, true
a.className = "#{type}-thread-button"
a.dataset.fullID = thread.fullID
$.on a, 'click', ThreadHiding.toggle
$.on a, 'click', ThreadHiding.toggle
a
makeStub: (thread, root) ->
numReplies = $$('.thread > .replyContainer', root).length
numReplies += +summary.textContent.match /\d+/ if summary = $ '.summary', root