? .DS_Store
? autocomplete-exchangeableACDB.patch
? includes/.DS_Store
? misc/.DS_Store
? modules/.DS_Store
? modules/system/.DS_Store
? sites/default/settings.php
Index: includes/form.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/form.inc,v
retrieving revision 1.426
diff -u -p -r1.426 form.inc
--- includes/form.inc	8 Jan 2010 06:36:34 -0000	1.426
+++ includes/form.inc	9 Jan 2010 00:12:42 -0000
@@ -2826,6 +2826,35 @@ function theme_hidden($variables) {
 }
 
 /**
+ * Add autocomplete to an element.
+ * 
+ * @param $element
+ *   An associative array containing the properties of the element.
+ *   - Properties used: #autocomplete_path.
+ *
+ * @return
+ *   The element with the additional attributes attached.
+ */
+function form_process_autocomplete($element) {
+  if (!empty($element['#autocomplete_path']) && drupal_valid_path($element['#autocomplete_path'])) {
+    $autocomplete_uri = check_url(url($element['#autocomplete_path'], array('absolute' => TRUE)));
+    $element['#attached']['js'][] = 'misc/autocomplete.js';
+    $element['#attached']['js'][] = array(
+      'data' => array(
+        'autocomplete' => array(
+          $autocomplete_uri => array(
+            'Drupal.ACDB' => array('#' . $element['#id'])
+          ),
+        ),
+      ),
+      'type' => 'setting',
+    );
+    $element['#attributes']['class'][] = 'form-autocomplete';
+  }
+  return $element;
+}
+
+/**
  * Theme a textfield form element.
  *
  * @param $variables
@@ -2847,11 +2876,6 @@ function theme_textfield($variables) {
   $extra = '';
   $output = '';
 
-  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" />';
-  }
   _form_set_class($element, $class);
 
   if (isset($element['#field_prefix'])) {
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	9 Jan 2010 00:12:42 -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 (var uri in settings.autocomplete) {
+        for (var type in settings.autocomplete[uri]) {
+          var acdb = eval('new ' + type + '(uri)');
+          for (var 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/system/system.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/system/system.module,v
retrieving revision 1.871
diff -u -p -r1.871 system.module
--- modules/system/system.module	8 Jan 2010 06:36:34 -0000	1.871
+++ modules/system/system.module	9 Jan 2010 00:12:42 -0000
@@ -353,7 +353,7 @@ function system_element_info() {
     '#size' => 60,
     '#maxlength' => 128,
     '#autocomplete_path' => FALSE,
-    '#process' => array('form_process_text_format', 'ajax_process_form'),
+    '#process' => array('form_process_text_format', 'ajax_process_form', 'form_process_autocomplete'),
     '#theme' => 'textfield',
     '#theme_wrappers' => array('form_element'),
   );
@@ -375,7 +375,7 @@ function system_element_info() {
     '#cols' => 60,
     '#rows' => 5,
     '#resizable' => TRUE,
-    '#process' => array('form_process_text_format', 'ajax_process_form'),
+    '#process' => array('form_process_text_format', 'ajax_process_form', 'form_process_autocomplete'),
     '#theme' => 'textarea',
     '#theme_wrappers' => array('form_element'),
   );
