Force stub menu to work

This commit is contained in:
Zixaphir 2013-08-09 19:21:26 -07:00
parent 97f7cca2b1
commit ee291bad0c
7 changed files with 244 additions and 173 deletions

View File

@ -1996,7 +1996,7 @@
} }
}, },
postFromNode: function(root) { postFromNode: function(root) {
return Get.postFromRoot($.x('ancestor::div[contains(@class,"postContainer")][1]', root)); return Get.postFromRoot($.x('(ancestor::div[contains(@class,"postContainer")]|following::div[contains(@class,"postContainer")])', root));
}, },
contextFromNode: function(quotelink) { contextFromNode: function(quotelink) {
return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', quotelink)); return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', quotelink));
@ -3225,15 +3225,11 @@
var post; var post;
post = Get.postFromNode(this); post = Get.postFromNode(this);
if (post.isHidden) { PostHiding[(post.isHidden ? 'show' : 'hide')](post);
PostHiding.show(post);
} else {
PostHiding.hide(post);
}
return PostHiding.saveHiddenState(post, post.isHidden); return PostHiding.saveHiddenState(post, post.isHidden);
}, },
hide: function(post, makeStub, hideRecursively) { hide: function(post, makeStub, hideRecursively) {
var a, postInfo, quotelink, _i, _len, _ref; var a, button, postInfo, quotelink, _i, _len, _ref;
if (makeStub == null) { if (makeStub == null) {
makeStub = Conf['Stubs']; makeStub = Conf['Stubs'];
@ -3259,15 +3255,12 @@
return; return;
} }
a = PostHiding.makeButton(post, 'show'); a = PostHiding.makeButton(post, 'show');
postInfo = Conf['Anonymize'] ? 'Anonymous' : $('.nameBlock', post.nodes.info).textContent; postInfo = Conf['Anonymize'] ? 'Anonymous' : post.info.name;
$.add(a, $.tn(" " + postInfo)); $.add(a, $.tn(" " + postInfo));
post.nodes.stub = $.el('div', { post.nodes.stub = $.el('div', {
className: 'stub' className: 'stub'
}); });
$.add(post.nodes.stub, a); $.add(post.nodes.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(post)]);
if (Conf['Menu']) {
$.add(post.nodes.stub, [$.tn(' '), Menu.makeButton(post)]);
}
return $.prepend(post.nodes.root, post.nodes.stub); return $.prepend(post.nodes.root, post.nodes.stub);
}, },
show: function(post, showRecursively) { show: function(post, showRecursively) {
@ -3462,11 +3455,6 @@
makeStub = $.el('label', { makeStub = $.el('label', {
innerHTML: "<input type=checkbox " + (Conf['Stubs'] ? 'checked' : '') + "> Make stub" innerHTML: "<input type=checkbox " + (Conf['Stubs'] ? 'checked' : '') + "> Make stub"
}); });
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
$.event('AddMenuEntry', { $.event('AddMenuEntry', {
type: 'post', type: 'post',
el: div, el: div,
@ -3489,6 +3477,34 @@
} }
] ]
}); });
div = $.el('a', {
className: 'show-thread-link',
textContent: 'Show thread',
href: 'javascript:;'
});
$.on(show, 'click', ThreadHiding.menu.show);
$.event('AddMenuEntry', {
type: 'post'
});
({
el: div,
order: 20,
open: function(_arg) {
var isReply, thread;
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
}
ThreadHiding.menu.thread = thread;
return true;
}
});
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
return $.event('AddMenuEntry', { return $.event('AddMenuEntry', {
type: 'post', type: 'post',
el: hideStubLink, el: hideStubLink,
@ -3513,6 +3529,14 @@
ThreadHiding.saveHiddenState(thread, makeStub); ThreadHiding.saveHiddenState(thread, makeStub);
return $.event('CloseMenu'); return $.event('CloseMenu');
}, },
show: function() {
var thread;
thread = ThreadHiding.menu.thread;
ThreadHiding.show(thread);
ThreadHiding.saveHiddenState(thread);
return $.event('CloseMenu');
},
hideStub: function() { hideStub: function() {
var thread; var thread;
@ -3567,7 +3591,7 @@
return ThreadHiding.saveHiddenState(thread); return ThreadHiding.saveHiddenState(thread);
}, },
hide: function(thread, makeStub) { hide: function(thread, makeStub) {
var OP, a, numReplies, opInfo, span, threadRoot; var OP, a, button, numReplies, opInfo, span, threadRoot;
if (makeStub == null) { if (makeStub == null) {
makeStub = Conf['Stubs']; makeStub = Conf['Stubs'];
@ -3579,22 +3603,15 @@
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true; threadRoot.hidden = threadRoot.nextElementSibling.hidden = true;
return; return;
} }
numReplies = 0; numReplies = ((span = $('.summary', threadRoot)) ? +span.textContent.match(/\d+/) : 0) + $$('.opContainer ~ .replyContainer', threadRoot).length;
if (span = $('.summary', threadRoot)) { numReplies = numReplies === 1 ? '1 reply' : "" + (numReplies || 'No') + " replies";
numReplies = +span.textContent.match(/\d+/); opInfo = Conf['Anonymize'] ? 'Anonymous' : OP.info.name;
}
numReplies += $$('.opContainer ~ .replyContainer', threadRoot).length;
numReplies = numReplies === 1 ? '1 reply' : "" + numReplies + " replies";
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', {
className: 'stub' className: 'stub'
}); });
$.add(thread.stub, a); $.add(thread.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(OP)]);
if (Conf['Menu']) {
$.add(thread.stub, [$.tn(' '), Menu.makeButton(OP)]);
}
return $.prepend(threadRoot, thread.stub); return $.prepend(threadRoot, thread.stub);
}, },
show: function(thread) { show: function(thread) {
@ -4203,7 +4220,9 @@
seek: function(type) { seek: function(type) {
var post, posts, result, str; var post, posts, result, str;
return unlses(Conf['Mark Quotes of You'] && Conf['Quick Reply']); if (!(Conf['Mark Quotes of You'] && Conf['Quick Reply'])) {
return;
}
$.rmClass($('.highlight'), 'highlight'); $.rmClass($('.highlight'), 'highlight');
if (!QuoteYou.lastRead) { if (!QuoteYou.lastRead) {
if (!(post = QuoteYou.lastRead = $('.quotesYou'))) { if (!(post = QuoteYou.lastRead = $('.quotesYou'))) {
@ -6993,45 +7012,48 @@
} }
}; };
Menu = { Menu = (function() {
init: function() { var a;
if (g.VIEW === 'catalog' || !Conf['Menu']) {
return;
}
this.menu = new UI.Menu('post');
return Post.prototype.callbacks.push({
name: 'Menu',
cb: this.node
});
},
node: function() {
var button;
if (this.isClone) { a = $.el('a', {
button = $('.menu-button', this.nodes.info); className: 'menu-button brackets-wrap',
} else { innerHTML: '<span class=drop-marker></span>',
button = Menu.makeButton(this); href: 'javascript:;'
$.add(this.nodes.info, [$.tn('\u00A0'), button]); });
} return {
return $.on(button, 'click', Menu.toggle); init: function() {
}, if (g.VIEW === 'catalog' || !Conf['Menu']) {
makeButton: (function() { return;
var a; }
this.menu = new UI.Menu('post');
return Post.prototype.callbacks.push({
name: 'Menu',
cb: this.node
});
},
node: function() {
var button;
a = null; if (this.isClone) {
return function() { button = $('.menu-button', this.nodes.info);
a || (a = $.el('a', { } else {
className: 'menu-button fourchanx-link', button = a.cloneNode(true);
innerHTML: '<i></i>', $.add(this.nodes.info, [$.tn('\u00A0'), button]);
href: 'javascript:;' }
})); return $.on(button, 'click', Menu.toggle);
return a.cloneNode(true); },
}; makeButton: function() {
})(), var el;
toggle: function(e) {
return Menu.menu.toggle(e, this, Get.postFromNode(this)); el = a.cloneNode(true);
} $.on(el, 'click', Menu.toggle);
}; return el;
},
toggle: function(e) {
return Menu.menu.toggle(e, this, Get.postFromNode(this));
}
};
})();
ReportLink = { ReportLink = {
init: function() { init: function() {

View File

@ -2008,7 +2008,7 @@
} }
}, },
postFromNode: function(root) { postFromNode: function(root) {
return Get.postFromRoot($.x('ancestor::div[contains(@class,"postContainer")][1]', root)); return Get.postFromRoot($.x('(ancestor::div[contains(@class,"postContainer")]|following::div[contains(@class,"postContainer")])', root));
}, },
contextFromNode: function(quotelink) { contextFromNode: function(quotelink) {
return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', quotelink)); return Get.postFromRoot($.x('ancestor::div[parent::div[@class="thread"]][1]', quotelink));
@ -3230,15 +3230,11 @@
var post; var post;
post = Get.postFromNode(this); post = Get.postFromNode(this);
if (post.isHidden) { PostHiding[(post.isHidden ? 'show' : 'hide')](post);
PostHiding.show(post);
} else {
PostHiding.hide(post);
}
return PostHiding.saveHiddenState(post, post.isHidden); return PostHiding.saveHiddenState(post, post.isHidden);
}, },
hide: function(post, makeStub, hideRecursively) { hide: function(post, makeStub, hideRecursively) {
var a, postInfo, quotelink, _i, _len, _ref; var a, button, postInfo, quotelink, _i, _len, _ref;
if (makeStub == null) { if (makeStub == null) {
makeStub = Conf['Stubs']; makeStub = Conf['Stubs'];
@ -3264,15 +3260,12 @@
return; return;
} }
a = PostHiding.makeButton(post, 'show'); a = PostHiding.makeButton(post, 'show');
postInfo = Conf['Anonymize'] ? 'Anonymous' : $('.nameBlock', post.nodes.info).textContent; postInfo = Conf['Anonymize'] ? 'Anonymous' : post.info.name;
$.add(a, $.tn(" " + postInfo)); $.add(a, $.tn(" " + postInfo));
post.nodes.stub = $.el('div', { post.nodes.stub = $.el('div', {
className: 'stub' className: 'stub'
}); });
$.add(post.nodes.stub, a); $.add(post.nodes.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(post)]);
if (Conf['Menu']) {
$.add(post.nodes.stub, [$.tn(' '), Menu.makeButton(post)]);
}
return $.prepend(post.nodes.root, post.nodes.stub); return $.prepend(post.nodes.root, post.nodes.stub);
}, },
show: function(post, showRecursively) { show: function(post, showRecursively) {
@ -3467,11 +3460,6 @@
makeStub = $.el('label', { makeStub = $.el('label', {
innerHTML: "<input type=checkbox " + (Conf['Stubs'] ? 'checked' : '') + "> Make stub" innerHTML: "<input type=checkbox " + (Conf['Stubs'] ? 'checked' : '') + "> Make stub"
}); });
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
$.event('AddMenuEntry', { $.event('AddMenuEntry', {
type: 'post', type: 'post',
el: div, el: div,
@ -3494,6 +3482,34 @@
} }
] ]
}); });
div = $.el('a', {
className: 'show-thread-link',
textContent: 'Show thread',
href: 'javascript:;'
});
$.on(show, 'click', ThreadHiding.menu.show);
$.event('AddMenuEntry', {
type: 'post'
});
({
el: div,
order: 20,
open: function(_arg) {
var isReply, thread;
thread = _arg.thread, isReply = _arg.isReply;
if (isReply || !thread.isHidden) {
return false;
}
ThreadHiding.menu.thread = thread;
return true;
}
});
hideStubLink = $.el('a', {
textContent: 'Hide stub',
href: 'javascript:;'
});
$.on(hideStubLink, 'click', ThreadHiding.menu.hideStub);
return $.event('AddMenuEntry', { return $.event('AddMenuEntry', {
type: 'post', type: 'post',
el: hideStubLink, el: hideStubLink,
@ -3518,6 +3534,14 @@
ThreadHiding.saveHiddenState(thread, makeStub); ThreadHiding.saveHiddenState(thread, makeStub);
return $.event('CloseMenu'); return $.event('CloseMenu');
}, },
show: function() {
var thread;
thread = ThreadHiding.menu.thread;
ThreadHiding.show(thread);
ThreadHiding.saveHiddenState(thread);
return $.event('CloseMenu');
},
hideStub: function() { hideStub: function() {
var thread; var thread;
@ -3572,7 +3596,7 @@
return ThreadHiding.saveHiddenState(thread); return ThreadHiding.saveHiddenState(thread);
}, },
hide: function(thread, makeStub) { hide: function(thread, makeStub) {
var OP, a, numReplies, opInfo, span, threadRoot; var OP, a, button, numReplies, opInfo, span, threadRoot;
if (makeStub == null) { if (makeStub == null) {
makeStub = Conf['Stubs']; makeStub = Conf['Stubs'];
@ -3584,22 +3608,15 @@
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true; threadRoot.hidden = threadRoot.nextElementSibling.hidden = true;
return; return;
} }
numReplies = 0; numReplies = ((span = $('.summary', threadRoot)) ? +span.textContent.match(/\d+/) : 0) + $$('.opContainer ~ .replyContainer', threadRoot).length;
if (span = $('.summary', threadRoot)) { numReplies = numReplies === 1 ? '1 reply' : "" + (numReplies || 'No') + " replies";
numReplies = +span.textContent.match(/\d+/); opInfo = Conf['Anonymize'] ? 'Anonymous' : OP.info.name;
}
numReplies += $$('.opContainer ~ .replyContainer', threadRoot).length;
numReplies = numReplies === 1 ? '1 reply' : "" + numReplies + " replies";
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', {
className: 'stub' className: 'stub'
}); });
$.add(thread.stub, a); $.add(thread.stub, !Conf['Menu'] ? a : [a, $.tn(' '), button = Menu.makeButton(OP)]);
if (Conf['Menu']) {
$.add(thread.stub, [$.tn(' '), Menu.makeButton(OP)]);
}
return $.prepend(threadRoot, thread.stub); return $.prepend(threadRoot, thread.stub);
}, },
show: function(thread) { show: function(thread) {
@ -4208,7 +4225,9 @@
seek: function(type) { seek: function(type) {
var post, posts, result, str; var post, posts, result, str;
return unlses(Conf['Mark Quotes of You'] && Conf['Quick Reply']); if (!(Conf['Mark Quotes of You'] && Conf['Quick Reply'])) {
return;
}
$.rmClass($('.highlight'), 'highlight'); $.rmClass($('.highlight'), 'highlight');
if (!QuoteYou.lastRead) { if (!QuoteYou.lastRead) {
if (!(post = QuoteYou.lastRead = $('.quotesYou'))) { if (!(post = QuoteYou.lastRead = $('.quotesYou'))) {
@ -6974,45 +6993,48 @@
} }
}; };
Menu = { Menu = (function() {
init: function() { var a;
if (g.VIEW === 'catalog' || !Conf['Menu']) {
return;
}
this.menu = new UI.Menu('post');
return Post.prototype.callbacks.push({
name: 'Menu',
cb: this.node
});
},
node: function() {
var button;
if (this.isClone) { a = $.el('a', {
button = $('.menu-button', this.nodes.info); className: 'menu-button brackets-wrap',
} else { innerHTML: '<span class=drop-marker></span>',
button = Menu.makeButton(this); href: 'javascript:;'
$.add(this.nodes.info, [$.tn('\u00A0'), button]); });
} return {
return $.on(button, 'click', Menu.toggle); init: function() {
}, if (g.VIEW === 'catalog' || !Conf['Menu']) {
makeButton: (function() { return;
var a; }
this.menu = new UI.Menu('post');
return Post.prototype.callbacks.push({
name: 'Menu',
cb: this.node
});
},
node: function() {
var button;
a = null; if (this.isClone) {
return function() { button = $('.menu-button', this.nodes.info);
a || (a = $.el('a', { } else {
className: 'menu-button fourchanx-link', button = a.cloneNode(true);
innerHTML: '<i></i>', $.add(this.nodes.info, [$.tn('\u00A0'), button]);
href: 'javascript:;' }
})); return $.on(button, 'click', Menu.toggle);
return a.cloneNode(true); },
}; makeButton: function() {
})(), var el;
toggle: function(e) {
return Menu.menu.toggle(e, this, Get.postFromNode(this)); el = a.cloneNode(true);
} $.on(el, 'click', Menu.toggle);
}; return el;
},
toggle: function(e) {
return Menu.menu.toggle(e, this, Get.postFromNode(this));
}
};
})();
ReportLink = { ReportLink = {
init: function() { init: function() {

View File

@ -17,7 +17,7 @@ PostHiding =
PostHiding.hide @, data.makeStub, data.hideRecursively PostHiding.hide @, data.makeStub, data.hideRecursively
else else
Recursive.apply PostHiding.hide, @, data.makeStub, true Recursive.apply PostHiding.hide, @, data.makeStub, true
Recursive.add PostHiding.hide, @, data.makeStub, true Recursive.add PostHiding.hide, @, data.makeStub, true
return unless Conf['Reply Hiding Buttons'] return unless Conf['Reply Hiding Buttons']
$.replace $('.sideArrows', @nodes.root), PostHiding.makeButton @, 'hide' $.replace $('.sideArrows', @nodes.root), PostHiding.makeButton @, 'hide'
@ -108,11 +108,12 @@ PostHiding =
PostHiding.hide post, makeStub, replies PostHiding.hide post, makeStub, replies
else if replies else if replies
Recursive.apply PostHiding.hide, post, makeStub, true Recursive.apply PostHiding.hide, post, makeStub, true
Recursive.add PostHiding.hide, post, makeStub, true Recursive.add PostHiding.hide, post, makeStub, true
else else
return return
PostHiding.saveHiddenState post, true, thisPost, makeStub, replies PostHiding.saveHiddenState post, true, thisPost, makeStub, replies
$.event 'CloseMenu' $.event 'CloseMenu'
show: -> show: ->
parent = @parentNode parent = @parentNode
thisPost = $('input[name=thisPost]', parent).checked thisPost = $('input[name=thisPost]', parent).checked
@ -122,7 +123,7 @@ PostHiding =
PostHiding.show post, replies PostHiding.show post, replies
else if replies else if replies
Recursive.apply PostHiding.show, post, true Recursive.apply PostHiding.show, post, true
Recursive.rm PostHiding.hide, post, true Recursive.rm PostHiding.hide, post, true
else else
return return
if data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID} if data = PostHiding.db.get {boardID: post.board.ID, threadID: post.thread.ID, postID: post.ID}
@ -158,10 +159,7 @@ PostHiding =
toggle: -> toggle: ->
post = Get.postFromNode @ post = Get.postFromNode @
if post.isHidden PostHiding[(if post.isHidden then 'show' else 'hide')] post
PostHiding.show post
else
PostHiding.hide post
PostHiding.saveHiddenState post, post.isHidden PostHiding.saveHiddenState post, post.isHidden
hide: (post, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) -> hide: (post, makeStub=Conf['Stubs'], hideRecursively=Conf['Recursive Hiding']) ->
@ -170,7 +168,7 @@ PostHiding =
if hideRecursively if hideRecursively
Recursive.apply PostHiding.hide, post, makeStub, true Recursive.apply PostHiding.hide, post, makeStub, true
Recursive.add PostHiding.hide, post, makeStub, true Recursive.add PostHiding.hide, post, makeStub, true
for quotelink in Get.allQuotelinksLinkingTo post for quotelink in Get.allQuotelinksLinkingTo post
$.addClass quotelink, 'filtered' $.addClass quotelink, 'filtered'
@ -184,13 +182,14 @@ PostHiding =
if Conf['Anonymize'] if Conf['Anonymize']
'Anonymous' 'Anonymous'
else else
$('.nameBlock', post.nodes.info).textContent post.info.name
$.add a, $.tn " #{postInfo}" $.add a, $.tn " #{postInfo}"
post.nodes.stub = $.el 'div', post.nodes.stub = $.el 'div',
className: 'stub' className: 'stub'
$.add post.nodes.stub, a $.add post.nodes.stub, unless Conf['Menu']
if Conf['Menu'] a
$.add post.nodes.stub, [$.tn(' '), Menu.makeButton post] else
[a, $.tn(' '), button = Menu.makeButton post]
$.prepend post.nodes.root, post.nodes.stub $.prepend post.nodes.root, post.nodes.stub
show: (post, showRecursively=Conf['Recursive Hiding']) -> show: (post, showRecursively=Conf['Recursive Hiding']) ->
@ -202,7 +201,7 @@ PostHiding =
post.isHidden = false post.isHidden = false
if showRecursively if showRecursively
Recursive.apply PostHiding.show, post, true Recursive.apply PostHiding.show, post, true
Recursive.rm PostHiding.hide, post Recursive.rm PostHiding.hide, post
for quotelink in Get.allQuotelinksLinkingTo post for quotelink in Get.allQuotelinksLinkingTo post
$.rmClass quotelink, 'filtered' $.rmClass quotelink, 'filtered'
return return

View File

@ -71,11 +71,6 @@ ThreadHiding =
makeStub = $.el 'label', makeStub = $.el 'label',
innerHTML: "<input type=checkbox #{if Conf['Stubs'] then 'checked' else ''}> Make stub" innerHTML: "<input type=checkbox #{if Conf['Stubs'] then 'checked' else ''}> Make stub"
hideStubLink = $.el 'a',
textContent: 'Hide stub'
href: 'javascript:;'
$.on hideStubLink, 'click', ThreadHiding.menu.hideStub
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'post' type: 'post'
el: div el: div
@ -87,6 +82,27 @@ ThreadHiding =
true true
subEntries: [el: apply; el: makeStub] subEntries: [el: apply; el: makeStub]
div = $.el 'a',
className: 'show-thread-link'
textContent: 'Show thread'
href: 'javascript:;'
$.on show, 'click', ThreadHiding.menu.show
$.event 'AddMenuEntry',
type: 'post'
el: div
order: 20
open: ({thread, isReply}) ->
if isReply or !thread.isHidden
return false
ThreadHiding.menu.thread = thread
true
hideStubLink = $.el 'a',
textContent: 'Hide stub'
href: 'javascript:;'
$.on hideStubLink, 'click', ThreadHiding.menu.hideStub
$.event 'AddMenuEntry', $.event 'AddMenuEntry',
type: 'post' type: 'post'
el: hideStubLink el: hideStubLink
@ -102,6 +118,13 @@ ThreadHiding =
ThreadHiding.hide thread, makeStub ThreadHiding.hide thread, makeStub
ThreadHiding.saveHiddenState thread, makeStub ThreadHiding.saveHiddenState thread, makeStub
$.event 'CloseMenu' $.event 'CloseMenu'
show: ->
{thread} = ThreadHiding.menu
ThreadHiding.show thread
ThreadHiding.saveHiddenState thread
$.event 'CloseMenu'
hideStub: -> hideStub: ->
{thread} = ThreadHiding.menu {thread} = ThreadHiding.menu
ThreadHiding.hide thread, false ThreadHiding.hide thread, false
@ -150,24 +173,28 @@ ThreadHiding =
threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr> threadRoot.hidden = threadRoot.nextElementSibling.hidden = true # <hr>
return return
numReplies = 0 numReplies = (
if span = $ '.summary', threadRoot if span = $ '.summary', threadRoot
numReplies = +span.textContent.match /\d+/ +span.textContent.match /\d+/
numReplies += $$('.opContainer ~ .replyContainer', threadRoot).length else
numReplies = if numReplies is 1 then '1 reply' else "#{numReplies} replies" 0
) +
$$('.opContainer ~ .replyContainer', threadRoot).length
numReplies = if numReplies is 1 then '1 reply' else "#{numReplies or 'No'} replies"
opInfo = opInfo =
if Conf['Anonymize'] if Conf['Anonymize']
'Anonymous' 'Anonymous'
else else
$('.nameBlock', OP.nodes.info).textContent OP.info.name
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',
className: 'stub' className: 'stub'
$.add thread.stub, a $.add thread.stub, unless Conf['Menu']
if Conf['Menu'] a
$.add thread.stub, [$.tn(' '), Menu.makeButton OP] else
[a, $.tn(' '), button = Menu.makeButton OP]
$.prepend threadRoot, thread.stub $.prepend threadRoot, thread.stub
show: (thread) -> show: (thread) ->

View File

@ -18,7 +18,7 @@ Get =
post = g.posts["#{boardID}.#{postID}"] post = g.posts["#{boardID}.#{postID}"]
if index then post.clones[index] else post if index then post.clones[index] else post
postFromNode: (root) -> postFromNode: (root) ->
Get.postFromRoot $.x 'ancestor::div[contains(@class,"postContainer")][1]', root Get.postFromRoot $.x '(ancestor::div[contains(@class,"postContainer")]|following::div[contains(@class,"postContainer")])', root
contextFromNode: (quotelink) -> contextFromNode: (quotelink) ->
Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink Get.postFromRoot $.x 'ancestor::div[parent::div[@class="thread"]][1]', quotelink
postDataFromLink: (link) -> postDataFromLink: (link) ->

View File

@ -1,4 +1,9 @@
Menu = Menu = do ->
a = $.el 'a',
className: 'menu-button brackets-wrap'
innerHTML: '<span class=drop-marker></span>'
href: 'javascript:;'
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] return if g.VIEW is 'catalog' or !Conf['Menu']
@ -11,18 +16,14 @@ Menu =
if @isClone if @isClone
button = $ '.menu-button', @nodes.info button = $ '.menu-button', @nodes.info
else else
button = Menu.makeButton @ button = a.cloneNode true
$.add @nodes.info, [$.tn('\u00A0'), button] $.add @nodes.info, [$.tn('\u00A0'), button]
$.on button, 'click', Menu.toggle $.on button, 'click', Menu.toggle
makeButton: do -> makeButton: ->
a = null el = a.cloneNode true
-> $.on el, 'click', Menu.toggle
a or= $.el 'a', el
className: 'menu-button fourchanx-link'
innerHTML: '<i></i>'
href: 'javascript:;'
a.cloneNode true
toggle: (e) -> toggle: (e) ->
Menu.menu.toggle e, @, Get.postFromNode @ Menu.menu.toggle e, @, Get.postFromNode @

View File

@ -33,7 +33,7 @@ QuoteYou =
cb: cb:
seek: (type) -> seek: (type) ->
return unlses Conf['Mark Quotes of You'] and Conf['Quick Reply'] return unless Conf['Mark Quotes of You'] and Conf['Quick Reply']
$.rmClass $('.highlight'), 'highlight' $.rmClass $('.highlight'), 'highlight'
unless QuoteYou.lastRead unless QuoteYou.lastRead