diff options
| author | Stephen Blott | 2015-04-25 07:06:31 +0100 |
|---|---|---|
| committer | Stephen Blott | 2015-04-25 07:06:31 +0100 |
| commit | 9100b1d48aa9c09d792d9e2c9251e6a6c62f81bf (patch) | |
| tree | e005bacd529ec8efa63243b45225051fc9af3417 /content_scripts/vomnibar.coffee | |
| parent | ef44d0ff49cec17a758b65c10ba4c0ecbc0c2ece (diff) | |
| parent | bfa6c88b41acac4c98d06f324f25f8bb7b328614 (diff) | |
| download | vimium-9100b1d48aa9c09d792d9e2c9251e6a6c62f81bf.tar.bz2 | |
Merge branch 'vomnibar-in-main-window' into vomnibar-in-main-window-merge
Conflicts:
background_scripts/main.coffee
content_scripts/vimium_frontend.coffee
Diffstat (limited to 'content_scripts/vomnibar.coffee')
| -rw-r--r-- | content_scripts/vomnibar.coffee | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index c4cfc8b9..2529c077 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -4,31 +4,33 @@ Vomnibar = vomnibarUI: null - activate: -> @open {completer:"omni"} - activateInNewTab: -> @open { + # sourceFrameId here (and below) is the ID of the frame from which this request originates, which may be different + # from the current frame. + activate: (sourceFrameId) -> @open sourceFrameId, {completer:"omni"} + activateInNewTab: (sourceFrameId) -> @open sourceFrameId, { completer: "omni" selectFirst: false newTab: true } - activateTabSelection: -> @open { + activateTabSelection: (sourceFrameId) -> @open sourceFrameId, { completer: "tabs" selectFirst: true } - activateBookmarks: -> @open { + activateBookmarks: (sourceFrameId) -> @open sourceFrameId, { completer: "bookmarks" selectFirst: true } - activateBookmarksInNewTab: -> @open { + activateBookmarksInNewTab: (sourceFrameId) -> @open sourceFrameId, { completer: "bookmarks" selectFirst: true newTab: true } - activateEditUrl: -> @open { + activateEditUrl: (sourceFrameId) -> @open sourceFrameId, { completer: "omni" selectFirst: false query: window.location.href } - activateEditUrlInNewTab: -> @open { + activateEditUrlInNewTab: (sourceFrameId) -> @open sourceFrameId, { completer: "omni" selectFirst: false query: window.location.href @@ -38,9 +40,11 @@ Vomnibar = init: -> unless @vomnibarUI? @vomnibarUI = new UIComponent "pages/vomnibar.html", "vomnibarFrame", (event) => - if event.data == "hide" - @vomnibarUI.hide() - @vomnibarUI.postMessage "hidden" + @vomnibarUI.hide() if event.data == "hide" + # Whenever the window receives the focus, we tell the Vomnibar UI that it has been hidden (regardless of + # whether it was previously visible). + window.addEventListener "focus", (event) => + @vomnibarUI.postMessage "hidden" if event.target == window; true # This function opens the vomnibar. It accepts options, a map with the values: @@ -48,7 +52,7 @@ Vomnibar = # query - Optional. Text to prefill the Vomnibar with. # selectFirst - Optional, boolean. Whether to select the first entry. # newTab - Optional, boolean. Whether to open the result in a new tab. - open: (options) -> @vomnibarUI.activate options + open: (sourceFrameId, options) -> @vomnibarUI.activate extend options, { sourceFrameId } root = exports ? window root.Vomnibar = Vomnibar |
