From 8d07da98663d2ed5f1243ed6a72314f01cf1d8d6 Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Sun, 5 May 2013 15:05:10 -0700 Subject: [PATCH] Fix #155 --- LICENSE | 2 +- builds/4chan-X.js | 9 +++++++-- builds/4chan-X.user.js | 9 +++++++-- builds/crx/script.js | 9 +++++++-- src/General/UI.coffee | 12 ++++++++++-- 5 files changed, 32 insertions(+), 9 deletions(-) diff --git a/LICENSE b/LICENSE index 9a14057f0..6df17d667 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.1.9 - 2013-05-03 +* 4chan X - Version 1.1.9 - 2013-05-05 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE diff --git a/builds/4chan-X.js b/builds/4chan-X.js index 4c38bce6c..c300168a8 100644 --- a/builds/4chan-X.js +++ b/builds/4chan-X.js @@ -18,7 +18,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.1.9 - 2013-05-03 +* 4chan X - Version 1.1.9 - 2013-05-05 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -2541,6 +2541,7 @@ } }); $.on(root, endEvents, o.hoverend); + $.on(d, 'keydown', o.hoverend); return $.on(root, 'mousemove', o.hover); }; hover = function(e) { @@ -2557,9 +2558,13 @@ style.left = left; return style.right = right; }; - hoverend = function() { + hoverend = function(e) { + if (e.type === 'keydown' && e.keyCode !== 13) { + return; + } $.rm(this.el); $.off(this.root, this.endEvents, this.hoverend); + $.off(d, 'keydown', this.hoverend); $.off(this.root, 'mousemove', this.hover); if (this.cb) { return this.cb.call(this); diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index c3c2726dc..72f53f5ea 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -18,7 +18,7 @@ // @icon data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwAgMAAAAqbBEUAAAACVBMVEUAAGcAAABmzDNZt9VtAAAAAXRSTlMAQObYZgAAAHFJREFUKFOt0LENACEIBdBv4Qju4wgWanEj3D6OcIVMKaitYHEU/jwTCQj8W75kiVCSBvdQ5/AvfVHBin11BgdRq3ysBgfwBDRrj3MCIA+oAQaku/Q1cNctrAmyDl577tOThYt/Y1RBM4DgOHzM0HFTAyLukH/cmRnqAAAAAElFTkSuQmCC // ==/UserScript== /* -* 4chan X - Version 1.1.9 - 2013-05-03 +* 4chan X - Version 1.1.9 - 2013-05-05 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -2537,6 +2537,7 @@ } }); $.on(root, endEvents, o.hoverend); + $.on(d, 'keydown', o.hoverend); return $.on(root, 'mousemove', o.hover); }; hover = function(e) { @@ -2553,9 +2554,13 @@ style.left = left; return style.right = right; }; - hoverend = function() { + hoverend = function(e) { + if (e.type === 'keydown' && e.keyCode !== 13) { + return; + } $.rm(this.el); $.off(this.root, this.endEvents, this.hoverend); + $.off(d, 'keydown', this.hoverend); $.off(this.root, 'mousemove', this.hover); if (this.cb) { return this.cb.call(this); diff --git a/builds/crx/script.js b/builds/crx/script.js index d305ee0d7..d05512dbb 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -1,5 +1,5 @@ /* -* 4chan X - Version 1.1.9 - 2013-05-03 +* 4chan X - Version 1.1.9 - 2013-05-05 * * Licensed under the MIT license. * https://github.com/seaweedchan/4chan-x/blob/master/LICENSE @@ -2539,6 +2539,7 @@ } }); $.on(root, endEvents, o.hoverend); + $.on(d, 'keydown', o.hoverend); return $.on(root, 'mousemove', o.hover); }; hover = function(e) { @@ -2555,9 +2556,13 @@ style.left = left; return style.right = right; }; - hoverend = function() { + hoverend = function(e) { + if (e.type === 'keydown' && e.keyCode !== 13) { + return; + } $.rm(this.el); $.off(this.root, this.endEvents, this.hoverend); + $.off(d, 'keydown', this.hoverend); $.off(this.root, 'mousemove', this.hover); if (this.cb) { return this.cb.call(this); diff --git a/src/General/UI.coffee b/src/General/UI.coffee index c97791439..aab109ead 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -203,7 +203,6 @@ UI = do -> @parseEntry subEntry return - dragstart = (e) -> return if e.type is 'mousedown' and e.button isnt 0 # not LMB # prevent text selection @@ -245,11 +244,13 @@ UI = do -> o.up = dragend.bind o $.on d, 'mousemove', o.move $.on d, 'mouseup', o.up + touchmove = (e) -> for touch in e.changedTouches if touch.identifier is @identifier drag.call @, touch return + drag = (e) -> {clientX, clientY} = e @@ -284,11 +285,13 @@ UI = do -> style.right = right style.top = top style.bottom = bottom + touchend = (e) -> for touch in e.changedTouches if touch.identifier is @identifier dragend.call @ return + dragend = -> if @isTouching $.off d, 'touchmove', @move @@ -318,7 +321,9 @@ UI = do -> o.hover o.latestEvent if el.parentNode $.on root, endEvents, o.hoverend + $.on d, 'keydown', o.hoverend $.on root, 'mousemove', o.hover + hover = (e) -> @latestEvent = e height = @el.offsetHeight @@ -341,9 +346,12 @@ UI = do -> style.top = top + 'px' style.left = left style.right = right - hoverend = -> + + hoverend = (e) -> + return if e.type is 'keydown' and e.keyCode isnt 13 $.rm @el $.off @root, @endEvents, @hoverend + $.off d, 'keydown', @hoverend $.off @root, 'mousemove', @hover @cb.call @ if @cb