From 5833ad4fdaf91bb9e2606a771f0776356a8ebef1 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 8 Apr 2013 11:26:58 -0700 Subject: [PATCH] Handle hovering a bit differently. --- 4chan-X.user.js | 12 +++++++++--- lib/ui.coffee | 1 - src/features.coffee | 12 ++++++++++-- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/4chan-X.user.js b/4chan-X.user.js index 472e33a7f..ba6957b98 100644 --- a/4chan-X.user.js +++ b/4chan-X.user.js @@ -1096,7 +1096,10 @@ this.shortcuts = $.el('span', { id: 'shortcuts' }); - return $.asap((function() { + this.hover = $.el('div', { + id: 'hoverUI' + }); + $.asap((function() { return d.body; }), function() { if (!Main.isThisPageLegit()) { @@ -1106,6 +1109,9 @@ return $.id('boardNavMobile'); }), Header.setBoardList); }); + return $.ready(function() { + return $.add(d.body, Header.hover); + }); }, setBoardList: function() { var a, btn, customBoardList, fullBoardList, nav; @@ -4298,7 +4304,7 @@ id: 'qp', className: 'dialog' }); - $.add(d.body, qp); + $.add(Header.hover, qp); Get.postClone(boardID, threadID, postID, qp, Get.contextFromLink(this)); UI.hover({ root: this, @@ -5298,7 +5304,7 @@ src: post.file.URL }); el.setAttribute('data-fullid', post.fullID); - $.add(d.body, el); + $.add(Header.hover, el); UI.hover({ root: this, el: el, diff --git a/lib/ui.coffee b/lib/ui.coffee index 14b8fe025..d8638f613 100644 --- a/lib/ui.coffee +++ b/lib/ui.coffee @@ -9,7 +9,6 @@ UI = do -> $.on move, 'touchstart mousedown', dragstart el - class Menu currentMenu = null lastToggledButton = null diff --git a/src/features.coffee b/src/features.coffee index 93751f73d..ba7346e87 100644 --- a/src/features.coffee +++ b/src/features.coffee @@ -4,12 +4,17 @@ Header = id: 'notifications' @shortcuts = $.el 'span', id: 'shortcuts' + @hover = $.el 'div', + id: 'hoverUI' $.asap (-> d.body), -> return unless Main.isThisPageLegit() # Wait for #boardNavMobile instead of #boardNavDesktop, # it might be incomplete otherwise. $.asap (-> $.id 'boardNavMobile'), Header.setBoardList + $.ready -> + $.add d.body, Header.hover + setBoardList: -> Header.nav = nav = $.id 'boardNavDesktop' @@ -2679,10 +2684,12 @@ QuotePreview = Post::callbacks.push name: 'Quote Previewing' cb: @node + node: -> for link in @nodes.quotelinks.concat [@nodes.backlinks...] $.on link, 'mouseover', QuotePreview.mouseover return + mouseover: (e) -> return if $.hasClass @, 'inlined' @@ -2691,7 +2698,7 @@ QuotePreview = qp = $.el 'div', id: 'qp' className: 'dialog' - $.add d.body, qp + $.add Header.hover, qp Get.postClone boardID, threadID, postID, qp, Get.contextFromLink @ UI.hover @@ -2717,6 +2724,7 @@ QuotePreview = if quote.hash[2..] is quoterID $.addClass quote, 'forwardlink' return + mouseout: -> # Stop if it only contains text. return unless root = @el.firstElementChild @@ -3417,7 +3425,7 @@ ImageHover = id: 'ihover' src: post.file.URL el.setAttribute 'data-fullid', post.fullID - $.add d.body, el + $.add Header.hover, el UI.hover root: @ el: el