diff options
| author | Stephen Blott | 2015-01-06 12:04:19 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-06 12:04:19 +0000 |
| commit | f19f21f7114c6cdc2c62b69e0f6dafac68fd84a0 (patch) | |
| tree | 79cb394c5bd3482b88d136aa615d5e3cdfd46373 /content_scripts/mode.coffee | |
| parent | b0f56ca439af45b62b23efd8c19c3838945f21f4 (diff) | |
| download | vimium-f19f21f7114c6cdc2c62b69e0f6dafac68fd84a0.tar.bz2 | |
Mode; simplify InsertModeBlocker logic.
Diffstat (limited to 'content_scripts/mode.coffee')
| -rw-r--r-- | content_scripts/mode.coffee | 11 |
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 |
