diff options
Diffstat (limited to 'pages')
| -rw-r--r-- | pages/help_dialog.html | 1 | ||||
| -rw-r--r-- | pages/options.coffee | 10 | ||||
| -rw-r--r-- | pages/options.html | 2 | ||||
| -rw-r--r-- | pages/vomnibar.coffee | 41 | 
4 files changed, 41 insertions, 13 deletions
| diff --git a/pages/help_dialog.html b/pages/help_dialog.html index 0884f2cd..77c3e2bf 100644 --- a/pages/help_dialog.html +++ b/pages/help_dialog.html @@ -46,6 +46,7 @@      </div>      <div class="vimiumReset vimiumColumn" style="text-align:right">        <span class="vimiumReset">Version {{version}}</span><br/> +      <a href="https://github.com/philc/vimium#release-notes" class="vimiumReset">What's new?</a>      </div>    </div>  </div> diff --git a/pages/options.coffee b/pages/options.coffee index d2950348..6545189b 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -271,8 +271,12 @@ initPopupPage = ->      exclusions = null      document.getElementById("optionsLink").setAttribute "href", chrome.runtime.getURL("pages/options.html") +    # As the active URL, we choose the most recently registered URL from a frame in the tab, or the tab's own +    # URL. +    url = chrome.extension.getBackgroundPage().urlForTab[tab.id] || tab.url +      updateState = -> -      rule = bgExclusions.getRule tab.url, exclusions.readValueFromElement() +      rule = bgExclusions.getRule url, exclusions.readValueFromElement()        $("state").innerHTML = "Vimium will " +          if rule and rule.passKeys            "exclude <span class='code'>#{rule.passKeys}</span>" @@ -291,8 +295,6 @@ initPopupPage = ->        Option.saveOptions()        $("saveOptions").innerHTML = "Saved"        $("saveOptions").disabled = true -      chrome.tabs.query { windowId: chrome.windows.WINDOW_ID_CURRENT, active: true }, (tabs) -> -        chrome.extension.getBackgroundPage().updateActiveState(tabs[0].id)      $("saveOptions").addEventListener "click", saveOptions @@ -302,7 +304,7 @@ initPopupPage = ->          window.close()      # Populate options. Just one, here. -    exclusions = new ExclusionRulesOnPopupOption(tab.url, "exclusionRules", onUpdated) +    exclusions = new ExclusionRulesOnPopupOption url, "exclusionRules", onUpdated      updateState()      document.addEventListener "keyup", updateState diff --git a/pages/options.html b/pages/options.html index 889d5ea0..f89ddcbb 100644 --- a/pages/options.html +++ b/pages/options.html @@ -200,7 +200,7 @@ b: http://b.com/?q=%s description                  <div class="help">                    <div class="example">                        The page to open with the "create new tab" command. -                      Set this to "<tt>pages/blank.html</tt>" for a blank page.<br /> +                      Set this to "<tt>pages/blank.html</tt>" for a blank page (except incognito mode).<br />                    </div>                  </div>                  <input id="newTabUrl" type="text" /> diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index 18a72a37..06ec9ee9 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -38,9 +38,13 @@ Vomnibar =      @vomnibarUI.setQuery(options.query)      @vomnibarUI.update() +  hide: -> @vomnibarUI?.hide() +  onHidden: -> @vomnibarUI?.onHidden() +  class VomnibarUI    constructor: ->      @refreshInterval = 0 +    @postHideCallback = null      @initDom()    setQuery: (query) -> @input.value = query @@ -57,9 +61,20 @@ class VomnibarUI    setForceNewTab: (forceNewTab) -> @forceNewTab = forceNewTab -  hide: -> +  # The sequence of events when the vomnibar is hidden is as follows: +  # 1. Post a "hide" message to the host page. +  # 2. The host page hides the vomnibar and posts back a "hidden" message. +  # 3. Only once "hidden" message is received here is any required action (callback) invoked (in onHidden). +  # This ensures that the vomnibar is actually hidden, and avoids flicker after opening a link in a new tab +  # (see #1485). +  hide: (callback = null) ->      UIComponentServer.postMessage "hide"      @reset() +    @postHideCallback = callback + +  onHidden: -> +    @postHideCallback?() +    @postHideCallback = null    reset: ->      @completionList.style.display = "" @@ -121,15 +136,15 @@ class VomnibarUI          query = @input.value.trim()          # <Enter> on an empty vomnibar is a no-op.          return unless 0 < query.length -        @hide() -        chrome.runtime.sendMessage({ -          handler: if openInNewTab then "openUrlInNewTab" else "openUrlInCurrentTab" -          url: query }) +        @hide -> +          chrome.runtime.sendMessage +            handler: if openInNewTab then "openUrlInNewTab" else "openUrlInCurrentTab" +            url: query        else          @update true, =>            # Shift+Enter will open the result in a new tab instead of the current tab. -          @completions[@selection].performAction(openInNewTab) -          @hide() +          completion = @completions[@selection] +          @hide -> completion.performAction openInNewTab      # It seems like we have to manually suppress the event here and still return true.      event.stopImmediatePropagation() @@ -180,6 +195,12 @@ class VomnibarUI      @completionList.style.display = ""      window.addEventListener "focus", => @input.focus() +    # A click in the vomnibar itself refocuses the input. +    @box.addEventListener "click", (event) => +      @input.focus() +      event.stopImmediatePropagation() +    # A click anywhere else hides the vomnibar. +    document.body.addEventListener "click", => @hide()  #  # Sends filter and refresh requests to a Vomnibox completer on the background page. @@ -225,7 +246,11 @@ extend BackgroundCompleter,      switchToTab: (tabId) -> chrome.runtime.sendMessage({ handler: "selectSpecificTab", id: tabId }) -UIComponentServer.registerHandler (event) -> Vomnibar.activate event.data +UIComponentServer.registerHandler (event) -> +  switch event.data +    when "hide" then Vomnibar.hide() +    when "hidden" then Vomnibar.onHidden() +    else Vomnibar.activate event.data  root = exports ? window  root.Vomnibar = Vomnibar | 
