diff options
| author | Stephen Blott | 2015-03-05 15:14:01 +0000 | 
|---|---|---|
| committer | Stephen Blott | 2015-03-05 15:14:01 +0000 | 
| commit | 8099d5d57f885517c4d5e04cdcc74c91980a75fb (patch) | |
| tree | 350b2ce99b6b76584d711fff88069941afe2cb09 /content_scripts/ui_component.coffee | |
| parent | c2638cd00b19e04bdfed164de6b1a3d4051cfbd9 (diff) | |
| download | vimium-8099d5d57f885517c4d5e04cdcc74c91980a75fb.tar.bz2 | |
Hide vomnibar if host frame regains focus.
Fixes #1506.
This takes the opposite approach to #1511.  Instead of hiding the
vomnibar when it blurs, we hide it when it's host frame is focused.
Diffstat (limited to 'content_scripts/ui_component.coffee')
| -rw-r--r-- | content_scripts/ui_component.coffee | 15 | 
1 files changed, 8 insertions, 7 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index c4ed3bf6..c6b59464 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -29,24 +29,25 @@ class UIComponent    activate: (message) ->      @postMessage message if message? -    if @showing -      # NOTE(smblott) Experimental.  Not sure this is a great idea. If the iframe was already showing, then -      # the user gets no visual feedback when it is re-focused.  So flash its border. -      @iframeElement.classList.add "vimiumUIComponentReactivated" -      setTimeout((=> @iframeElement.classList.remove "vimiumUIComponentReactivated"), 200) -    else -      @show() +    @show() unless @showing      @iframeElement.focus()    show: (message) ->      @postMessage message if message?      @iframeElement.classList.remove "vimiumUIComponentHidden"      @iframeElement.classList.add "vimiumUIComponentShowing" +    window.addEventListener "focus", @onFocus = (event) => +      if event.target == window +        window.removeEventListener @onFocus +        @onFocus = null +        @postMessage "hide"      @showing = true    hide: (focusWindow = true)->      @iframeElement.classList.remove "vimiumUIComponentShowing"      @iframeElement.classList.add "vimiumUIComponentHidden" +    window.removeEventListener @onFocus if @onFocus +    @onFocus = null      window.focus() if focusWindow      @showing = false  | 
