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;
right: 1px;
}
.catalog-thread > a:not(:hover) .menu-button {
display: none;
}
.thread-icons > .menu-button > i {
font-size: 14px;
}
.thread-stats {
flex-shrink: 0;
cursor: help;

View File

@ -2,35 +2,46 @@ Menu =
init: ->
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'
Post.callbacks.push
name: 'Menu'
cb: @node
CatalogThread.callbacks.push
name: 'Image Hover'
cb: @catalogNode
node: ->
if @isClone
$.on $('.menu-button', @nodes.info), 'click', Menu.toggle
return
$.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 ->
frag = null
->
unless frag
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
makeButton: ->
clone = Menu.frag.cloneNode true
$.on clone.lastElementChild, 'click', Menu.toggle
clone
toggle: (e) ->
try
# Posts, inlined posts, hidden replies.
post = Get.postFromNode @
catch
# Hidden threads.
post = Get.threadFromNode(@).OP
post = if fullID = @parentNode.parentNode.parentNode.dataset.fullID
g.threads[fullID].OP
else
# Hidden threads.
Get.threadFromNode(@).OP
Menu.menu.toggle e, @, post