From ac90db47aa2671cd663cc6a9cdf783dc30a582e9 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 10 Jan 2015 00:00:11 +0000 Subject: Modes; more changes... - Better comments. - Strip unnecessary handlers for leaving post-find mode. - Simplify passKeys. - focusInput now re-bubbles its triggering keydown event. --- content_scripts/mode_find.coffee | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'content_scripts/mode_find.coffee') diff --git a/content_scripts/mode_find.coffee b/content_scripts/mode_find.coffee index 3b9f951e..d63b3319 100644 --- a/content_scripts/mode_find.coffee +++ b/content_scripts/mode_find.coffee @@ -2,11 +2,11 @@ # When we use find mode, the selection/focus can end up in a focusable/editable element. In this situation, # special considerations apply. We implement three special cases: -# 1. Be an InsertModeBlocker. This prevents keyboard events from dropping us unintentionally into insert -# mode. This is achieved by inheriting from InsertModeBlocker. +# 1. Prevent keyboard events from dropping us unintentionally into insert mode. This is achieved by +# inheriting from InsertModeBlocker. # 2. Prevent all keyboard events on the active element from propagating. This is achieved by setting the # trapAllKeyboardEvents option. There's some controversy as to whether this is the right thing to do. -# See discussion in #1415. This implements option 2 from there, although option 3 would be a reasonable +# See discussion in #1415. This implements Option 2 from there, although Option 3 would be a reasonable # alternative. # 3. If the very-next keystroke is Escape, then drop immediately into insert mode. # @@ -16,9 +16,10 @@ class PostFindMode extends InsertModeBlocker super name: "post-find" - # Be a singleton. That way, we don't have to keep track of any currently-active instance. Such an - # instance is automatically deactivated when a new instance is created. + # Be a singleton. That way, we don't have to keep track of any currently-active instance. Any active + # instance is automatically deactivated when a new instance is activated. singleton: PostFindMode + exitOnBlur: element trapAllKeyboardEvents: element return @exit() unless element and findModeAnchorNode @@ -42,11 +43,5 @@ class PostFindMode extends InsertModeBlocker @remove() true - # Various ways in which we can leave PostFindMode. - @push - focus: (event) => @alwaysContinueBubbling => @exit() - blur: (event) => @alwaysContinueBubbling => @exit() - keydown: (event) => @alwaysContinueBubbling => @exit() if document.activeElement != element - root = exports ? window root.PostFindMode = PostFindMode -- cgit v1.2.3