aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/mode.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-01-06 12:04:19 +0000
committerStephen Blott2015-01-06 12:04:19 +0000
commitf19f21f7114c6cdc2c62b69e0f6dafac68fd84a0 (patch)
tree79cb394c5bd3482b88d136aa615d5e3cdfd46373 /content_scripts/mode.coffee
parentb0f56ca439af45b62b23efd8c19c3838945f21f4 (diff)
downloadvimium-f19f21f7114c6cdc2c62b69e0f6dafac68fd84a0.tar.bz2
Mode; simplify InsertModeBlocker logic.
Diffstat (limited to 'content_scripts/mode.coffee')
-rw-r--r--content_scripts/mode.coffee11
1 files changed, 5 insertions, 6 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee
index b81a4ede..df833c51 100644
--- a/content_scripts/mode.coffee
+++ b/content_scripts/mode.coffee
@@ -153,16 +153,15 @@ class ExitOnEscapeMode extends SingletonMode
event: event
@suppressEvent
-# This mode exits when @constrainingElement (if defined) loses the focus.
+# This mode exits when element (if defined) loses the focus.
class ConstrainedMode extends ExitOnEscapeMode
- constructor: (@constrainingElement, singleton, options) ->
+ constructor: (element, singleton=null, options={}) ->
super singleton, options
- if @constrainingElement
- @constrainingElement.focus()
+ if element?.focus?
+ element.focus()
@push
- "blur": (event) => @alwaysContinueBubbling =>
- @exit() if event.srcElement == @constrainingElement
+ "blur": (event) => @alwaysContinueBubbling => @exit() if event.srcElement == element
# The state mode tracks the enabled state in @enabled and @passKeys. It calls @registerStateChange() whenever
# the state changes. The state is distributed by bubbling a "registerStateChange" event down the handler