aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authormrmr19932014-12-29 18:55:06 +0000
committermrmr19932014-12-29 18:55:06 +0000
commit57418a9ad6104c487b67fcfd27ec8503858e5a14 (patch)
tree54a6c129cf88393f7c2cfc15452cf0987e88aff4 /content_scripts
parent2dc855abaeeda8ad74c3179f7224858860672338 (diff)
downloadvimium-57418a9ad6104c487b67fcfd27ec8503858e5a14.tar.bz2
Use UIComponent for Vomnibar iframe
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/ui_component.coffee2
-rw-r--r--content_scripts/vimium_frontend.coffee3
-rw-r--r--content_scripts/vomnibar.coffee42
3 files changed, 14 insertions, 33 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee
index d89f0cc8..696cb42c 100644
--- a/content_scripts/ui_component.coffee
+++ b/content_scripts/ui_component.coffee
@@ -42,7 +42,7 @@ class UIComponent
@showing = true
@iframeElement.focus()
- hide: (focusWindow=true)->
+ hide: (focusWindow = true)->
if @showing
@iframeElement.setAttribute "style", @hideStyle
window.focus() if focusWindow
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index 2de08c39..ae275f0c 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -139,8 +139,6 @@ initializePreDomReady = ->
getActiveState: -> { enabled: isEnabledForUrl, passKeys: passKeys }
setState: setState
currentKeyQueue: (request) -> keyQueue = request.keyQueue
- vomnibarShow: -> Vomnibar.show()
- vomnibarClose: -> Vomnibar.close()
chrome.runtime.onMessage.addListener (request, sender, sendResponse) ->
# In the options page, we will receive requests from both content and background scripts. ignore those
@@ -202,6 +200,7 @@ initializeOnDomReady = ->
# Tell the background page we're in the dom ready state.
chrome.runtime.connect({ name: "domReady" })
CursorHider.init()
+ Vomnibar.init()
registerFrame = ->
# Don't register frameset containers; focusing them is no use.
diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee
index 10f75652..6b82d31c 100644
--- a/content_scripts/vomnibar.coffee
+++ b/content_scripts/vomnibar.coffee
@@ -2,7 +2,7 @@
# This wraps the vomnibar iframe, which we inject into the page to provide the vomnibar.
#
Vomnibar =
- vomnibarElement: null
+ vomnibarUI: null
activate: -> @open {completer:"omni"}
activateInNewTab: -> @open {
@@ -35,41 +35,23 @@ Vomnibar =
newTab: true
}
+ init: ->
+ unless @vomnibarUI?
+ @vomnibarUI = new UIComponent "pages/vomnibar.html", "vomnibarFrame", @handleMessage.bind this
+
+ handleMessage: (event) ->
+ if event.data == "hide"
+ @hide()
+
+
# This function opens the vomnibar. It accepts options, a map with the values:
# completer - The completer to fetch results from.
# 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) ->
- unless @vomnibarElement?
- @vomnibarElement = document.createElement "iframe"
- @vomnibarElement.className = "vomnibarFrame"
- @vomnibarElement.seamless = "seamless"
- @hide()
-
- options.frameId = frameId
-
- optionStrings = []
- for option of options
- if typeof options[option] == "boolean"
- optionStrings.push option if options[option]
- else
- optionStrings.push "#{option}=#{escape(options[option])}"
-
- @vomnibarElement.src = "#{chrome.runtime.getURL "pages/vomnibar.html"}?#{optionStrings.join "&"}"
- document.documentElement.appendChild @vomnibarElement
-
- @vomnibarElement.focus()
-
- close: ->
- @hide()
- @vomnibarElement?.remove()
-
- show: ->
- @vomnibarElement?.style.display = "block"
+ open: (options) -> @vomnibarUI.activate options
- hide: ->
- @vomnibarElement?.style.display = "none"
+ hide: -> @vomnibarUI?.hide()
root = exports ? window
root.Vomnibar = Vomnibar