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,27 +2,35 @@ 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: ->
makeButton: do -> menuButton = $.el 'a',
frag = null
->
unless frag
a = $.el 'a',
className: 'menu-button' className: 'menu-button'
innerHTML: '[<i></i>]' innerHTML: '<i class="fa fa-bars"></i>'
href: 'javascript:;' href: 'javascript:;'
frag = $.nodes [$.tn(' '), a] $.on menuButton, 'click', Menu.toggle
clone = frag.cloneNode true $.add @nodes.icons, menuButton
makeButton: ->
clone = Menu.frag.cloneNode true
$.on clone.lastElementChild, 'click', Menu.toggle $.on clone.lastElementChild, 'click', Menu.toggle
clone clone
@ -31,6 +39,9 @@ Menu =
# Posts, inlined posts, hidden replies. # Posts, inlined posts, hidden replies.
post = Get.postFromNode @ post = Get.postFromNode @
catch catch
post = if fullID = @parentNode.parentNode.parentNode.dataset.fullID
g.threads[fullID].OP
else
# Hidden threads. # Hidden threads.
post = Get.threadFromNode(@).OP Get.threadFromNode(@).OP
Menu.menu.toggle e, @, post Menu.menu.toggle e, @, post