aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2016-03-04 06:44:36 +0000
committerStephen Blott2016-03-04 06:44:36 +0000
commitde6c623b65f072650e70c8c5acf8c9d809bc64f5 (patch)
tree278ee481f4480eb560eb8b60aa4c424ad7dd5b5e
parent7dfcd123191ff9b7deb9059e1d454d425254125c (diff)
downloadvimium-de6c623b65f072650e70c8c5acf8c9d809bc64f5.tar.bz2
Refactor hints; no need to guard against no rect.
- The check for whether a rect is defined is only used in one of the three cases. So we don't need it. - Also, better veriable name.
-rw-r--r--content_scripts/link_hints.coffee18
1 files changed, 8 insertions, 10 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee
index cfacb862..57fec611 100644
--- a/content_scripts/link_hints.coffee
+++ b/content_scripts/link_hints.coffee
@@ -393,7 +393,7 @@ class LinkHintsMode
else if userMightOverType
# Block keyboard events while the user is still typing. The intention is to prevent the user from
# inadvertently launching Vimium commands when (over-)typing the link text.
- new TypingProtector 200, linkMatched?.rect, linkActivator
+ new TypingProtector 200, linkMatched.rect, linkActivator
else
DomUtils.flashRect linkMatched.rect
linkActivator()
@@ -633,24 +633,22 @@ class TypingProtector extends Mode
constructor: (delay, rect, callback) ->
@timer = Utils.setTimeout delay, => @exit()
- handler = (event) =>
+ resetExitTimer = (event) =>
clearTimeout @timer
@timer = Utils.setTimeout delay, => @exit()
super
name: "hint/typing-protector"
suppressAllKeyboardEvents: true
- keydown: handler
- keypress: handler
-
- if rect
- # We keep a "flash" overlay active while the user is typing; this provides visual feeback that something
- # has been selected.
- flashEl = DomUtils.addFlashRect rect
- @onExit -> DomUtils.removeElement flashEl
+ keydown: resetExitTimer
+ keypress: resetExitTimer
@onExit callback
+ # We keep a "flash" overlay active while the user is typing; this provides visual feeback that something
+ # has been selected.
+ flashEl = DomUtils.addFlashRect rect
+ @onExit -> DomUtils.removeElement flashEl
class WaitForEnter extends Mode
constructor: (rect, callback) ->