diff options
| author | Stephen Blott | 2015-01-21 11:34:56 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-01-21 12:27:52 +0000 |
| commit | 0ec38c1050b00845abaa2faa9f56d04c9d2b8992 (patch) | |
| tree | 9a6c25e2178905a8c094bfbf25c428d129de33fc /content_scripts/vimium_frontend.coffee | |
| parent | 6f73864899e1c802fd504dec1dcd1644d513d97d (diff) | |
| download | vimium-0ec38c1050b00845abaa2faa9f56d04c9d2b8992.tar.bz2 | |
Edit mode: initial framework.
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 725d8a53..79302930 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -328,9 +328,12 @@ extend window, enterInsertMode: -> new InsertMode global: true - enterVisualMode: => + enterVisualMode: -> new VisualMode() + enterEditMode: -> + @focusInput 1, EditMode + focusInput: do -> # Track the most recently focused input element. recentlyFocusedElement = null @@ -340,10 +343,11 @@ extend window, recentlyFocusedElement = event.target if DomUtils.isEditable event.target true - (count) -> + (count, mode = InsertMode) -> # 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. + # If mode is provided, then enter that mode on exit. Otherwise, just let insert mode take over. resultSet = DomUtils.evaluateXPath textInputXPath, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE visibleInputs = for i in [0...resultSet.snapshotLength] by 1 @@ -395,8 +399,7 @@ extend window, @exit() @continueBubbling - @onExit -> DomUtils.removeElement hintContainingDiv - hintContainingDiv = DomUtils.addElementList hints, + @hintContainingDiv = DomUtils.addElementList hints, id: "vimiumInputMarkerContainer" className: "vimiumReset" @@ -406,6 +409,13 @@ extend window, else hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' + exit: -> + super() + DomUtils.removeElement @hintContainingDiv + if mode and DomUtils.isEditable document.activeElement + new mode + singleton: document.activeElement + # Decide whether this keyChar should be passed to the underlying page. # Keystrokes are *never* considered passKeys if the keyQueue is not empty. So, for example, if 't' is a # passKey, then 'gt' and '99t' will neverthless be handled by vimium. |
