diff options
| author | Phil Crosby | 2012-05-25 23:47:18 -0700 |
|---|---|---|
| committer | Phil Crosby | 2012-05-25 23:47:18 -0700 |
| commit | 3f81442c312128f1e0e6a5b6bffbbf4ecf49b726 (patch) | |
| tree | c9746477adb5ae2c5ff8c667bc240cf6c1880f18 /content_scripts/vomnibar.js | |
| parent | 770e301a1455a823c30fa9d4bed41c109165949b (diff) | |
| download | vimium-3f81442c312128f1e0e6a5b6bffbbf4ecf49b726.tar.bz2 | |
Add a vomnibar test harness, for quick styling work.
Diffstat (limited to 'content_scripts/vomnibar.js')
| -rw-r--r-- | content_scripts/vomnibar.js | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/content_scripts/vomnibar.js b/content_scripts/vomnibar.js index 4f136635..e5e81d32 100644 --- a/content_scripts/vomnibar.js +++ b/content_scripts/vomnibar.js @@ -21,6 +21,7 @@ var vomnibar = (function() { if (initialQueryValue) vomnibarUI.setQuery(initialQueryValue); vomnibarUI.show(); + return vomnibarUI; } /** User interface for fuzzy completion */ @@ -126,18 +127,21 @@ var vomnibar = (function() { this.completer.filter(query, this.maxResults, function(completions) { this.completions = completions; - - // update completion list with the new data - this.completionList.innerHTML = completions.map(function(completion) { - return "<li>" + completion.html + "</li>"; - }).join(''); - - this.completionList.style.display = this.completions.length > 0 ? "block" : "none"; - this.updateSelection(); + this.populateUiWithCompletions(completions); if (callback) callback(); }.proxy(this)); }, + populateUiWithCompletions: function(completions) { + // update completion list with the new data + this.completionList.innerHTML = completions.map(function(completion) { + return "<li>" + completion.html + "</li>"; + }).join(''); + + this.completionList.style.display = (completions.length > 0) ? "block" : "none"; + this.updateSelection(); + }, + update: function(force, callback) { force = force || false; // explicitely default to asynchronous updating @@ -161,15 +165,16 @@ var vomnibar = (function() { initDom: function() { this.box = utils.createElementFromHtml( - '<div id="vomnibar" class="vimiumReset">'+ - '<div class="input">'+ - '<span class="prompt">' + utils.escapeHtml(this.prompt) + '</span> '+ - '<input type="text" class="query"></span></div>'+ - '<ul></ul></div>'); + '<div id="vomnibar" class="vimiumReset">' + + '<div class="topHalf">' + + '<input type="text" />' + + '</div>' + + '<ul></ul>' + + '</div>'); this.box.style.display = 'none'; document.body.appendChild(this.box); - this.input = document.querySelector("#vomnibar .query"); + this.input = document.querySelector("#vomnibar input"); this.input.addEventListener("input", function() { this.update(); }.bind(this)); this.completionList = document.querySelector("#vomnibar ul"); this.completionList.style.display = "none"; @@ -227,6 +232,8 @@ var vomnibar = (function() { return { activate: function() { activate("omni", 100); }, activateWithCurrentUrl: function() { activate("omni", 100, window.location.toString()); }, - activateTabSelection: function() { activate("tabs", 0); } + activateTabSelection: function() { activate("tabs", 0); }, + /* Used by our vomnibar dev harness. */ + getUI: function() { return vomnibarUI; } } })(); |
