aboutsummaryrefslogtreecommitdiffstats
path: root/fuzzyMode.js
diff options
context:
space:
mode:
authorPhil Crosby2012-05-05 18:43:19 -0700
committerPhil Crosby2012-05-05 18:43:19 -0700
commit46f395b18705231af14a76b8050ce168a4640dda (patch)
treee15c28e19ae3153476f3d80581189dafd3a80e0a /fuzzyMode.js
parent49a7cc898a52f74a42beabb7274733a53f692427 (diff)
downloadvimium-46f395b18705231af14a76b8050ce168a4640dda.tar.bz2
Use proxy instead of self
Diffstat (limited to 'fuzzyMode.js')
-rw-r--r--fuzzyMode.js25
1 files changed, 11 insertions, 14 deletions
diff --git a/fuzzyMode.js b/fuzzyMode.js
index cc69211e..3b4839e8 100644
--- a/fuzzyMode.js
+++ b/fuzzyMode.js
@@ -65,7 +65,6 @@ var fuzzyMode = (function() {
},
onKeydown: function(event) {
- var self = this;
var keyChar = getKeyChar(event);
if (isEscape(event)) {
@@ -95,9 +94,9 @@ var fuzzyMode = (function() {
this.update(true, function() {
// Shift+Enter will open the result in a new tab instead of the current tab.
var openInNewTab = (event.shiftKey || isPrimaryModifierKey(event));
- self.completions[self.selection].performAction(openInNewTab);
- self.hide();
- });
+ this.completions[this.selection].performAction(openInNewTab);
+ this.hide();
+ }.proxy(this));
}
else {
return true; // pass through
@@ -110,21 +109,20 @@ var fuzzyMode = (function() {
},
updateCompletions: function(callback) {
- var self = this;
query = this.input.value.replace(/^\s*/, "");
this.completer.filter(query, this.maxResults, function(completions) {
- self.completions = completions;
+ this.completions = completions;
// update completion list with the new data
- self.completionList.innerHTML = completions.map(function(completion) {
+ this.completionList.innerHTML = completions.map(function(completion) {
return "<li>" + completion.html + "</li>";
}).join('');
- self.completionList.style.display = self.completions.length > 0 ? "block" : "none";
- self.updateSelection();
+ this.completionList.style.display = this.completions.length > 0 ? "block" : "none";
+ this.updateSelection();
if (callback) callback();
- });
+ }.proxy(this));
},
update: function(force, callback) {
@@ -139,13 +137,12 @@ var fuzzyMode = (function() {
// an update is already scheduled, don't do anything
return;
} else {
- var self = this;
// always update asynchronously for better user experience and to take some load off the CPU
// (not every keystroke will cause a dedicated update)
this.updateTimer = setTimeout(function() {
- self.updateCompletions(callback);
- self.updateTimer = null;
- }, this.refreshInterval);
+ this.updateCompletions(callback);
+ this.updateTimer = null;
+ }.proxy(this), this.refreshInterval);
}
},