aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authorStephen Blott2015-03-17 10:32:40 +0000
committerStephen Blott2015-03-17 10:32:40 +0000
commit9461d30b0d19fd65dc43e18bebec1fe0fd3ee818 (patch)
tree38336fe71a9d0d345a98b526a417024f23d12bdb /content_scripts
parentaa8d00fd9779d4061431dbdcb7a70b9c39e8049a (diff)
downloadvimium-9461d30b0d19fd65dc43e18bebec1fe0fd3ee818.tar.bz2
Activate vomnibar in window.top; hide on focus.
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/ui_component.coffee15
-rw-r--r--content_scripts/vimium_frontend.coffee1
2 files changed, 6 insertions, 10 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee
index 82398727..64dddf67 100644
--- a/content_scripts/ui_component.coffee
+++ b/content_scripts/ui_component.coffee
@@ -15,6 +15,11 @@ 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.
+ chrome.runtime.onMessage.addListener (request) =>
+ @hide false if @showing and request.name == "frameFocused"
+ false # Free up response handler.
+
# Open a port and pass it to the iframe via window.postMessage.
openPort: ->
messageChannel = new MessageChannel()
@@ -37,21 +42,11 @@ 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 so that the focus listener below isn't triggered
- # 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"
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index eb951c33..941b2bc2 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -178,6 +178,7 @@ initializePreDomReady = ->
currentKeyQueue: (request) ->
keyQueue = request.keyQueue
handlerStack.bubbleEvent "registerKeyQueue", { keyQueue: keyQueue }
+ frameFocused: -> # A frame has received the focus. We don't care, here. The Vomnibar/UI-component cares.
chrome.runtime.onMessage.addListener (request, sender, sendResponse) ->
# In the options page, we will receive requests from both content and background scripts. ignore those