From 60e89e3f28dcb5cb5936f31940c786117ba5240a Mon Sep 17 00:00:00 2001 From: Mayhem Date: Sun, 2 Feb 2014 23:30:04 +0100 Subject: [PATCH] Add the menu button to threads in the catalog. --- css/style.css | 6 ++++++ src/Menu/Menu.coffee | 39 +++++++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/css/style.css b/css/style.css index 30b78cf0c..4b705b943 100644 --- a/css/style.css +++ b/css/style.css @@ -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; diff --git a/src/Menu/Menu.coffee b/src/Menu/Menu.coffee index 23fb2ce91..c5ba70c31 100644 --- a/src/Menu/Menu.coffee +++ b/src/Menu/Menu.coffee @@ -2,35 +2,46 @@ Menu = init: -> return if g.VIEW is 'catalog' or !Conf['Menu'] + a = $.el 'a', + className: 'menu-button' + innerHTML: '[]' + 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: '' + href: 'javascript:;' + $.on menuButton, 'click', Menu.toggle + $.add @nodes.icons, menuButton - makeButton: do -> - frag = null - -> - unless frag - a = $.el 'a', - className: 'menu-button' - innerHTML: '[]' - 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