aboutsummaryrefslogtreecommitdiffstats
path: root/background_scripts/completion.coffee
diff options
context:
space:
mode:
authorStephen Blott2015-05-27 08:34:15 +0100
committerStephen Blott2015-05-27 08:35:34 +0100
commite27da85676a9d62145ed7ef56e125de2e133ae10 (patch)
tree412fc458e08805a9836d63dcb76f1b7ae2b0a517 /background_scripts/completion.coffee
parent9b9c26a42bffa88584d44526da5e14a5e546fa07 (diff)
downloadvimium-e27da85676a9d62145ed7ef56e125de2e133ae10.tar.bz2
Custom-only: single-line completions for custom search engines.
Diffstat (limited to 'background_scripts/completion.coffee')
-rw-r--r--background_scripts/completion.coffee34
1 files changed, 22 insertions, 12 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index 7a5f37bf..3238f744 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -41,23 +41,32 @@ class Suggestion
# or @relevancyFunction.
@relevancy ?= @relevancyFunction this
- generateHtml: ->
+ generateHtml: (request) ->
return @html if @html
relevancyHtml = if @showRelevancy then "<span class='relevancy'>#{@computeRelevancy()}</span>" else ""
insertTextClass = if @insertText then "vomnibarInsertText" else "vomnibarNoInsertText"
insertTextIndicator = "&#8618;" # A right hooked arrow.
+ @title = @insertText if @insertText and request.isCustomSearch
# NOTE(philc): We're using these vimium-specific class names so we don't collide with the page's CSS.
@html =
- """
- <div class="vimiumReset vomnibarTopHalf">
- <span class="vimiumReset vomnibarSource #{insertTextClass}">#{insertTextIndicator}</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">#{@highlightUrlTerms Utils.escapeHtml @shortenUrl()}</span>
- #{relevancyHtml}
- </div>
- """
+ if request.isCustomSearch
+ """
+ <div class="vimiumReset vomnibarTopHalf">
+ <span class="vimiumReset vomnibarSource #{insertTextClass}">#{insertTextIndicator}</span><span class="vimiumReset vomnibarSource">#{@type}</span>
+ <span class="vimiumReset vomnibarTitle">#{@highlightQueryTerms Utils.escapeHtml @title}</span>
+ </div>
+ """
+ else
+ """
+ <div class="vimiumReset vomnibarTopHalf">
+ <span class="vimiumReset vomnibarSource #{insertTextClass}">#{insertTextIndicator}</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">#{@highlightUrlTerms Utils.escapeHtml @shortenUrl()}</span>
+ #{relevancyHtml}
+ </div>
+ """
# Use neat trick to snatch a domain (http://stackoverflow.com/a/8498668).
getUrlRoot: (url) ->
@@ -419,6 +428,7 @@ class SearchEngineCompleter
queryTerms: queryTerms[1..]
keyword: keyword
engine: engines[keyword]
+ isCustomSearch: true
refresh: (port) ->
@previousSuggestions = {}
@@ -662,7 +672,7 @@ class MultiCompleter
completer.postProcessSuggestions? request, suggestions for completer in @completers
# Generate HTML for the remaining suggestions and return them.
- suggestion.generateHtml() for suggestion in suggestions
+ suggestion.generateHtml request for suggestion in suggestions
suggestions
# Utilities which help us compute a relevancy score for a given item.