aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-03-06 11:50:55 +0000
committerStephen Blott2015-03-06 11:50:55 +0000
commit52c06b16325968289890dab2133f2ec33540fcb4 (patch)
tree9b0ec819f64b8fdfe91dbb06f5b4ec4bc776dba7 /content_scripts
parent29eb444f2fb519a0cae32363d8462aa06ef133a7 (diff)
parentbc7a12dc74eaea06bcad23d89fb81643bd8b1625 (diff)
downloadvimium-52c06b16325968289890dab2133f2ec33540fcb4.tar.bz2
Merge branch 'hide-vomnibar-on-focus'
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/ui_component.coffee15
1 files changed, 8 insertions, 7 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee
index c4ed3bf6..c6b59464 100644
--- a/content_scripts/ui_component.coffee
+++ b/content_scripts/ui_component.coffee
@@ -29,24 +29,25 @@ class UIComponent
activate: (message) ->
@postMessage message if message?
- if @showing
- # NOTE(smblott) Experimental. Not sure this is a great idea. If the iframe was already showing, then
- # the user gets no visual feedback when it is re-focused. So flash its border.
- @iframeElement.classList.add "vimiumUIComponentReactivated"
- setTimeout((=> @iframeElement.classList.remove "vimiumUIComponentReactivated"), 200)
- else
- @show()
+ @show() unless @showing
@iframeElement.focus()
show: (message) ->
@postMessage message if message?
@iframeElement.classList.remove "vimiumUIComponentHidden"
@iframeElement.classList.add "vimiumUIComponentShowing"
+ window.addEventListener "focus", @onFocus = (event) =>
+ if event.target == window
+ window.removeEventListener @onFocus
+ @onFocus = null
+ @postMessage "hide"
@showing = true
hide: (focusWindow = true)->
@iframeElement.classList.remove "vimiumUIComponentShowing"
@iframeElement.classList.add "vimiumUIComponentHidden"
+ window.removeEventListener @onFocus if @onFocus
+ @onFocus = null
window.focus() if focusWindow
@showing = false