Add the menu button to threads in the catalog.

This commit is contained in:
Mayhem 2014-02-02 23:30:04 +01:00
parent 99f4f14c47
commit 60e89e3f28
2 changed files with 31 additions and 14 deletions

View File

@ -444,6 +444,12 @@ a[href="javascript:;"] {
top: 1px; top: 1px;
right: 1px; right: 1px;
} }
.catalog-thread > a:not(:hover) .menu-button {
display: none;
}
.thread-icons > .menu-button > i {
font-size: 14px;
}
.thread-stats { .thread-stats {
flex-shrink: 0; flex-shrink: 0;
cursor: help; cursor: help;

View File

@ -2,35 +2,46 @@ Menu =
init: -> init: ->
return if g.VIEW is 'catalog' or !Conf['Menu'] return if g.VIEW is 'catalog' or !Conf['Menu']
a = $.el 'a',
className: 'menu-button'
innerHTML: '[<i></i>]'
href: 'javascript:;'
@frag = $.nodes [$.tn(' '), a]
@menu = new UI.Menu 'post' @menu = new UI.Menu 'post'
Post.callbacks.push Post.callbacks.push
name: 'Menu' name: 'Menu'
cb: @node cb: @node
CatalogThread.callbacks.push
name: 'Image Hover'
cb: @catalogNode
node: -> node: ->
if @isClone if @isClone
$.on $('.menu-button', @nodes.info), 'click', Menu.toggle $.on $('.menu-button', @nodes.info), 'click', Menu.toggle
return return
$.add @nodes.info, Menu.makeButton() $.add @nodes.info, Menu.makeButton()
catalogNode: ->
menuButton = $.el 'a',
className: 'menu-button'
innerHTML: '<i class="fa fa-bars"></i>'
href: 'javascript:;'
$.on menuButton, 'click', Menu.toggle
$.add @nodes.icons, menuButton
makeButton: do -> makeButton: ->
frag = null clone = Menu.frag.cloneNode true
-> $.on clone.lastElementChild, 'click', Menu.toggle
unless frag clone
a = $.el 'a',
className: 'menu-button'
innerHTML: '[<i></i>]'
href: 'javascript:;'
frag = $.nodes [$.tn(' '), a]
clone = frag.cloneNode true
$.on clone.lastElementChild, 'click', Menu.toggle
clone
toggle: (e) -> toggle: (e) ->
try try
# Posts, inlined posts, hidden replies. # Posts, inlined posts, hidden replies.
post = Get.postFromNode @ post = Get.postFromNode @
catch catch
# Hidden threads. post = if fullID = @parentNode.parentNode.parentNode.dataset.fullID
post = Get.threadFromNode(@).OP g.threads[fullID].OP
else
# Hidden threads.
Get.threadFromNode(@).OP
Menu.menu.toggle e, @, post Menu.menu.toggle e, @, post