diff --git a/4chan_x.user.js b/4chan_x.user.js index 423f22987..0e27011d4 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -255,9 +255,6 @@ } }, hoverend: function() { - if (!UI.el) { - return; - } $.rm(UI.el); return delete UI.el; } @@ -3230,7 +3227,15 @@ if (/\binlined\b/.test(this.className)) { return; } - UI.hoverend(); + if (qp = $.id('qp')) { + if (qp === UI.el) { + delete UI.el; + } + $.rm(qp); + } + if (UI.el) { + return; + } qp = UI.el = $.el('div', { id: 'qp', className: 'post reply dialog' @@ -3675,19 +3680,28 @@ return $.on(post.img, 'mouseover', ImageHover.mouseover); }, mouseover: function() { - UI.hoverend(); - UI.el = $.el('img', { + var el; + if (el = $.id('ihover')) { + if (el === UI.el) { + delete UI.el; + } + $.rm(el); + } + if (UI.el) { + return; + } + el = UI.el = $.el('img', { id: 'ihover', src: this.parentNode.href }); - $.add(d.body, UI.el); - $.on(UI.el, 'load', ImageHover.load); + $.add(d.body, el); + $.on(el, 'load', ImageHover.load); $.on(this, 'mousemove', UI.hover); return $.on(this, 'mouseout', ImageHover.mouseout); }, load: function() { var style; - if (this !== UI.el) { + if (!this.parentNode) { return; } style = this.style; diff --git a/script.coffee b/script.coffee index 905762b04..2eabb7678 100644 --- a/script.coffee +++ b/script.coffee @@ -225,9 +225,7 @@ UI = else style.left = null style.right = clientWidth - clientX + 45 + 'px' - hoverend: -> - return unless UI.el $.rm UI.el delete UI.el @@ -2445,8 +2443,15 @@ QuotePreview = mouseover: (e) -> return if /\binlined\b/.test @className - # Make sure to remove the previous UI.el - UI.hoverend() + # Make sure to remove the previous qp + # in case it got stuck. Opera-only bug? + if qp = $.id 'qp' + if qp is UI.el + delete UI.el + $.rm qp + + # Don't stop other elements from dragging + return if UI.el qp = UI.el = $.el 'div', id: 'qp' @@ -2482,7 +2487,7 @@ QuotePreview = $.removeClass el.parentNode, 'qphl' else $.removeClass el, 'qphl' - $.off @, 'mousemove', UI.hover + $.off @, 'mousemove', UI.hover $.off @, 'mouseout click', QuotePreview.mouseout parse: (req, id) -> return unless (qp = UI.el) and qp.textContent is "Loading #{id}..." @@ -2789,18 +2794,25 @@ ImageHover = return unless post.img $.on post.img, 'mouseover', ImageHover.mouseover mouseover: -> - # Make sure to remove the previous UI.el - UI.hoverend() + # Make sure to remove the previous image hover + # in case it got stuck. Opera-only bug? + if el = $.id 'ihover' + if el is UI.el + delete UI.el + $.rm el - UI.el = $.el 'img' + # Don't stop other elements from dragging + return if UI.el + + el = UI.el = $.el 'img' id: 'ihover' src: @parentNode.href - $.add d.body, UI.el - $.on UI.el, 'load', ImageHover.load - $.on @, 'mousemove', UI.hover - $.on @, 'mouseout', ImageHover.mouseout + $.add d.body, el + $.on el, 'load', ImageHover.load + $.on @, 'mousemove', UI.hover + $.on @, 'mouseout', ImageHover.mouseout load: -> - return if @ isnt UI.el + return unless @parentNode # 'Fake' mousemove event by giving required values. {style} = @ UI.hover