summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-04-05 00:53:16 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-04-05 00:53:16 +0000
commita81547d5b3351eb2db8797f1df0d56c25f7ebcec (patch)
tree06697a639cab829cca66ba0a69079b25cddb0760 /misc
parent34eefb707253debf4065a2d6cce221caf8057691 (diff)
downloadbrdo-a81547d5b3351eb2db8797f1df0d56c25f7ebcec.tar.gz
brdo-a81547d5b3351eb2db8797f1df0d56c25f7ebcec.tar.bz2
#57255: Cancel autocomplete requests when the user tabs out of the field
Diffstat (limited to 'misc')
-rw-r--r--misc/autocomplete.js16
-rw-r--r--misc/drupal.js4
2 files changed, 16 insertions, 4 deletions
diff --git a/misc/autocomplete.js b/misc/autocomplete.js
index 4d72005e1..93d5bf55d 100644
--- a/misc/autocomplete.js
+++ b/misc/autocomplete.js
@@ -47,7 +47,7 @@ function jsAC(input, db) {
this.db = db;
this.input.onkeydown = function (event) { return ac.onkeydown(this, event); };
this.input.onkeyup = function (event) { ac.onkeyup(this, event) };
- this.input.onblur = function () { ac.hidePopup() };
+ this.input.onblur = function () { ac.hidePopup(); ac.db.cancel(); };
this.popup = document.createElement('div');
this.popup.id = 'autocomplete';
this.popup.owner = this;
@@ -240,7 +240,7 @@ ACDB.prototype.search = function(searchString) {
var db = this;
this.timer = setTimeout(function() {
addClass(db.owner.input, 'throbbing');
- HTTPGet(db.uri +'/'+ encodeURIComponent(searchString), db.receive, db);
+ db.transport = HTTPGet(db.uri +'/'+ encodeURIComponent(searchString), db.receive, db);
}, this.delay);
}
@@ -263,3 +263,15 @@ ACDB.prototype.receive = function(string, xmlhttp, acdb) {
acdb.cache[acdb.searchString] = matches;
acdb.owner.found(matches);
}
+
+/**
+ * Cancels the current autocomplete request
+ */
+ACDB.prototype.cancel = function() {
+ if (this.owner) removeClass(this.owner.input, 'throbbing');
+ if (this.timer) clearTimeout(this.timer);
+ if (this.transport) {
+ this.transport.onreadystatechange = function() {};
+ this.transport.abort();
+ }
+}
diff --git a/misc/drupal.js b/misc/drupal.js
index e289d1592..cf4510a28 100644
--- a/misc/drupal.js
+++ b/misc/drupal.js
@@ -59,7 +59,7 @@ function HTTPGet(uri, callbackFunction, callbackParameter) {
}
}
}
- return true;
+ return xmlHttp;
}
else {
return xmlHttp.responseText;
@@ -100,7 +100,7 @@ function HTTPPost(uri, callbackFunction, callbackParameter, object) {
}
}
}
- return true;
+ return xmlHttp;
}
else {
return xmlHttp.responseText;