? .project
? sites/all/themes/.DS_Store
? sites/default/.DS_Store
Index: misc/ahah.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/ahah.js,v
retrieving revision 1.15
diff -u -p -r1.15 ahah.js
--- misc/ahah.js	27 Apr 2009 20:19:35 -0000	1.15
+++ misc/ahah.js	10 Jul 2009 14:44:04 -0000
@@ -13,6 +13,8 @@
  * to provide AHAH capabilities.
  */
 
+Drupal.ahah = Drupal.ahah || {};
+
 /**
  * Attaches the ahah behavior to each ahah form element.
  */
@@ -24,7 +26,7 @@ Drupal.behaviors.ahah = {
 
         $(element_settings.selector).each(function () {
           element_settings.element = this;
-          var ahah = new Drupal.ahah(base, element_settings);
+          Drupal.ahah[base] = new Drupal.ahah(base, element_settings);
         });
 
         $('#' + base).addClass('ahah-processed');
@@ -35,6 +37,24 @@ Drupal.behaviors.ahah = {
 
 /**
  * AHAH object.
+ *
+ * All AHAH objects on a page are accessible through the global Drupal.ahah object
+ * and are keyed by the submit button's ID. You can access them from your module's
+ * JavaScript file to override properties or functions.
+ * For example, if your AHAH enabled button has the ID 'edit-submit', you can
+ * redefine the function that is called to insert the new content like this
+ * (inside a Drupal.behaviors attach block):
+ * @code
+ *    Drupal.behaviors.myCustomAhahStuff = {
+ *      attach: function(context, settings) {
+ *        Drupal.ahah['edit-submit'].insertNewContent = function(response, status) {
+ *          new_content = $(response.data);
+ *          $('#my-wrapper').append(new_content);
+ *          alert('New content was appended to #my-wrapper');
+ *        }
+ *      }
+ *    };
+ * @endcode
  */
 Drupal.ahah = function (base, element_settings) {
   // Set the properties for this object.
@@ -149,11 +169,7 @@ Drupal.ahah.prototype.beforeSubmit = fun
  * Handler for the form redirection completion.
  */
 Drupal.ahah.prototype.success = function (response, status) {
-  var wrapper = $(this.wrapper);
   var form = $(this.element).parents('form');
-  // Manually insert HTML into the jQuery object, using $() directly crashes
-  // Safari with long string lengths. http://dev.jquery.com/ticket/1152
-  var new_content = $('<div></div>').html(response.data);
 
   // Restore the previous action and target to the form.
   form.attr('action', this.form_action);
@@ -169,8 +185,25 @@ Drupal.ahah.prototype.success = function
   }
   $(this.element).removeClass('progress-disabled').attr('disabled', false);
 
-  // Add the new content to the page.
   Drupal.freezeHeight();
+
+  // Call the insertNewContent handler to insert the new content into the page.
+  this.insertNewContent(response, status);
+
+  Drupal.unfreezeHeight();
+};
+
+/**
+ * Handler to insert the new content into the page.
+ */
+Drupal.ahah.prototype.insertNewContent = function (response, status) {
+  var wrapper = $(this.wrapper);
+
+  // Manually insert HTML into the jQuery object, using $() directly crashes
+  // Safari with long string lengths. http://dev.jquery.com/ticket/1152
+  var new_content = $('<div></div>').html(response.data);
+
+  // Add the new content to the page.
   if (this.method == 'replace') {
     wrapper.empty().append(new_content);
   }
@@ -199,8 +232,6 @@ Drupal.ahah.prototype.success = function
   if (new_content.parents('html').length > 0) {
     Drupal.attachBehaviors(new_content);
   }
-
-  Drupal.unfreezeHeight();
 };
 
 /**
