aboutsummaryrefslogtreecommitdiffstats
path: root/content_scripts
diff options
context:
space:
mode:
authormrmr19932014-12-29 09:33:34 +0000
committermrmr19932014-12-29 09:33:34 +0000
commit5ea0f75a00b592956981bf8f6f7a0d2fa89620ae (patch)
treefc2d8ba0ebdfcd50e6aa7392b3a716c4c0d5ea1a /content_scripts
parent71af7f016f51e3c8b9c1fcfba46cb8289c91e030 (diff)
downloadvimium-5ea0f75a00b592956981bf8f6f7a0d2fa89620ae.tar.bz2
Close UIComponent iframes when pressing esc by default
Diffstat (limited to 'content_scripts')
-rw-r--r--content_scripts/ui_component.coffee11
1 files changed, 11 insertions, 0 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee
index c0889e7f..f47719e5 100644
--- a/content_scripts/ui_component.coffee
+++ b/content_scripts/ui_component.coffee
@@ -14,6 +14,8 @@ class UIComponent
document.documentElement.appendChild @iframeElement
@hide()
+ @addEventListener "message", handleHideMessage
+
# Open a port and pass it to the iframe via window.postMessage.
openPort: ->
messageChannel = new MessageChannel()
@@ -30,6 +32,7 @@ class UIComponent
handleMessage: (event) ->
for listener in @messageEventListeners
retVal = listener.call this, event
+ retVal ?= true
return false unless retVal
true
@@ -60,7 +63,15 @@ class UIComponent
hide: ->
return unless @iframeElement?
@iframeElement.setAttribute "style", @hideStyle
+ window.focus()
@showing = false
+handleHideMessage = (event) ->
+ if event.data == "hide"
+ @hide()
+ false
+ else
+ true
+
root = exports ? window
root.UIComponent = UIComponent