Add a menu button next to stubs. Close #502.
This commit is contained in:
parent
5430a1198b
commit
469b60a4c5
@ -947,7 +947,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
cb: function() {
|
cb: function() {
|
||||||
return ThreadHiding.toggle(this.parentNode);
|
return ThreadHiding.toggle($.x('ancestor::div[parent::div[@class="board"]]', this));
|
||||||
},
|
},
|
||||||
toggle: function(thread) {
|
toggle: function(thread) {
|
||||||
var hiddenThreads, id;
|
var hiddenThreads, id;
|
||||||
@ -963,7 +963,7 @@
|
|||||||
return $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
|
return $.set("hiddenThreads/" + g.BOARD + "/", hiddenThreads);
|
||||||
},
|
},
|
||||||
hide: function(thread, show_stub) {
|
hide: function(thread, show_stub) {
|
||||||
var a, num, opInfo, span, text;
|
var a, menuButton, num, opInfo, span, stub, text;
|
||||||
if (show_stub == null) {
|
if (show_stub == null) {
|
||||||
show_stub = Conf['Show Stubs'];
|
show_stub = Conf['Show Stubs'];
|
||||||
}
|
}
|
||||||
@ -982,19 +982,24 @@
|
|||||||
num += $$('.opContainer ~ .replyContainer', thread).length;
|
num += $$('.opContainer ~ .replyContainer', thread).length;
|
||||||
text = num === 1 ? '1 reply' : "" + num + " replies";
|
text = num === 1 ? '1 reply' : "" + num + " replies";
|
||||||
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent;
|
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent;
|
||||||
a = $.el('a', {
|
stub = $.el('div', {
|
||||||
className: 'hide_thread_button hidden_thread',
|
className: 'hide_thread_button hidden_thread',
|
||||||
innerHTML: '<span>[ + ]</span>',
|
innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
|
||||||
href: 'javascript:;'
|
|
||||||
});
|
});
|
||||||
$.add(a, $.tn(" " + opInfo + " (" + text + ")"));
|
a = stub.firstChild;
|
||||||
$.on(a, 'click', ThreadHiding.cb);
|
$.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) {
|
show: function(thread) {
|
||||||
var a;
|
var stub;
|
||||||
if (a = $('.hidden_thread', thread)) {
|
if (stub = $('.hidden_thread', thread)) {
|
||||||
$.rm(a);
|
$.rm(stub);
|
||||||
}
|
}
|
||||||
thread.hidden = false;
|
thread.hidden = false;
|
||||||
return thread.nextElementSibling.hidden = false;
|
return thread.nextElementSibling.hidden = false;
|
||||||
@ -1042,7 +1047,7 @@
|
|||||||
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
|
return $.set("hiddenReplies/" + g.BOARD + "/", g.hiddenReplies);
|
||||||
},
|
},
|
||||||
hide: function(root, show_stub) {
|
hide: function(root, show_stub) {
|
||||||
var a, el, side, stub;
|
var a, el, menuButton, side, stub;
|
||||||
if (show_stub == null) {
|
if (show_stub == null) {
|
||||||
show_stub = Conf['Show Stubs'];
|
show_stub = Conf['Show Stubs'];
|
||||||
}
|
}
|
||||||
@ -1061,8 +1066,13 @@
|
|||||||
innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
|
innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
|
||||||
});
|
});
|
||||||
a = stub.firstChild;
|
a = stub.firstChild;
|
||||||
$.add(a, $.tn($('.nameBlock', el).textContent));
|
|
||||||
$.on(a, 'click', ReplyHiding.toggle);
|
$.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);
|
return $.prepend(root, stub);
|
||||||
},
|
},
|
||||||
show: function(root) {
|
show: function(root) {
|
||||||
@ -1103,7 +1113,7 @@
|
|||||||
return $.on(a, 'click', Menu.toggle);
|
return $.on(a, 'click', Menu.toggle);
|
||||||
},
|
},
|
||||||
toggle: function(e) {
|
toggle: function(e) {
|
||||||
var lastOpener;
|
var lastOpener, post;
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
if (Menu.el.parentNode) {
|
if (Menu.el.parentNode) {
|
||||||
@ -1114,7 +1124,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Menu.lastOpener = this;
|
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) {
|
open: function(button, post) {
|
||||||
var bLeft, bRect, bTop, el, entry, mRect, _i, _len, _ref;
|
var bLeft, bRect, bTop, el, entry, mRect, _i, _len, _ref;
|
||||||
|
|||||||
@ -719,7 +719,7 @@ ThreadHiding =
|
|||||||
return
|
return
|
||||||
|
|
||||||
cb: ->
|
cb: ->
|
||||||
ThreadHiding.toggle @parentNode
|
ThreadHiding.toggle $.x 'ancestor::div[parent::div[@class="board"]]', @
|
||||||
|
|
||||||
toggle: (thread) ->
|
toggle: (thread) ->
|
||||||
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
hiddenThreads = $.get "hiddenThreads/#{g.BOARD}/", {}
|
||||||
@ -747,17 +747,21 @@ ThreadHiding =
|
|||||||
text = if num is 1 then '1 reply' else "#{num} replies"
|
text = if num is 1 then '1 reply' else "#{num} replies"
|
||||||
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent
|
opInfo = $('.op > .postInfo > .nameBlock', thread).textContent
|
||||||
|
|
||||||
a = $.el 'a',
|
stub = $.el 'div',
|
||||||
className: 'hide_thread_button hidden_thread'
|
className: 'hide_thread_button hidden_thread'
|
||||||
innerHTML: '<span>[ + ]</span>'
|
innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
|
||||||
href: 'javascript:;'
|
a = stub.firstChild
|
||||||
$.add a, $.tn " #{opInfo} (#{text})"
|
$.on a, 'click', ThreadHiding.cb
|
||||||
$.on a, 'click', ThreadHiding.cb
|
$.add a, $.tn "#{opInfo} (#{text})"
|
||||||
$.prepend thread, a
|
if Conf['Menu']
|
||||||
|
menuButton = Menu.a.cloneNode true
|
||||||
|
$.on menuButton, 'click', Menu.toggle
|
||||||
|
$.add stub, [$.tn(' '), menuButton]
|
||||||
|
$.prepend thread, stub
|
||||||
|
|
||||||
show: (thread) ->
|
show: (thread) ->
|
||||||
if a = $ '.hidden_thread', thread
|
if stub = $ '.hidden_thread', thread
|
||||||
$.rm a
|
$.rm stub
|
||||||
thread.hidden = false
|
thread.hidden = false
|
||||||
thread.nextElementSibling.hidden = false
|
thread.nextElementSibling.hidden = false
|
||||||
|
|
||||||
@ -805,8 +809,12 @@ ReplyHiding =
|
|||||||
className: 'hide_reply_button stub'
|
className: 'hide_reply_button stub'
|
||||||
innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
|
innerHTML: '<a href="javascript:;"><span>[ + ]</span> </a>'
|
||||||
a = stub.firstChild
|
a = stub.firstChild
|
||||||
$.add a, $.tn $('.nameBlock', el).textContent
|
|
||||||
$.on a, 'click', ReplyHiding.toggle
|
$.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
|
$.prepend root, stub
|
||||||
|
|
||||||
show: (root) ->
|
show: (root) ->
|
||||||
@ -848,7 +856,13 @@ Menu =
|
|||||||
return if lastOpener is @
|
return if lastOpener is @
|
||||||
|
|
||||||
Menu.lastOpener = @
|
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) ->
|
open: (button, post) ->
|
||||||
{el} = Menu
|
{el} = Menu
|
||||||
# XXX GM/Scriptish require setAttribute
|
# XXX GM/Scriptish require setAttribute
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user