From 4e3ef0b401cfb4682a17a1ee88058ed76d64be20 Mon Sep 17 00:00:00 2001 From: mrmr1993 Date: Mon, 29 Dec 2014 10:29:09 +0000 Subject: Small changes to UIComponent --- content_scripts/ui_component.coffee | 17 +++++++++++------ content_scripts/vimium_frontend.coffee | 1 - 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index ce1af082..b0e4f71c 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -5,13 +5,16 @@ class UIComponent showStyle: "display: block;" hideStyle: "display: none;" - constructor: (iframeUrl, className) -> + constructor: (iframeUrl, className, showStyle, hideStyle) -> @iframeElement = document.createElement "iframe" @iframeElement.className = className @iframeElement.seamless = "seamless" @iframeElement.src = chrome.runtime.getURL iframeUrl @iframeElement.addEventListener "load", => @openPort() document.documentElement.appendChild @iframeElement + + @setShowStyle showStyle if showStyle? + @setHideStyle hideStyle if showStyle? @hide() @addEventListener "message", handleHideMessage @@ -43,9 +46,7 @@ class UIComponent removeEventListener: (type, listener) -> if type == "message" - listenerIndex = @messageEventListeners.indexOf listener - if listenerIndex > -1 - @messageEventListeners = @messageEventListeners.splice listenerIndex, 1 + @messageEventListeners = @messageEventListeners.filter (f) -> f != listener undefined setHideStyle: (@hideStyle) -> @@ -54,14 +55,18 @@ class UIComponent setShowStyle: (@showStyle) -> @show() if @showing == true + setStyles: (@showStyle = @showStyle, @hideStyle = @hideStyle) -> + if @showing + @show() + else + @hide() + show: -> - return unless @iframeElement? @iframeElement.setAttribute "style", @showStyle @iframeElement.focus() @showing = true hide: -> - return unless @iframeElement? @iframeElement.setAttribute "style", @hideStyle window.focus() @showing = false diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index 5c166ff0..a505a84a 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -922,7 +922,6 @@ exitFindMode = -> window.showHelpDialog = (html, fid) -> return if (isShowingHelpDialog || !document.body || fid != frameId) - isShowingHelpDialog = true container = document.createElement("div") container.id = "vimiumHelpDialogContainer" -- cgit v1.2.3