diff options
author | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-05-20 07:23:47 +0000 |
---|---|---|
committer | Neil Drumm <drumm@3064.no-reply.drupal.org> | 2006-05-20 07:23:47 +0000 |
commit | ae5e50883c7636210a908fa49a23cf0392662147 (patch) | |
tree | aa07edd9731f069f74842358dc9f47da2c9f6de6 /misc | |
parent | c95ffdf30ea48872b08103e6203b241786f9042c (diff) | |
download | brdo-ae5e50883c7636210a908fa49a23cf0392662147.tar.gz brdo-ae5e50883c7636210a908fa49a23cf0392662147.tar.bz2 |
#63630 by Zen, Remove hardcoded statements from the acdb prototype.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/autocomplete.js | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/misc/autocomplete.js b/misc/autocomplete.js index c00edc96d..49e7e0210 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -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() {}; |