diff --git a/4chan_x.user.js b/4chan_x.user.js
index a78d7d6db..ea228dc50 100644
--- a/4chan_x.user.js
+++ b/4chan_x.user.js
@@ -947,7 +947,7 @@
}
},
cb: function() {
- return ThreadHiding.toggle(this.parentNode);
+ return ThreadHiding.toggle($.x('ancestor::div[parent::div[@class="board"]]', this));
},
toggle: function(thread) {
var hiddenThreads, id;
@@ -963,7 +963,7 @@
return $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
},
hide: function(thread, show_stub) {
- var a, num, opInfo, span, text;
+ var a, menuButton, num, opInfo, span, stub, text;
if (show_stub == null) {
show_stub = Conf['Show Stubs'];
}
@@ -982,19 +982,24 @@
num += $$('.opContainer ~ .replyContainer', thread).length;
text = num === 1 ? '1 reply' : "" + num + " replies";
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent;
- a = $.el('a', {
+ stub = $.el('div', {
className: 'hide_thread_button hidden_thread',
- innerHTML: '[ + ]',
- href: 'javascript:;'
+ innerHTML: '[ + ] '
});
- $.add(a, $.tn(" " + opInfo + " (" + text + ")"));
+ a = stub.firstChild;
$.on(a, 'click', ThreadHiding.cb);
- return $.prepend(thread, a);
+ $.add(a, $.tn("" + opInfo + " (" + text + ")"));
+ if (Conf['Menu']) {
+ menuButton = Menu.a.cloneNode(true);
+ $.on(menuButton, 'click', Menu.toggle);
+ $.add(stub, [$.tn(' '), menuButton]);
+ }
+ return $.prepend(thread, stub);
},
show: function(thread) {
- var a;
- if (a = $('.hidden_thread', thread)) {
- $.rm(a);
+ var stub;
+ if (stub = $('.hidden_thread', thread)) {
+ $.rm(stub);
}
thread.hidden = false;
return thread.nextElementSibling.hidden = false;
@@ -1042,7 +1047,7 @@
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
},
hide: function(root, show_stub) {
- var a, el, side, stub;
+ var a, el, menuButton, side, stub;
if (show_stub == null) {
show_stub = Conf['Show Stubs'];
}
@@ -1061,8 +1066,13 @@
innerHTML: '[ + ] '
});
a = stub.firstChild;
- $.add(a, $.tn($('.nameBlock', el).textContent));
$.on(a, 'click', ReplyHiding.toggle);
+ $.add(a, $.tn($('.nameBlock', el).textContent));
+ if (Conf['Menu']) {
+ menuButton = Menu.a.cloneNode(true);
+ $.on(menuButton, 'click', Menu.toggle);
+ $.add(stub, [$.tn(' '), menuButton]);
+ }
return $.prepend(root, stub);
},
show: function(root) {
@@ -1103,7 +1113,7 @@
return $.on(a, 'click', Menu.toggle);
},
toggle: function(e) {
- var lastOpener;
+ var lastOpener, post;
e.preventDefault();
e.stopPropagation();
if (Menu.el.parentNode) {
@@ -1114,7 +1124,9 @@
}
}
Menu.lastOpener = this;
- return Menu.open(this, Main.preParse($.x('ancestor::div[contains(@class,"postContainer")][1]', this)));
+ post = /\bhidden_thread\b/.test(this.parentNode.className) ? $.x('ancestor::div[parent::div[@class="board"]]/child::div[contains(@class,"opContainer")]', this) : $.x('ancestor::div[contains(@class,"postContainer")][1]', this);
+ $.log(postContainer);
+ return Menu.open(this, Main.preParse(post));
},
open: function(button, post) {
var bLeft, bRect, bTop, el, entry, mRect, _i, _len, _ref;
diff --git a/script.coffee b/script.coffee
index 61078555e..6bb23c206 100644
--- a/script.coffee
+++ b/script.coffee
@@ -719,7 +719,7 @@ ThreadHiding =
return
cb: ->
- ThreadHiding.toggle @parentNode
+ ThreadHiding.toggle $.x 'ancestor::div[parent::div[@class="board"]]', @
toggle: (thread) ->
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
@@ -747,17 +747,21 @@ ThreadHiding =
text = if num is 1 then '1 reply' else "#{num} replies"
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent
- a = $.el 'a',
+ stub = $.el 'div',
className: 'hide_thread_button hidden_thread'
- innerHTML: '[ + ]'
- href: 'javascript:;'
- $.add a, $.tn " #{opInfo} (#{text})"
- $.on a, 'click', ThreadHiding.cb
- $.prepend thread, a
+ innerHTML: '[ + ] '
+ a = stub.firstChild
+ $.on a, 'click', ThreadHiding.cb
+ $.add a, $.tn "#{opInfo} (#{text})"
+ if Conf['Menu']
+ menuButton = Menu.a.cloneNode true
+ $.on menuButton, 'click', Menu.toggle
+ $.add stub, [$.tn(' '), menuButton]
+ $.prepend thread, stub
show: (thread) ->
- if a = $ '.hidden_thread', thread
- $.rm a
+ if stub = $ '.hidden_thread', thread
+ $.rm stub
thread.hidden = false
thread.nextElementSibling.hidden = false
@@ -805,8 +809,12 @@ ReplyHiding =
className: 'hide_reply_button stub'
innerHTML: '[ + ] '
a = stub.firstChild
- $.add a, $.tn $('.nameBlock', el).textContent
$.on a, 'click', ReplyHiding.toggle
+ $.add a, $.tn $('.nameBlock', el).textContent
+ if Conf['Menu']
+ menuButton = Menu.a.cloneNode true
+ $.on menuButton, 'click', Menu.toggle
+ $.add stub, [$.tn(' '), menuButton]
$.prepend root, stub
show: (root) ->
@@ -848,7 +856,13 @@ Menu =
return if lastOpener is @
Menu.lastOpener = @
- Menu.open @, Main.preParse $.x 'ancestor::div[contains(@class,"postContainer")][1]', @
+ post =
+ if /\bhidden_thread\b/.test @parentNode.className
+ $.x 'ancestor::div[parent::div[@class="board"]]/child::div[contains(@class,"opContainer")]', @
+ else
+ $.x 'ancestor::div[contains(@class,"postContainer")][1]', @
+ $.log postContainer
+ Menu.open @, Main.preParse post
open: (button, post) ->
{el} = Menu
# XXX GM/Scriptish require setAttribute