? .DS_Store
? autocomplete-exchangeableACDB.patch
? sites/default/files
? sites/default/private
? sites/default/settings.php
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.425
diff -u -p -r1.425 form.inc
--- includes/form.inc	3 Jan 2010 21:01:04 -0000	1.425
+++ includes/form.inc	7 Jan 2010 02:54:47 -0000
@@ -2838,7 +2838,8 @@ function theme_textfield($variables) {
   if ($element['#autocomplete_path'] && drupal_valid_path($element['#autocomplete_path'])) {
     drupal_add_js('misc/autocomplete.js');
     $class[] = 'form-autocomplete';
-    $extra =  '<input class="autocomplete" type="hidden" id="' . $element['#id'] . '-autocomplete" value="' . check_url(url($element['#autocomplete_path'], array('absolute' => TRUE))) . '" disabled="disabled" />';
+    $autocomplete_uri = check_url(url($element['#autocomplete_path'], array('absolute' => TRUE)));
+    drupal_add_js(array('autocomplete' => array($autocomplete_uri => array('Drupal.ACDB' => array('#' . $element['#id'])))), 'setting');
   }
   _form_set_class($element, $class);
 
Index: misc/autocomplete.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v
retrieving revision 1.34
diff -u -p -r1.34 autocomplete.js
--- misc/autocomplete.js	5 Sep 2009 12:03:31 -0000	1.34
+++ misc/autocomplete.js	7 Jan 2010 02:54:47 -0000
@@ -6,17 +6,19 @@
  */
 Drupal.behaviors.autocomplete = {
   attach: function (context, settings) {
-    var acdb = [];
-    $('input.autocomplete', context).once('autocomplete', function () {
-      var uri = this.value;
-      if (!acdb[uri]) {
-        acdb[uri] = new Drupal.ACDB(uri);
+    if (settings.autocomplete) {
+      for (uri in settings.autocomplete) {
+        for (type in settings.autocomplete[uri]) {
+          var acdb = eval('new ' + type + '(uri)');
+          for (i = 0; i < settings.autocomplete[uri][type].length; i++) {
+            $(settings.autocomplete[uri][type][i]).attr('autocomplete', 'OFF').once('autocomplete', function () {
+              $(this.form).submit(Drupal.autocompleteSubmit);
+              new Drupal.jsAC(this, acdb);
+            });
+          }
+        }
       }
-      var input = $('#' + this.id.substr(0, this.id.length - 13))
-        .attr('autocomplete', 'OFF')[0];
-      $(input.form).submit(Drupal.autocompleteSubmit);
-      new Drupal.jsAC(input, acdb[uri]);
-    });
+    }
   }
 };
 
@@ -37,11 +39,12 @@ Drupal.jsAC = function (input, db) {
   var ac = this;
   this.input = input;
   this.db = db;
+  this.db.ac = this;
 
   $(this.input)
     .keydown(function (event) { return ac.onkeydown(this, event); })
     .keyup(function (event) { ac.onkeyup(this, event); })
-    .blur(function () { ac.hidePopup(); ac.db.cancel(); });
+    .blur(function () { ac.db.cancel(); });
 
 };
 
@@ -299,6 +302,7 @@ Drupal.ACDB.prototype.search = function 
  * Cancels the current autocomplete request.
  */
 Drupal.ACDB.prototype.cancel = function () {
+  this.db.hidePopup();
   if (this.owner) this.owner.setStatus('cancel');
   if (this.timer) clearTimeout(this.timer);
   this.searchString = '';
Index: modules/profile/profile.test
===================================================================
RCS file: /cvs/drupal/drupal/modules/profile/profile.test,v
retrieving revision 1.23
diff -u -p -r1.23 profile.test
--- modules/profile/profile.test	20 Nov 2009 04:15:15 -0000	1.23
+++ modules/profile/profile.test	7 Jan 2010 02:54:48 -0000
@@ -335,12 +335,11 @@ class ProfileTestAutocomplete extends Pr
     $this->setProfileField($field, $field['value']);
 
     // Set some html for what we want to see in the page output later.
-    $autocomplete_html = '<input class="autocomplete" type="hidden" id="' . drupal_html_id('edit-' . $field['form_name'] . '-autocomplete') . '" value="' . url('profile/autocomplete/' . $field['fid'], array('absolute' => TRUE)) . '" disabled="disabled" />';
     $field_html = '<input type="text" maxlength="255" name="' . $field['form_name'] . '" id="' . drupal_html_id('edit-' . $field['form_name']) . '" size="60" value="' . $field['value'] . '" class="form-text form-autocomplete required" />';
 
     // Check that autocompletion html is found on the user's profile edit page.
     $this->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);
-    $this->assertRaw($autocomplete_html, t('Autocomplete found.'));
+    $this->assertRaw('"Drupal.ACDB":[', t('Autocomplete found.'));
     $this->assertRaw('misc/autocomplete.js', t('Autocomplete JavaScript found.'));
     $this->assertRaw('class="form-text form-autocomplete"', t('Autocomplete form element class found.'));
 
@@ -356,7 +355,7 @@ class ProfileTestAutocomplete extends Pr
 
     // Check that autocompletion html is not found on the user's profile edit page.
     $this->drupalGet('user/' . $this->normal_user->uid . '/edit/' . $category);
-    $this->assertNoRaw($autocomplete_html, t('Autocomplete not found.'));
+    $this->assertNoRaw('"Drupal.ACDB":[', t('Autocomplete not found.'));
 
     // User should be denied access to the profile autocomplete path.
     $this->drupalGet('profile/autocomplete/' . $field['fid'] . '/' . $field['value'][0]);
