From 549f38eb3dc994cff20e10eb69a2f155a498abdf Mon Sep 17 00:00:00 2001 From: Niklas Baumstark Date: Fri, 13 Apr 2012 04:20:45 +0200 Subject: change to real input box --- fuzzyMode.js | 33 ++++++++++++--------------------- vimium.css | 9 +++++++++ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/fuzzyMode.js b/fuzzyMode.js index aab89e16..37107a07 100644 --- a/fuzzyMode.js +++ b/fuzzyMode.js @@ -39,8 +39,8 @@ var fuzzyMode = (function() { show: function(reverseAction) { this.reverseAction = reverseAction; this.box.style.display = 'block'; - var self = this; - handlerStack.push({ keydown: function(event) { self.onKeydown(event); }}); + this.input.focus(); + handlerStack.push({ keydown: this.onKeydown.bind(this) }); }, hide: function() { @@ -50,7 +50,7 @@ var fuzzyMode = (function() { }, reset: function() { - this.query = ''; + this.input.value = ''; this.updateTimer = null; this.completions = []; this.selection = 0; @@ -86,13 +86,6 @@ var fuzzyMode = (function() { this.updateSelection(); } - else if (event.keyCode == keyCodes.backspace) { - if (this.query.length > 0) { - this.query = this.query.substr(0, this.query.length-1); - this.update(); - } - } - // refresh with F5 else if (keyChar == 'f5') { this.completer.refresh(); @@ -110,12 +103,11 @@ var fuzzyMode = (function() { self.hide(); }); } - - else if (keyChar.length == 1) { - this.query += keyChar; - this.update(); + else { + return true; // pass through } + // it seems like we have to manually supress the event here and still return true... event.stopPropagation(); event.preventDefault(); return true; @@ -123,8 +115,9 @@ var fuzzyMode = (function() { updateCompletions: function(callback) { var self = this; - //var start = Date.now(); - this.completer.filter(this.query, this.maxResults, function(completions) { + query = this.input.value.replace(/^\s*/, ''); + + this.completer.filter(query, this.maxResults, function(completions) { self.completions = completions; // update completion list with the new data @@ -141,9 +134,6 @@ var fuzzyMode = (function() { update: function(force, callback) { force = force || false; // explicitely default to asynchronous updating - this.query = this.query.replace(/^\s*/, ''); - this.input.textContent = this.query; - if (force) { // cancel scheduled update if (this.updateTimer !== null) @@ -168,12 +158,13 @@ var fuzzyMode = (function() { '
'+ '
'+ '' + utils.escapeHtml(this.prompt) + ' '+ - '
'+ + '
'+ ''); this.box.style.display = 'none'; document.body.appendChild(this.box); - this.input = document.querySelector("#fuzzybox .query"); + this.input = document.querySelector("#fuzzybox .query"); + this.input.addEventListener("input", function() { this.update(); }.bind(this)); this.completionList = document.querySelector("#fuzzybox ul"); this.completionList.style.display = 'none'; }, diff --git a/vimium.css b/vimium.css index 53bc50d8..774c0fd3 100644 --- a/vimium.css +++ b/vimium.css @@ -369,3 +369,12 @@ body.vimiumFindMode ::selection { font-size: inherit !important; font-family: inherit !important; } + +#fuzzybox .input .query { + font-size: inherit !important; + font-family: inherit !important; + color: inherit !important; + background: none; + outline: none; + border: none; +} -- cgit v1.2.3