diff options
| -rw-r--r-- | fuzzyMode.js | 27 | ||||
| -rw-r--r-- | lib/completion.js | 40 | ||||
| -rw-r--r-- | manifest.json | 1 |
3 files changed, 33 insertions, 35 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js index 2d53431e..f7514276 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -195,6 +195,33 @@ var fuzzyMode = (function() { } }); + /** Creates an action that opens :url in the current tab by default or in a new tab as an alternative. */ + function createActionOpenUrl(url) { + var open = function(newTab, selected) { + return function() { + chrome.extension.sendRequest({ + handler: newTab ? "openUrlInNewTab" : "openUrlInCurrentTab", + url: url, + selected: selected + }); + } + } + + if (url.indexOf("javascript:") == 0) + return [ open(false), open(false), open(false) ]; + else + return [ open(false), open(true, true), open(true, false) ]; + } + + /** Returns an action that switches to the tab with the given :id. */ + function createActionSwitchToTab(id) { + var open = function() { + chrome.extension.sendRequest({ handler: 'selectSpecificTab', id: id }); + } + return [open, open, open]; + } + + // public interface return { activateAll: function() { start("omni", false, 100); }, diff --git a/lib/completion.js b/lib/completion.js index 9eb003ca..b608a2e5 100644 --- a/lib/completion.js +++ b/lib/completion.js @@ -21,7 +21,7 @@ var completion = (function() { var url = item.url; var parts = [type, url, item.title]; var str = parts.join(' '); - action = action || {func: 'completion.createActionOpenUrl', args: [url]}; + action = action || {func: 'createActionOpenUrl', args: [url]}; function createLazyCompletion(query) { return new LazyCompletion(url.length / fuzzyMatcher.calculateRelevancy(query, str), function() { @@ -87,7 +87,7 @@ var completion = (function() { return new LazyCompletion(-2, function() { return { html: createCompletionHtml(desc, term), - action: {func: 'completion.createActionOpenUrl', args: [utils.createFullUrl(url)]}, + action: {func: 'createActionOpenUrl', args: [utils.createFullUrl(url)]}, }}) }.proxy(this)); }, @@ -101,7 +101,7 @@ var completion = (function() { return new LazyCompletion(-1, function() { return { html: createCompletionHtml(isUrl ? "goto" : "search", query), - action: {func: "completion.createActionOpenUrl", args: isUrl ? [utils.createFullUrl(query)] + action: {func: "createActionOpenUrl", args: isUrl ? [utils.createFullUrl(query)] : [utils.createSearchUrl(query)]}, }}); }, @@ -175,7 +175,7 @@ var completion = (function() { chrome.tabs.getAllInWindow(null, function(tabs) { this.asyncCompleter.resultsReady(tabs.map(function(tab) { return this.asyncCompleter.createInternalMatch("tab", tab, - { func: "completion.createActionSwitchToTab", args: [tab.id] }); + { func: "createActionSwitchToTab", args: [tab.id] }); }.proxy(this))); }.proxy(this)); } @@ -245,7 +245,7 @@ var completion = (function() { best = new LazyCompletion(-1.5, function() { return { html: createCompletionHtml('site', domain), - action: {func: 'completion.createActionOpenUrl', args: [protocol + '://' + domain]}, + action: {func: 'createActionOpenUrl', args: [protocol + '://' + domain]}, }}); }); }); @@ -479,32 +479,6 @@ var completion = (function() { return split.join(''); } - /** Creates an action that opens :url in the current tab by default or in a new tab as an alternative. */ - function createActionOpenUrl(url) { - var open = function(newTab, selected) { - return function() { - chrome.extension.sendRequest({ - handler: newTab ? "openUrlInNewTab" : "openUrlInCurrentTab", - url: url, - selected: selected - }); - } - } - - if (url.indexOf("javascript:") == 0) - return [ open(false), open(false), open(false) ]; - else - return [ open(false), open(true, true), open(true, false) ]; - } - - /** Returns an action that switches to the tab with the given :id. */ - function createActionSwitchToTab(id) { - var open = function() { - chrome.extension.sendRequest({ handler: 'selectSpecificTab', id: id }); - } - return [open, open, open]; - } - /** Creates an file-internal representation of a URL match with the given paramters */ function createCompletionHtml(type, str, title) { title = title || ''; @@ -597,8 +571,6 @@ var completion = (function() { FuzzyTabCompletionSource: FuzzyTabCompletionSource, SmartCompletionSource: SmartCompletionSource, DomainCompletionSource: DomainCompletionSource, - MultiCompleter: MultiCompleter, - createActionOpenUrl: createActionOpenUrl, - createActionSwitchToTab: createActionSwitchToTab, + MultiCompleter: MultiCompleter }; })() diff --git a/manifest.json b/manifest.json index 78b3a088..b0598dd2 100644 --- a/manifest.json +++ b/manifest.json @@ -21,7 +21,6 @@ "lib/keyboardUtils.js", "lib/domUtils.js", "lib/clipboard.js", - "lib/completion.js", "linkHints.js", "fuzzyMode.js", "vimiumFrontend.js" |
