diff options
| author | ilya | 2012-07-07 22:33:18 -0700 |
|---|---|---|
| committer | ilya | 2012-07-07 22:33:18 -0700 |
| commit | e7def00476d6eec553a1ec31bc1d2cc2a6c7fd23 (patch) | |
| tree | 896b10c020db52b36639269f86649fbff6824e2f | |
| parent | 1d1a9c55dc0987b0b2ebd4eb73ac7e7be8651fde (diff) | |
| download | vimium-e7def00476d6eec553a1ec31bc1d2cc2a6c7fd23.tar.bz2 | |
Select the first result by default for tabs and bookmarks modes
| -rw-r--r-- | content_scripts/vomnibar.coffee | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/content_scripts/vomnibar.coffee b/content_scripts/vomnibar.coffee index 433d0d01..bb95a407 100644 --- a/content_scripts/vomnibar.coffee +++ b/content_scripts/vomnibar.coffee @@ -10,10 +10,11 @@ Vomnibar = # # Activate the Vomnibox. # - activateWithCompleter: (completerName, refreshInterval, initialQueryValue) -> + activateWithCompleter: (completerName, refreshInterval, initialQueryValue, selectFirstResult) -> completer = @getCompleter(completerName) @vomnibarUI = new VomnibarUI() unless @vomnibarUI completer.refresh() + @vomnibarUI.setInitialSelectionValue(if selectFirstResult then 0 else -1) @vomnibarUI.setCompleter(completer) @vomnibarUI.setRefreshInterval(refreshInterval) @vomnibarUI.show() @@ -23,8 +24,8 @@ Vomnibar = activate: -> @activateWithCompleter("omni", 100) activateWithCurrentUrl: -> @activateWithCompleter("omni", 100, window.location.toString()) - activateTabSelection: -> @activateWithCompleter("tabs", 0) - activateBookmarks: -> @activateWithCompleter("bookmarks", 0) + activateTabSelection: -> @activateWithCompleter("tabs", 0, null, true) + activateBookmarks: -> @activateWithCompleter("bookmarks", 0, null, true) getUI: -> @vomnibarUI @@ -35,6 +36,9 @@ class VomnibarUI setQuery: (query) -> @input.value = query + setInitialSelectionValue: (initialSelectionValue) -> + @initialSelectionValue = initialSelectionValue + setCompleter: (completer) -> @completer = completer @reset() @@ -56,7 +60,7 @@ class VomnibarUI @input.value = "" @updateTimer = null @completions = [] - @selection = -1 + @selection = @initialSelectionValue @update(true) updateSelection: -> @@ -93,11 +97,11 @@ class VomnibarUI @hide() else if (action == "up") @selection -= 1 - @selection = @completions.length - 1 if @selection < -1 + @selection = @completions.length - 1 if @selection < @initialSelectionValue @updateSelection() else if (action == "down") @selection += 1 - @selection = -1 if @selection == @completions.length + @selection = @initialSelectionValue if @selection == @completions.length @updateSelection() else if (action == "enter") # If they type something and hit enter without selecting a completion from our list of suggestions, |
