diff options
| author | mrmr1993 | 2017-10-29 12:03:43 +0000 | 
|---|---|---|
| committer | mrmr1993 | 2017-10-29 12:03:43 +0000 | 
| commit | ad8fa8e850eaa6ca3ef4d45e1903d11aa564cafe (patch) | |
| tree | 890024729f3aee7580722c19d1ddb0ac26f9b159 | |
| parent | a00bb7d2172803bc04b3543b31345879cb434b27 (diff) | |
| download | vimium-ad8fa8e850eaa6ca3ef4d45e1903d11aa564cafe.tar.bz2 | |
Move FocusSelector to mode_normal.coffee
| -rw-r--r-- | content_scripts/mode_normal.coffee | 38 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 40 | 
2 files changed, 39 insertions, 39 deletions
| diff --git a/content_scripts/mode_normal.coffee b/content_scripts/mode_normal.coffee index 02681475..9a03e9d0 100644 --- a/content_scripts/mode_normal.coffee +++ b/content_scripts/mode_normal.coffee @@ -217,6 +217,44 @@ textInputXPath = (->    DomUtils.makeXPath(inputElements)  )() +class FocusSelector extends Mode +  constructor: (hints, visibleInputs, selectedInputIndex) -> +    super +      name: "focus-selector" +      exitOnClick: true +      keydown: (event) => +        if event.key == "Tab" +          hints[selectedInputIndex].classList.remove 'internalVimiumSelectedInputHint' +          selectedInputIndex += hints.length + (if event.shiftKey then -1 else 1) +          selectedInputIndex %= hints.length +          hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' +          DomUtils.simulateSelect visibleInputs[selectedInputIndex].element +          @suppressEvent +        else unless event.key == "Shift" +          @exit() +          # Give the new mode the opportunity to handle the event. +          @restartBubbling + +    @hintContainingDiv = DomUtils.addElementList hints, +      id: "vimiumInputMarkerContainer" +      className: "vimiumReset" + +    DomUtils.simulateSelect visibleInputs[selectedInputIndex].element +    if visibleInputs.length == 1 +      @exit() +      return +    else +      hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' + +  exit: -> +    super() +    DomUtils.removeElement @hintContainingDiv +    if document.activeElement and DomUtils.isEditable document.activeElement +      new InsertMode +        singleton: "post-find-mode/focus-input" +        targetElement: document.activeElement +        indicator: false +  root = exports ? (window.root ?= {})  root.NormalMode = NormalMode  root.NormalModeCommands = NormalModeCommands diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 920fb27c..5a2db5d0 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -295,44 +295,6 @@ extend root,      , true      -> recentlyFocusedElement -class FocusSelector extends Mode -  constructor: (hints, visibleInputs, selectedInputIndex) -> -    super -      name: "focus-selector" -      exitOnClick: true -      keydown: (event) => -        if event.key == "Tab" -          hints[selectedInputIndex].classList.remove 'internalVimiumSelectedInputHint' -          selectedInputIndex += hints.length + (if event.shiftKey then -1 else 1) -          selectedInputIndex %= hints.length -          hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' -          DomUtils.simulateSelect visibleInputs[selectedInputIndex].element -          @suppressEvent -        else unless event.key == "Shift" -          @exit() -          # Give the new mode the opportunity to handle the event. -          @restartBubbling - -    @hintContainingDiv = DomUtils.addElementList hints, -      id: "vimiumInputMarkerContainer" -      className: "vimiumReset" - -    DomUtils.simulateSelect visibleInputs[selectedInputIndex].element -    if visibleInputs.length == 1 -      @exit() -      return -    else -      hints[selectedInputIndex].classList.add 'internalVimiumSelectedInputHint' - -  exit: -> -    super() -    DomUtils.removeElement @hintContainingDiv -    if document.activeElement and DomUtils.isEditable document.activeElement -      new InsertMode -        singleton: "post-find-mode/focus-input" -        targetElement: document.activeElement -        indicator: false -  # Checks if Vimium should be enabled or not in this frame.  As a side effect, it also informs the background  # page whether this frame has the focus, allowing the background page to track the active frame's URL and set  # the page icon. @@ -462,7 +424,7 @@ root.Frame = Frame  root.windowIsFocused = windowIsFocused  root.bgLog = bgLog  # These are exported for find mode and link-hints mode. -extend root, {focusThisFrame, FocusSelector, findAndFollowRel, findAndFollowLink} +extend root, {focusThisFrame, findAndFollowRel, findAndFollowLink}  # These are exported only for the tests.  extend root, {installModes}  extend window, root unless exports? | 
