aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts/hud.coffee
diff options
context:
space:
mode:
authorStephen Blott2016-04-18 06:49:30 +0100
committerStephen Blott2016-04-18 07:01:36 +0100
commit9c4c79eef9267d4bde62a996f82fcb0eff66df91 (patch)
tree2f1bcba1b9f9c267809217f9f526579f31c303ef /content_scripts/hud.coffee
parent8846d04f3043e4be4be3d8e63c1efb46fe7e0b0e (diff)
downloadvimium-9c4c79eef9267d4bde62a996f82fcb0eff66df91.tar.bz2
Require documentReady for all UI components.
This replaces c01d7eea8675f9a7d84999777e8de72244d687b6. All UI components require the document to be ready. So, here the constructor waits for DomUtils.documentReady(). The diff looks big, but mainly it's a result of changes in indentation in the constructor and in hide(). Also, hide() now uses @postMessage() to post a null message. This forces hide to use @iframePort.use(), which ensures that hide()s cannot overtake activate()s. This continues #2100.
Diffstat (limited to 'content_scripts/hud.coffee')
-rw-r--r--content_scripts/hud.coffee20
1 files changed, 9 insertions, 11 deletions
diff --git a/content_scripts/hud.coffee b/content_scripts/hud.coffee
index 62bcf03f..7ad13aaf 100644
--- a/content_scripts/hud.coffee
+++ b/content_scripts/hud.coffee
@@ -13,10 +13,8 @@ HUD =
# it doesn't sit on top of horizontal scrollbars like Chrome's HUD does.
init: ->
- unless @hudUI?
- @hudUI = new UIComponent "pages/hud.html", "vimiumHUDFrame", ({data}) =>
- this[data.name]? data
- @tween = new Tween "iframe.vimiumHUDFrame.vimiumUIComponentVisible", @hudUI.shadowDOM
+ @hudUI ?= new UIComponent "pages/hud.html", "vimiumHUDFrame", ({data}) => this[data.name]? data
+ @tween ?= new Tween "iframe.vimiumHUDFrame.vimiumUIComponentVisible", @hudUI.shadowDOM
showForDuration: (text, duration) ->
@show(text)
@@ -46,13 +44,13 @@ HUD =
# If :updateIndicator is truthy, then we also refresh the mode indicator. The only time we don't update the
# mode indicator, is when hide() is called for the mode indicator itself.
hide: (immediate = false, updateIndicator = true) ->
- return unless @hudUI?.uiComponentIsReady
- clearTimeout(@_showForDurationTimerId)
- @tween.stop()
- if immediate
- if updateIndicator then Mode.setIndicator() else @hudUI.hide()
- else
- @tween.fade 0, 150, => @hide true, updateIndicator
+ if @hudUI? and @tween?
+ clearTimeout @_showForDurationTimerId
+ @tween.stop()
+ if immediate
+ if updateIndicator then Mode.setIndicator() else @hudUI.hide()
+ else
+ @tween.fade 0, 150, => @hide true, updateIndicator
hideFindMode: (data) ->
@findMode.checkReturnToViewPort()