diff options
| -rw-r--r-- | content_scripts/hud.coffee | 16 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 5 | ||||
| -rw-r--r-- | content_scripts/vomnibar.coffee | 9 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 3 |
4 files changed, 20 insertions, 13 deletions
diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee index 62bcf03f..38c9ab9b 100644 --- a/content_scripts/hud.coffee +++ b/content_scripts/hud.coffee @@ -23,15 +23,17 @@ HUD = @_showForDurationTimerId = setTimeout((=> @hide()), duration) show: (text) -> - @init() - clearTimeout(@_showForDurationTimerId) - @hudUI.activate {name: "show", text} - @tween.fade 1.0, 150 + DomUtils.ifDocumentIsReady => + @init() + clearTimeout(@_showForDurationTimerId) + @hudUI.activate {name: "show", text} + @tween.fade 1.0, 150 showFindMode: (@findMode = null) -> - @init() - @hudUI.activate name: "showFindMode" - @tween.fade 1.0, 150 + DomUtils.ifDocumentIsReady => + @init() + @hudUI.activate name: "showFindMode" + @tween.fade 1.0, 150 search: (data) -> @findMode.findInPlace data.query diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index a80093f9..d1ff874e 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -616,8 +616,9 @@ enterFindMode = -> new FindMode() window.showHelp = (sourceFrameId) -> - chrome.runtime.sendMessage handler: "getHelpDialogHtml", (response) -> - HelpDialog.toggle {sourceFrameId, html: response} + DomUtils.ifDocumentIsReady -> + chrome.runtime.sendMessage handler: "getHelpDialogHtml", (response) -> + HelpDialog.toggle {sourceFrameId, html: response} # If we are in the help dialog iframe, then HelpDialog is already defined with the necessary functions. window.HelpDialog ?= diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index cbd2892c..292cedc7 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -56,10 +56,11 @@ Vomnibar = # selectFirst - Optional, boolean. Whether to select the first entry. # newTab - Optional, boolean. Whether to open the result in a new tab. open: (sourceFrameId, options) -> - @init() - # The Vomnibar cannot coexist with the help dialog (it causes focus issues). - HelpDialog.abort() - @vomnibarUI.activate extend options, { name: "activate", sourceFrameId, focus: true } + DomUtils.ifDocumentIsReady => + @init() + # The Vomnibar cannot coexist with the help dialog (it causes focus issues). + HelpDialog.abort() + @vomnibarUI.activate extend options, { name: "activate", sourceFrameId, focus: true } root = exports ? window root.Vomnibar = Vomnibar diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index 3d719337..20392c83 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -13,6 +13,9 @@ DomUtils = (callback) -> if isReady then callback() else callbacks.push callback + ifDocumentIsReady: (callback) -> + callback() unless document.readyState == "loading" + createElement: (tagName) -> element = document.createElement tagName if element instanceof HTMLElement |
