Fix thread hiding stubs.

This commit is contained in:
Nicolas Stepien 2013-03-07 19:39:48 +01:00
parent e0600eb02e
commit 12fb19de2c
2 changed files with 9 additions and 7 deletions

View File

@ -2085,14 +2085,15 @@
return ThreadHiding.saveHiddenState(thread); return ThreadHiding.saveHiddenState(thread);
}, },
hide: function(thread, makeStub) { hide: function(thread, makeStub) {
var a, numReplies, opInfo, span, threadRoot; var OP, a, numReplies, opInfo, span, threadRoot;
if (makeStub == null) { if (makeStub == null) {
makeStub = Conf['Stubs']; makeStub = Conf['Stubs'];
} }
if (thread.hidden) { if (thread.hidden) {
return; return;
} }
threadRoot = thread.OP.nodes.root.parentNode; OP = thread.OP;
threadRoot = OP.nodes.root.parentNode;
threadRoot.hidden = thread.isHidden = true; threadRoot.hidden = thread.isHidden = true;
if (!makeStub) { if (!makeStub) {
threadRoot.nextElementSibling.hidden = true; threadRoot.nextElementSibling.hidden = true;
@ -2104,7 +2105,7 @@
} }
numReplies += $$('.opContainer ~ .replyContainer', threadRoot).length; numReplies += $$('.opContainer ~ .replyContainer', threadRoot).length;
numReplies = numReplies === 1 ? '1 reply' : "" + numReplies + " replies"; numReplies = numReplies === 1 ? '1 reply' : "" + numReplies + " replies";
opInfo = Conf['Anonymize'] ? 'Anonymous' : $('.nameBlock', op.nodes.info).textContent; opInfo = Conf['Anonymize'] ? 'Anonymous' : $('.nameBlock', OP.nodes.info).textContent;
a = ThreadHiding.makeButton(thread, 'show'); a = ThreadHiding.makeButton(thread, 'show');
$.add(a, $.tn(" " + opInfo + " (" + numReplies + ")")); $.add(a, $.tn(" " + opInfo + " (" + numReplies + ")"));
thread.stub = $.el('div', { thread.stub = $.el('div', {
@ -2112,7 +2113,7 @@
}); });
$.add(thread.stub, a); $.add(thread.stub, a);
if (Conf['Menu']) { if (Conf['Menu']) {
$.add(thread.stub, [$.tn(' '), Menu.makeButton(op)]); $.add(thread.stub, [$.tn(' '), Menu.makeButton(OP)]);
} }
return $.before(threadRoot, thread.stub); return $.before(threadRoot, thread.stub);
}, },

View File

@ -1008,7 +1008,8 @@ ThreadHiding =
hide: (thread, makeStub=Conf['Stubs']) -> hide: (thread, makeStub=Conf['Stubs']) ->
return if thread.hidden return if thread.hidden
threadRoot = thread.OP.nodes.root.parentNode {OP} = thread
threadRoot = OP.nodes.root.parentNode
threadRoot.hidden = thread.isHidden = true threadRoot.hidden = thread.isHidden = true
unless makeStub unless makeStub
@ -1024,7 +1025,7 @@ ThreadHiding =
if Conf['Anonymize'] if Conf['Anonymize']
'Anonymous' 'Anonymous'
else else
$('.nameBlock', op.nodes.info).textContent $('.nameBlock', OP.nodes.info).textContent
a = ThreadHiding.makeButton thread, 'show' a = ThreadHiding.makeButton thread, 'show'
$.add a, $.tn " #{opInfo} (#{numReplies})" $.add a, $.tn " #{opInfo} (#{numReplies})"
@ -1032,7 +1033,7 @@ ThreadHiding =
className: 'stub' className: 'stub'
$.add thread.stub, a $.add thread.stub, a
if Conf['Menu'] if Conf['Menu']
$.add thread.stub, [$.tn(' '), Menu.makeButton op] $.add thread.stub, [$.tn(' '), Menu.makeButton OP]
$.before threadRoot, thread.stub $.before threadRoot, thread.stub
show: (thread) -> show: (thread) ->