aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vimium_frontend.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-02-01 15:48:54 +0000
committerStephen Blott2015-02-01 15:48:54 +0000
commita9b8c4cdc176889c8ef442711109a9b5f4334c16 (patch)
treebe69020dd730339135510e54eebc450994d86f50 /content_scripts/vimium_frontend.coffee
parent68e4aa3931babdf97c5f12dc5f655415e2073402 (diff)
parent7939b69ffc2880ff4590d1c8dcfd5eb7492200fd (diff)
downloadvimium-a9b8c4cdc176889c8ef442711109a9b5f4334c16.tar.bz2
Merge branch 'modes-rework-dom-tests'
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
-rw-r--r--content_scripts/vimium_frontend.coffee29
1 files changed, 15 insertions, 14 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 725d8a53..5d56ad5b 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -103,13 +103,8 @@ frameId = Math.floor(Math.random()*999999999)
hasModifiersRegex = /^<([amc]-)+.>/
-#
-# Complete initialization work that sould be done prior to DOMReady.
-#
-initializePreDomReady = ->
- settings.addEventListener("load", LinkHints.init.bind(LinkHints))
- settings.load()
-
+# Only exported for tests.
+window.initializeModes = ->
class NormalMode extends Mode
constructor: ->
super
@@ -122,12 +117,20 @@ initializePreDomReady = ->
# Install the permanent modes. The permanently-installed insert mode tracks focus/blur events, and
# activates/deactivates itself accordingly.
+ new BadgeMode
new NormalMode
new PassKeysMode
new InsertMode permanent: true
- checkIfEnabledForUrl()
+#
+# Complete initialization work that sould be done prior to DOMReady.
+#
+initializePreDomReady = ->
+ settings.addEventListener("load", LinkHints.init.bind(LinkHints))
+ settings.load()
+ initializeModes()
+ checkIfEnabledForUrl()
refreshCompletionKeys()
# Send the key to the key handler in the background page.
@@ -179,7 +182,7 @@ installListener = (element, event, callback) ->
# Run this as early as possible, so the page can't register any event handlers before us.
#
installedListeners = false
-initializeWhenEnabled = (newPassKeys) ->
+window.initializeWhenEnabled = (newPassKeys) ->
isEnabledForUrl = true
passKeys = newPassKeys
if (!installedListeners)
@@ -334,11 +337,9 @@ extend window,
focusInput: do ->
# Track the most recently focused input element.
recentlyFocusedElement = null
- handlerStack.push
- _name: "focus-input-tracker"
- focus: (event) ->
- recentlyFocusedElement = event.target if DomUtils.isEditable event.target
- true
+ window.addEventListener "focus",
+ (event) -> recentlyFocusedElement = event.target if DomUtils.isEditable event.target
+ , true
(count) ->
# Focus the first input element on the page, and create overlays to highlight all the input elements, with