Index: popups.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/popups/popups.js,v
retrieving revision 1.9.8.2
diff -u -p -r1.9.8.2 popups.js
--- popups.js	21 Nov 2008 08:51:13 -0000	1.9.8.2
+++ popups.js	3 Jan 2009 20:53:39 -0000
@@ -336,7 +336,7 @@ Drupal.popups.openPath = function(elemen
     data: params,
     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);
       // Add additional CSS to the page.
       for (var type in json.css) {
         for (var file in json.css[type]) {
@@ -410,8 +410,10 @@ Drupal.popups.openPath = function(elemen
  *   HTML to show in the popups.
  * @param options
  *   Hash of options controlling how the popups interacts with the underlying page.
+ * @param element
+ *   A DOM object containing the element that was clicked to initiate the popup.
  */
-Drupal.popups.openContent = function(title, content, options) {
+Drupal.popups.openContent = function(title, content, options, element) {
   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.
@@ -428,7 +430,7 @@ Drupal.popups.openContent = function(tit
     beforeSubmit: Drupal.popups.beforeSubmit,
     beforeSend: Drupal.popups.beforeSend,
     success: function(response, status) {
-      Drupal.popups.formSuccess(response, options);
+      Drupal.popups.formSuccess(response, options, element);
     },
     error: function() {
       Drupal.popups.message("Bad Response form submission");
@@ -462,15 +464,24 @@ Drupal.popups.beforeSubmit = function(fo
  *     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 element
+ *   A DOM object containing the element that was clicked to initiate the popup. 
  */
-Drupal.popups.formSuccess = function(data, options) {  
+Drupal.popups.formSuccess = function(data, options, element) {  
   // 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.
     Drupal.popups.removeLoading();
-    Drupal.popups.openContent(data.title, data.messages + data.content, options);
+    Drupal.popups.openContent(data.title, data.messages + data.content, options, element);
   }
   else { // Done.
+    if (options.afterSubmit) { // Execute an afterSubmit callback if available.
+      var afterSubmitResult = eval(options.afterSubmit +'(data, options, element)');
+      if (afterSubmitResult == false) {
+        return;
+      }
+    }
+    
     if (options.reloadWhenDone) { // Force a non-ajax, complete reload of the page.
       location.reload(); 
     }
