Commit ae5e5088 authored by drumm's avatar drumm
Browse files

#63630 by Zen, Remove hardcoded statements from the acdb prototype.

parent c95ffdf3
......@@ -216,7 +216,19 @@ jsAC.prototype.found = function (matches) {
else {
this.hidePopup();
}
removeClass(this.input, 'throbbing');
}
jsAC.prototype.setStatus = function (status) {
switch (status) {
case 'begin':
addClass(this.input, 'throbbing');
break;
case 'cancel':
case 'error':
case 'found':
removeClass(this.input, 'throbbing');
break;
}
}
/**
......@@ -241,7 +253,7 @@ ACDB.prototype.search = function(searchString) {
}
var db = this;
this.timer = setTimeout(function() {
addClass(db.owner.input, 'throbbing');
db.owner.setStatus('begin');
db.transport = HTTPGet(db.uri +'/'+ encodeURIComponent(searchString), db.receive, db);
}, this.delay);
}
......@@ -252,7 +264,7 @@ ACDB.prototype.search = function(searchString) {
ACDB.prototype.receive = function(string, xmlhttp, acdb) {
// Note: Safari returns 'undefined' status if the request returns no data.
if (xmlhttp.status != 200 && typeof xmlhttp.status != 'undefined') {
removeClass(acdb.owner.input, 'throbbing');
acdb.owner.setStatus('error');
return alert('An HTTP error '+ xmlhttp.status +' occured.\n'+ acdb.uri);
}
// Parse back result
......@@ -260,6 +272,7 @@ ACDB.prototype.receive = function(string, xmlhttp, acdb) {
if (typeof matches['status'] == 'undefined' || matches['status'] != 0) {
acdb.cache[acdb.searchString] = matches;
acdb.owner.found(matches);
acdb.owner.setStatus('found');
}
}
......@@ -267,7 +280,7 @@ ACDB.prototype.receive = function(string, xmlhttp, acdb) {
* Cancels the current autocomplete request
*/
ACDB.prototype.cancel = function() {
if (this.owner) removeClass(this.owner.input, 'throbbing');
if (this.owner) this.owner.setStatus('cancel');
if (this.timer) clearTimeout(this.timer);
if (this.transport) {
this.transport.onreadystatechange = function() {};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment