aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/vimium_frontend.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-04-28 13:31:01 +0100
committerStephen Blott2015-04-28 13:31:01 +0100
commit8975229fd637ca1a91d7c52beb5969fe2b5e4d27 (patch)
tree74ace9150a4fa0de121b576f692982407a0bcd8b /content_scripts/vimium_frontend.coffee
parentc102821e37d1c1cec99580bfdba13bff9bd58de1 (diff)
downloadvimium-8975229fd637ca1a91d7c52beb5969fe2b5e4d27.tar.bz2
Activate grab-back-focus only if enabled.
This turned out to be trickier than expected. It turns out there's a period after document.body is defined but before the DOM is ready when we can't use the HUD (but previously thought we could, ie. HUD.isReady returned true).
Diffstat (limited to 'content_scripts/vimium_frontend.coffee')
-rw-r--r--content_scripts/vimium_frontend.coffee7
1 files changed, 5 insertions, 2 deletions
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index bc1f7687..c9410f90 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -13,6 +13,7 @@ isShowingHelpDialog = false
keyPort = null
isEnabledForUrl = true
isIncognitoMode = chrome.extension.inIncognitoContext
+isDomReady = false
passKeys = null
keyQueue = null
# The user's operating system.
@@ -149,7 +150,6 @@ window.initializeModes = ->
new NormalMode
new PassKeysMode
new InsertMode permanent: true
- new GrabBackFocus
Scroller.init settings
#
@@ -229,7 +229,9 @@ window.installListeners = ->
do (type) -> installListener window, type, (event) -> handlerStack.bubbleEvent type, event
installListener document, "DOMActivate", (event) -> handlerStack.bubbleEvent 'DOMActivate', event
installedListeners = true
+ # Other once-only initialisation.
FindModeHistory.init()
+ new GrabBackFocus if isEnabledForUrl
#
# Whenever we get the focus:
@@ -252,6 +254,7 @@ window.addEventListener "hashchange", onFocus
# Initialization tasks that must wait for the document to be ready.
#
initializeOnDomReady = ->
+ isDomReady = true
# Tell the background page we're in the dom ready state.
chrome.runtime.connect({ name: "domReady" })
CursorHider.init()
@@ -1153,7 +1156,7 @@ HUD =
else
HUD._tweenId = Tween.fade HUD.displayElement(), 0, 150, -> HUD.hide true, updateIndicator
- isReady: -> document.body != null
+ isReady: -> document.body != null and isDomReady
# A preference which can be toggled in the Options page. */
enabled: -> !settings.get("hideHud")