Index: popups.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/popups/popups.js,v
retrieving revision 1.9
diff -u -r1.9 popups.js
--- popups.js	6 Mar 2008 20:32:50 -0000	1.9
+++ popups.js	1 Apr 2008 21:02:05 -0000
@@ -15,7 +15,7 @@
  *   body = Drupal.t("There are unsaved changes on this page.");
  *   buttons = {
  *    'popups_save': { title: Drupal.t('Save Changes'), func: function(){$('#edit-submit').click()} },
- *    'popups_submit': { title: Drupal.t('Discard Changes and Continue'), func: function(){window.location = a.href} },
+ *    'popups_submit': { title: Drupal.t('Discard Changes and Continue'), func: function(){window.location = elt.href} },
  *    'popups_cancel': { title: Drupal.t('Cancel'), func: this.close }
  *  };
  *  this.open( "Warning - Please Confirm", body, buttons );
@@ -310,7 +310,7 @@
   var popups = this;
   $(link, context).not('.popups-processed').each( function() {
     $(this).click( function(e){ 
-      var a = this;
+      var elt = this;
       // If the option is distructive, check if the page is already modified, and offer to save.
       var page_is_dirty = $('span.tabledrag-changed').size() > 0;
       var will_modify_original = !options.noReload && !options.singleRow;
@@ -318,14 +318,14 @@
         // The user will lose modifications, so popup dialog offering to save current state.
         var body = Drupal.t("There are unsaved changes on this page, which you will lose if you continue.");
         var buttons = {
-         'popups_save': {title: Drupal.t('Save Changes'), func: function(){popups.save_page(a, options)}},
-         'popups_submit': {title: Drupal.t('Continue'), func: function(){Drupal.popups.close(); popups.open_path(a, options)}},
+         'popups_save': {title: Drupal.t('Save Changes'), func: function(){popups.save_page(elt, options)}},
+         'popups_submit': {title: Drupal.t('Continue'), func: function(){Drupal.popups.close(); popups.open_path(elt, options)}},
          'popups_cancel': {title: Drupal.t('Cancel'), func: Drupal.popups.close}
         };
         return popups.open( Drupal.t('Warning: Please Confirm'), body, buttons );
       }
       else {
-        return popups.open_path(a, options);
+        return popups.open_path(elt, options);
       } 
     });
     $(this).addClass('popups-processed');
@@ -359,7 +359,7 @@
  * @param a - link that was clicked.
  * @param options - options associated with the link.
  */
-Drupal.popups.prototype.open_path = function( a, options ) {
+Drupal.popups.prototype.open_path = function( elt, options ) {
   var popup = this;
   // let the user know something is happening
   $('body').css("cursor", "wait");
@@ -367,19 +367,20 @@
   Drupal.popups.add_loading();
 
 //  var type = options.type ? options.type : 'json'; // Default to json.
-  var url = Drupal.popups.prepUrl(a.href); 
+  var href = options.href ? options.href : elt.href;
+  var url = Drupal.popups.prepUrl(href);
 //  if (type=='html') { // Special handling for html.
 //    $.get(url, function(data) {  
 //      var $response = $('<div></div>');
 //      $response.html(data);
 //      var body = $response.html();
-//      popup.open_content(document.title, body, options, a);
+//      popup.open_content(document.title, body, options, elt);
 //       $('body').css("cursor", "auto"); // Return the cursor to normal state.
 //    });
 //  }
 //  else { // It is a json object from Drupal.
   $.getJSON(url, function(json) {  
-    popup.open_content(json.title, json.messages + json.content, options, a);
+    popup.open_content(json.title, json.messages + json.content, options, elt);
     $('body').css("cursor", "auto"); // Return the cursor to normal state.  
   });
 //  }
@@ -390,7 +391,7 @@
      var title = $data.find('title').text();
      var messages = $data.find('messages').text();
      var content = messages + $data.find('content').text();
-     popup.open_content(title, content, options, a);
+     popup.open_content(title, content, options, elt);
      $('body').css("cursor", "auto"); // Return the cursor to normal state.
     }
     else { // Not XML, so show entire HTML page in popup.
@@ -402,7 +403,7 @@
 //      Drupal.popups.message('Error: Bad response.', msg);
 //      Drupal.popups.remove_loading();
       var title = document.title;
-      popup.open_content(title, body, options, a);
+      popup.open_content(title, body, options, elt);
       $('body').css("cursor", "auto"); // Return the cursor to normal state.
     }
   });   
@@ -411,7 +412,7 @@
 };
 
 
-Drupal.popups.prototype.open_content = function(title, content, options, a) {
+Drupal.popups.prototype.open_content = function(title, content, options, elt) {
   this.open(title, content); 
   // Add behaviors to content in popup. 
   // TODO: d-n-d: need to click to let go of selection.
@@ -424,7 +425,7 @@
   $form.ajaxForm({ 
     dataType: 'json',     
     beforeSubmit: Drupal.popups.beforeSubmit,
-    success: function(response, status) { Drupal.popups.formSuccess(response, options, a) },
+    success: function(response, status) { Drupal.popups.formSuccess(response, options, elt) },
   });
 }
 
@@ -448,7 +449,7 @@
  * @param options - hash of per link options.
  * @param a - the link that was clicked.
  */
-Drupal.popups.formSuccess = function (response, options, a) {
+Drupal.popups.formSuccess = function (response, options, elt) {
   var $data = $(response);
   if ($data.size() > 1) { // Bad html response, show an error message.
     var $response = $('<div></div>');
@@ -475,7 +476,7 @@
 //      var content = $data.find('content').text();
       Drupal.popups.remove_loading();
       var popups = new Drupal.popups();     
-      popups.open_content(data.title, data.messages + data.content, options, a);
+      popups.open_content(data.title, data.messages + data.content, options, elt);
     }
     else { // Done, so show messages in dialog and embed the results in the original page.
       if (data.messages) {
@@ -490,7 +491,7 @@
       // Just update a single row out of a table (still expiremental). 
       // Loop through, with special case for first element.
       if (options.singleRow) {
-        var href = $(a).attr('href');
+        var href = options.href ? options.href : $(elt).attr('href');
         var selector = 'table a[href=' + href + ']';
         var $new_row = $data.find(selector).parents('tr'); // new tr
         var $target_row = $(selector).parents('tr'); // target tr.
@@ -549,7 +550,7 @@
  * @param a - link that was clicked.
  * @param options - options associated with the link.
  */
-Drupal.popups.prototype.save_page = function(a, options) {
+Drupal.popups.prototype.save_page = function(elt, options) {
   var popups = this;
   // TODO - what if clicking on link with option['targetSelector']?
   var target = Drupal.settings.popups.defaultTargetSelector;
@@ -564,7 +565,7 @@
       Drupal.attachBehaviors($c);
       Drupal.popups.close();
       // The form has been saved, the page reloaded, now safe to show the link in a popup.
-      popups.open_path(a, options); 
+      popups.open_path(elt, options); 
     }     
   };
   $form.ajaxSubmit( ajaxOptions ); // Submit the form. 

