diff options
| author | Stephen Blott | 2015-05-17 11:30:30 +0100 | 
|---|---|---|
| committer | Stephen Blott | 2015-05-17 11:30:30 +0100 | 
| commit | 0c7668d6cc46cf24081b6b64ece27faef6667dea (patch) | |
| tree | 61f17b652f66084c10b9b748107231fbc5c91d44 | |
| parent | 913806699a2cc66aea4489137a84189e01afd9da (diff) | |
| download | vimium-0c7668d6cc46cf24081b6b64ece27faef6667dea.tar.bz2 | |
TabToOpen: tidy up pre-PR.
| -rw-r--r-- | background_scripts/completion.coffee | 26 | ||||
| -rw-r--r-- | lib/utils.coffee | 2 | ||||
| -rw-r--r-- | pages/vomnibar.coffee | 14 | ||||
| -rw-r--r-- | pages/vomnibar.css | 7 | 
4 files changed, 15 insertions, 34 deletions
| diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee index d5c6c23a..0f8f24f5 100644 --- a/background_scripts/completion.coffee +++ b/background_scripts/completion.coffee @@ -45,17 +45,14 @@ class Suggestion      return @html if @html      relevancyHtml = if @showRelevancy then "<span class='relevancy'>#{@computeRelevancy()}</span>" else ""      # NOTE(philc): We're using these vimium-specific class names so we don't collide with the page's CSS. -    insertTextClass = if @insertText then "vomnibarInsertText" else "vomnibarNoInsertText" -    insertTextIndicator = "﹢" # A small plus sign. -    insertTextIndicator = "﹥" # A small "greater than" sign.      @html =        """        <div class="vimiumReset vomnibarTopHalf"> -         <span class="vimiumReset vomnibarSource #{insertTextClass}">#{insertTextIndicator}</span><span class="vimiumReset vomnibarSource">#{@type}</span> +         <span class="vimiumReset vomnibarSource">#{@type}</span>           <span class="vimiumReset vomnibarTitle">#{@highlightQueryTerms Utils.escapeHtml @title}</span>         </div>         <div class="vimiumReset vomnibarBottomHalf"> -        <span class="vimiumReset vomnibarSource vomnibarNoInsertText">#{insertTextIndicator}</span><span class="vimiumReset vomnibarUrl">#{@highlightQueryTerms Utils.escapeHtml @shortenUrl()}</span> +        <span class="vimiumReset vomnibarUrl">#{@highlightQueryTerms Utils.escapeHtml @shortenUrl()}</span>          #{relevancyHtml}        </div>        """ @@ -225,7 +222,7 @@ class BookmarkCompleter      RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title)  class HistoryCompleter -  filter: ({ queryTerms, tabToOpen }, onComplete) -> +  filter: ({ queryTerms, seenTabToOpenCompletionList }, onComplete) ->      @currentSearch = { queryTerms: @queryTerms, onComplete: @onComplete }      results = []      HistoryCache.use (history) => @@ -233,7 +230,7 @@ class HistoryCompleter        results =          if queryTerms.length > 0            history.filter (entry) -> RankingUtils.matches(queryTerms, entry.url, entry.title) -        else if tabToOpen +        else if seenTabToOpenCompletionList            # <Tab> opens the completion list, even without a query.            history          else @@ -253,14 +250,6 @@ class HistoryCompleter      # If there are no query terms, then relevancy is based on recency alone.      return recencyScore if suggestion.queryTerms.length == 0      wordRelevancy = RankingUtils.wordRelevancy(suggestion.queryTerms, suggestion.url, suggestion.title) -    if suggestion.insertText? -      # If this suggestion matches a previous search with the default search engine, then we also score the -      # previous query terms themselves (suggestion.insertText) and, if that score is higher, then we use it -      # in place of the wordRelevancy score.  Because the query terms are shorter than the original URL, this -      # has the side effect of boosting the wordRelevancy score for previous searches with the default search -      # engine. -      wordRelevancy = Math.max wordRelevancy, -        RankingUtils.wordRelevancy suggestion.queryTerms, suggestion.insertText, suggestion.title      # Average out the word score and the recency. Recency has the ability to pull the score up, but not down.      (wordRelevancy + Math.max recencyScore, wordRelevancy) / 2 @@ -406,7 +395,7 @@ class SearchEngineCompleter    # This looks up the custom search engine and, if one is found, notes it and removes its keyword from the    # query terms. -  triageRequest: (request) -> +  preprocessRequest: (request) ->      @searchEngines.use (engines) =>        { queryTerms, query } = request        request.searchEngines = engines @@ -559,7 +548,6 @@ class SearchEngineCompleter              console.log suggestion.insertText, engine unless engine.description              suggestion.type = engine.description ? "custom search"              break -    delete request.searchEngines  # A completer which calls filter() on many completers, aggregates the results, ranks them, and returns the top  # 10. All queries from the vomnibar come through a multi completer. @@ -578,7 +566,7 @@ class MultiCompleter      # Provide each completer with an opportunity to see (and possibly alter) the request before it is      # launched. -    completer.triageRequest? request for completer in @completers +    completer.preprocessRequest? request for completer in @completers      RegexpCache.clear()      { queryTerms } = request @@ -648,7 +636,7 @@ class MultiCompleter          break if count++ == @maxResults          seenUrls[url] = suggestion -    # Give each completer an opportunity to tweak the suggestions. +    # Give each completer the opportunity to tweak the suggestions.      completer.postProcessSuggestions? request, suggestions for completer in @completers      # Generate HTML for the remaining suggestions and return them. diff --git a/lib/utils.coffee b/lib/utils.coffee index cd466b9b..724250e0 100644 --- a/lib/utils.coffee +++ b/lib/utils.coffee @@ -114,7 +114,7 @@ Utils =      searchUrl += "%s" unless 0 <= searchUrl.indexOf "%s"      searchUrl.replace /%s/g, @createSearchQuery query -  # Extract a query from url if it appears to be a URL created by createSearchQuery. +  # Extract a query from url if it appears to be a URL created generated from the given search URL.    # For example, map "https://www.google.ie/search?q=star+wars&foo&bar" to "star wars".    extractQuery: do =>      queryTerminator = new RegExp "[?&#/]" diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee index c4b22911..fd7fd3cc 100644 --- a/pages/vomnibar.coffee +++ b/pages/vomnibar.coffee @@ -71,7 +71,7 @@ class VomnibarUI      @customSearchMode = null      @selection = @initialSelectionValue      @keywords = [] -    @tabToOpen = false +    @seenTabToOpenCompletionList = false    updateSelection: ->      # For custom search engines, we suppress the leading term (e.g. the "w" of "w query terms") within the @@ -126,8 +126,8 @@ class VomnibarUI      if (action == "dismiss")        @hide()      else if action in [ "tab", "down" ] -      if @input.value.trim().length == 0 and action == "tab" and not @tabToOpen -        @tabToOpen = true +      if @input.value.trim().length == 0 and action == "tab" and not @seenTabToOpenCompletionList +        @seenTabToOpenCompletionList = true          @update true        else          @selection += 1 @@ -162,8 +162,8 @@ class VomnibarUI          @input.value = @customSearchMode          @customSearchMode = null          @update true -      else if inputIsEmpty and @tabToOpen -        @tabToOpen = false +      else if inputIsEmpty and @seenTabToOpenCompletionList +        @seenTabToOpenCompletionList = false          @update true        else          return true # Do not suppress event. @@ -181,7 +181,7 @@ class VomnibarUI    updateCompletions: (callback = null) ->      @completer.filter        query: @getInputValueAsQuery() -      tabToOpen: @tabToOpen +      seenTabToOpenCompletionList: @seenTabToOpenCompletionList        callback: (@lastReponse) =>          { results } = @lastReponse          @completions = results @@ -194,7 +194,7 @@ class VomnibarUI          callback?()    onInput: => -    @tabToOpen = false +    @seenTabToOpenCompletionList = false      @completer.cancel()      if 0 <= @selection and @completions[@selection].customSearchMode and not @customSearchMode        @customSearchMode = @completions[@selection].customSearchMode diff --git a/pages/vomnibar.css b/pages/vomnibar.css index b1ed0252..9fdc43ba 100644 --- a/pages/vomnibar.css +++ b/pages/vomnibar.css @@ -145,10 +145,3 @@     * on the eye for this purpose. */    background-color: #E6EEFB;  } - -.vomnibarInsertText { -} - -.vomnibarNoInsertText { -  visibility: hidden; -} | 
