diff options
| author | Phil Crosby | 2012-05-05 15:00:09 -0700 |
|---|---|---|
| committer | Phil Crosby | 2012-05-05 18:32:13 -0700 |
| commit | 8bbdcd53d87f3504853405d6e20c11759666e487 (patch) | |
| tree | beed29f2fce2713d1d4b2c7a4056d5ef1fb3a5e8 | |
| parent | ce46b9486e1842fe9002b9dcd04afbe06bdedd57 (diff) | |
| download | vimium-8bbdcd53d87f3504853405d6e20c11759666e487.tar.bz2 | |
Move backgroundCompleter into fuzzymode.js
This is the first step in an attempt to split background js from frontend.
| -rw-r--r-- | fuzzyMode.js | 30 | ||||
| -rw-r--r-- | lib/completion.js | 24 |
2 files changed, 29 insertions, 25 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js index 8667d467..2d53431e 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -4,7 +4,7 @@ var fuzzyMode = (function() { function getCompleter(name) { if (!(name in completers)) - completers[name] = new completion.BackgroundCompleter(name); + completers[name] = new BackgroundCompleter(name); return completers[name]; } @@ -167,6 +167,34 @@ var fuzzyMode = (function() { }, } + /* + * Sends filter and refresh requests to a Vomnibar completer on the background page. + */ + var BackgroundCompleter = Class.extend({ + /* + * - name: The name of the background page completer that you want to interface with. One of [omni, tabs]. + */ + init: function(name) { + this.name = name; + this.filterPort = chrome.extension.connect({ name: "filterCompleter" }); + }, + + refresh: function() { chrome.extension.sendRequest({ handler: "refreshCompleter", name: this.name }); }, + + filter: function(query, maxResults, callback) { + var id = utils.createUniqueId(); + this.filterPort.onMessage.addListener(function(msg) { + if (msg.id != id) return; + callback(msg.results.map(function(result) { + var action = result.action; + result.action = eval(action.func).apply(null, action.args); + return result; + })); + }); + this.filterPort.postMessage({ id: id, name: this.name, query: query, maxResults: maxResults }); + } + }); + // public interface return { activateAll: function() { start("omni", false, 100); }, diff --git a/lib/completion.js b/lib/completion.js index cd78a213..9eb003ca 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -253,29 +253,6 @@ var completion = (function() { } }); - /** Get completion results from the background page */ - var BackgroundCompleter = Class.extend({ - init: function(name) { - this.name = name; - this.filterPort = chrome.extension.connect({ name: "filterCompleter" }); - }, - - refresh: function() { chrome.extension.sendRequest({ handler: "refreshCompleter", name: this.name }); }, - - filter: function(query, maxResults, callback) { - var id = utils.createUniqueId(); - this.filterPort.onMessage.addListener(function(msg) { - if (msg.id != id) return; - callback(msg.results.map(function(result) { - var action = result.action; - result.action = eval(action.func).apply(null, action.args); - return result; - })); - }); - this.filterPort.postMessage({ id: id, name: this.name, query: query, maxResults: maxResults }); - } - }); - /** A meta-completer that delegates queries and merges and sorts the results of a collection of other * completer instances given in :sources. The optional argument :queryThreshold determines how long a * query has to be to trigger a search. */ @@ -621,7 +598,6 @@ var completion = (function() { SmartCompletionSource: SmartCompletionSource, DomainCompletionSource: DomainCompletionSource, MultiCompleter: MultiCompleter, - BackgroundCompleter: BackgroundCompleter, createActionOpenUrl: createActionOpenUrl, createActionSwitchToTab: createActionSwitchToTab, }; |
