diff options
| author | Stephen Blott | 2015-03-17 11:42:58 +0000 |
|---|---|---|
| committer | Stephen Blott | 2015-03-17 11:42:58 +0000 |
| commit | 8bc811aae1118e28faa7c17e67b039c67f637274 (patch) | |
| tree | 702f28f1d88fef438a717895ede5107409df54be /content_scripts/ui_component.coffee | |
| parent | 9461d30b0d19fd65dc43e18bebec1fe0fd3ee818 (diff) | |
| download | vimium-8bc811aae1118e28faa7c17e67b039c67f637274.tar.bz2 | |
Activate vomnibar in window.top; hide on focus, fixed.
Diffstat (limited to 'content_scripts/ui_component.coffee')
| -rw-r--r-- | content_scripts/ui_component.coffee | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index 64dddf67..3d8cef29 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -15,9 +15,9 @@ class UIComponent # Hide the iframe, but don't interfere with the focus. @hide false - # If any frame in the current tab receives the focus, then we hide the vomnibar. + # If any other frame in the current tab receives the focus, then we hide the vomnibar. chrome.runtime.onMessage.addListener (request) => - @hide false if @showing and request.name == "frameFocused" + @hide false if @showing and request.name == "frameFocused" and request.frameId != frameId false # Free up response handler. # Open a port and pass it to the iframe via window.postMessage. @@ -42,11 +42,21 @@ class UIComponent @postMessage message if message? @iframeElement.classList.remove "vimiumUIComponentHidden" @iframeElement.classList.add "vimiumUIComponentShowing" + # The window may not have the focus. We focus it now, to prevent the "focus" listener below from firing + # immediately. + window.focus() + window.addEventListener "focus", @onFocus = (event) => + if event.target == window + window.removeEventListener "focus", @onFocus + @onFocus = null + @postMessage "hide" @showing = true hide: (focusWindow = true)-> @iframeElement.classList.remove "vimiumUIComponentShowing" @iframeElement.classList.add "vimiumUIComponentHidden" + window.removeEventListener "focus", @onFocus if @onFocus + @onFocus = null if focusWindow and @options?.frameId? chrome.runtime.sendMessage handler: "sendMessageToFrames" |
