diff options
| author | Stephen Blott | 2015-01-05 13:33:55 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-05 13:51:56 +0000 |
| commit | f2cc3b3e870e3c0c6946a675b7971e128bf9e824 (patch) | |
| tree | 7cf33e1e2dc8f781a46ae03e9ae9dca8d31231f3 /content_scripts | |
| parent | edd52393cc9897a74d2ea94001cafe55dec09433 (diff) | |
| download | vimium-f2cc3b3e870e3c0c6946a675b7971e128bf9e824.tar.bz2 | |
Modes; minor tweeks.
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/mode.coffee | 10 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 24 |
2 files changed, 14 insertions, 20 deletions
diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index 30136315..e5795190 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -140,17 +140,17 @@ class ExitOnEscapeMode extends SingletonMode event: event @suppressEvent -# When @element loses the focus. +# Exit mode when @constrainingElement (if defined) loses the focus. class ConstrainedMode extends ExitOnEscapeMode - constructor: (@element, singleton, options) -> + constructor: (@constrainingElement, singleton, options) -> super singleton, options - if @element - @element.focus() + if @constrainingElement + @constrainingElement.focus() @push "blur": (event) => handlerStack.alwaysContinueBubbling => - @exit() if event.srcElement == @element + @exit() if event.srcElement == @constrainingElement # The state mode tracks the enabled state in @enabled and @passKeys, and its initialized state in # @initialized. It calls @registerStateChange() whenever the state changes. diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 99463fbc..fd55348d 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -344,8 +344,6 @@ extend window, new VisualMode() focusInput: (count) -> - SingletonMode.kill PostFindMode - # Focus the first input element on the page, and create overlays to highlight all the input elements, with # the currently-focused element highlighted specially. Tabbing will shift focus to the next input element. # Pressing any other key will remove the overlays and the special tab behavior. @@ -361,14 +359,14 @@ extend window, selectedInputIndex = Math.min(count - 1, visibleInputs.length - 1) - element = visibleInputs[selectedInputIndex].element - element.focus() - - # If PostFindMode is was previously active, then element may already have had the focus. In this case, - # focus() does not generate a "focus" event. So we now force insert mode. - new InsertMode element + element = visibleInputs[selectedInputIndex].element.focus() - return if visibleInputs.length == 1 + if visibleInputs.length == 1 + # If PostFindMode is was previously active, then element may already have had the focus. In this case, + # focus(), above, will not have generated a "focus" event to trigger insert mode. So we force insert + # mode now. + new InsertMode visibleInputs[selectedInputIndex].element + return hints = for tuple in visibleInputs hint = document.createElement("div") @@ -402,16 +400,12 @@ extend window, if ++selectedInputIndex == hints.length selectedInputIndex = 0 hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' - element = visibleInputs[selectedInputIndex].element - element.focus() + visibleInputs[selectedInputIndex].element.focus() false else unless event.keyCode == KeyboardUtils.keyCodes.shiftKey DomUtils.removeElement hintContainingDiv @exit() - new InsertMode element - return true - keypress: (event) -> false - keyup: (event) -> false + new InsertMode visibleInputs[selectedInputIndex].element new FocusSelector() |
