Index: popups.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/popups/popups.js,v
retrieving revision 1.9.2.15
diff -u -r1.9.2.15 popups.js
--- popups.js	17 Nov 2008 23:51:49 -0000	1.9.2.15
+++ popups.js	19 Nov 2008 00:02:22 -0000
@@ -91,7 +91,7 @@
          'popup_submit': {title: Drupal.t('Continue'), func: function(){Drupal.popups.removePopup(); Drupal.popups.openPath(element, options);}},
          'popup_cancel': {title: Drupal.t('Cancel'), func: Drupal.popups.close}
         };
-        return Drupal.popups.open( Drupal.t('Warning: Please Confirm'), body, buttons );
+        return Drupal.popups.open( Drupal.t('Warning: Please Confirm'), body, buttons, this);
       }
       else {
         return Drupal.popups.openPath(element, options);
@@ -323,7 +323,7 @@
     dataType: 'json',
     beforeSend: Drupal.popups.beforeSend,
     success: function(json) { 
-      Drupal.popups.openContent(json.title, json.messages + json.content, options);
+      Drupal.popups.openContent(json.title, json.messages + json.content, options, element);
     },
     complete: function() {
       $('body').css("cursor", "auto"); // Return the cursor to normal state.      
@@ -372,8 +372,10 @@
  *   HTML to show in the popups.
  * @param options
  *   Hash of options controlling how the popups interacts with the underlying page.
+ * @param a
+ *   The link that was clicked to open this popup.
  */
-Drupal.popups.openContent = function(title, content, options) {
+Drupal.popups.openContent = function(title, content, options, a) {
   Drupal.popups.open(title, content, null, options.width); 
   // Add behaviors to content in popups. 
   // TODO: d-n-d: need to click to let go of selection.
@@ -391,7 +393,7 @@
       beforeSubmit: Drupal.popups.beforeSubmit,
       beforeSend: Drupal.popups.beforeSend,
       success: function(response, status) {
-        Drupal.popups.formSuccess(response, options);
+        Drupal.popups.formSuccess(response, options, a);
       },
       error: function() {
         Drupal.popups.message("Bad Response form submission");
@@ -426,8 +428,10 @@
  *     nonModal: bool, does the popups block access to the underlying page.
  *     targetSelectors: hash of jQuery selectors, overrides defaultTargetSelector.
  *     titleSelectors: array of jQuery selectors, where to put the the new title of the page.
+ * @param a
+ *   A DOM Object containing the link that was clicked to initiate the popup.
  */
-Drupal.popups.formSuccess = function(data, options) {  
+Drupal.popups.formSuccess = function(data, options, a) {  
   // Determine if we are at an end point, or just moving from one popups to another.
   var done = (data.path === Drupal.settings.popups.originalPath) || (data.path === options.forceReturn);
   if (!done) { // Not done yet, so show new page in new popups.
@@ -435,6 +439,13 @@
     Drupal.popups.openContent(data.title, data.messages + data.content, options);
   }
   else { // Done.
+    if (options.afterSubmit) { // Execute an afterSubmit callback if available.
+      var afterSubmitResult = eval(options.afterSubmit +'(data, options, a)');
+      if (afterSubmitResult == false) {
+        return;
+      }
+    }
+
     if (options.reloadWhenDone) { // Force a non-ajax, complete reload of the page.
       location.reload(); 
     }
