? ___form_builder___js___PaQNOn
Index: form_builder.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/form_builder/form_builder.js,v
retrieving revision 1.23
diff -u -p -r1.23 form_builder.js
--- form_builder.js	30 Dec 2010 17:09:05 -0000	1.23
+++ form_builder.js	30 Dec 2010 20:05:46 -0000
@@ -53,7 +53,7 @@ Drupal.behaviors.formBuilderElement.atta
 Drupal.behaviors.formBuilderFields = {};
 Drupal.behaviors.formBuilderFields.attach = function(context) {
   // Bind a function to all elements to update the preview on change.
-  var $configureForm = $('#form-builder-field-configure');
+  var $configureForm = $('#form-builder-field-configure', context);
 
   $configureForm.find('input, textarea, select')
     .not('.form-builder-field-change)')
@@ -304,18 +304,19 @@ Drupal.formBuilder.disableField = functi
  */
 Drupal.formBuilder.editField = function() {
   var element = $(this).parents('div.form-builder-wrapper').get(0);
-  var link = this;
+  var link = $(this);
 
   // Prevent duplicate clicks from taking effect if already handling a click.
   if (Drupal.formBuilder.updatingElement) {
     return false;
   }
 
+  link.addClass('progress');
+
   // If clicking on the link a second time, close the form instead of open.
-  if (element == Drupal.formBuilder.activeElement && link == Drupal.formBuilder.activeLink) {
-    $(link).addClass('progress');
+  if (element == Drupal.formBuilder.activeElement && link.get(0) == Drupal.formBuilder.activeLink) {
     Drupal.formBuilder.closeActive(function() {
-      $(link).removeClass('progress');
+      link.removeClass('progress');
     });
     Drupal.formBuilder.unsetActive();
     return false;
@@ -331,10 +332,9 @@ Drupal.formBuilder.editField = function(
     });
   };
 
-  $(link).addClass('progress');
   Drupal.formBuilder.updatingElement = true;
   Drupal.formBuilder.closeActive(getForm);
-  Drupal.formBuilder.setActive(element, link);
+  Drupal.formBuilder.setActive(element, link.get(0));
 
   return false;
 };
@@ -502,15 +502,15 @@ Drupal.formBuilder.addElement = function
  */
 Drupal.formBuilder.updateElementPosition = function(element) {
   // Update weights of all children within this element's parent.
-  $(element).parent().children('div.form-builder-wrapper').each(function(index) {
+  element.parent().children('div.form-builder-wrapper').each(function(index) {
     var child_id = $(this).children('div.form-builder-element:first').attr('id');
     $('#form-builder-positions input.form-builder-weight').filter('.' + child_id).val(index);
   });
 
   // Update this element's parent.
-  var $parent = $(element).parents('div.form-builder-element:first');
+  var $parent = element.parents('div.form-builder-element:first');
   var parent_id = $parent.length ? $parent.attr('id').replace(/form-builder-element-(.*)/, '$1') : 0;
-  var child_id = $(element).children('div.form-builder-element:first').attr('id');
+  var child_id = element.children('div.form-builder-element:first').attr('id');
   $('#form-builder-positions input.form-builder-parent').filter('.' + child_id).val(parent_id);
 
   // Submit the position form via AJAX to save the new weights and parents.
@@ -538,13 +538,13 @@ Drupal.formBuilder.startDrag = function(
  *   The jQuery Sortables object containing information about the sortable.
  */
 Drupal.formBuilder.stopDrag = function(e, ui) {
-  var element = ui.item.get(0);
+  var element = ui.item;
 
   // If the element is a new field from the palette, update it with a real field.
-  if ($(element).is('.ui-draggable')) {
+  if (element.is('.ui-draggable')) {
     var name = 'new_' + new Date().getTime();
     // If this is a "unique" element, its element ID is hard-coded.
-    if ($(element).is('.form-builder-unique')) {
+    if (element.is('.form-builder-unique')) {
       name = element.className.replace(/^.*?form-builder-element-([a-z0-9_]+).*?$/, '$1');
     }
 
@@ -582,8 +582,9 @@ Drupal.formBuilder.stopDrag = function(e
  *   The jQuery Sortables object containing information about the sortable.
  */
 Drupal.formBuilder.startPaletteDrag = function(e, ui) {
-  if ($(this).is('.form-builder-unique')) {
-    $(this).css('visibility', 'hidden');
+  var $this = $(this);
+  if ($this.is('.form-builder-unique')) {
+    $this.css('visibility', 'hidden');
   }
 
   Drupal.formBuilder.activeDragUi = ui;
@@ -598,17 +599,18 @@ Drupal.formBuilder.startPaletteDrag = fu
  *   The jQuery Sortables object containing information about the sortable.
  */
 Drupal.formBuilder.stopPaletteDrag = function(e, ui) {
+  var $this = $(this);
   // If the activeDragUi is still set, we did not drop onto the form.
   if (Drupal.formBuilder.activeDragUi) {
     ui.helper.remove();
     Drupal.formBuilder.activeDragUi = false;
-    $(this).css('visibility', '');
+    $this.css('visibility', '');
     $(window).scroll();
   }
   // If dropped onto the form and a unique field, remove it from the palette.
-  else if ($(this).is('.form-builder-unique')) {
-    $(this).animate({ height: '0', width: '0' }, function() {
-      $(this).css({ visibility: '', height: '', width: '', display: 'none' });
+  else if ($this.is('.form-builder-unique')) {
+    $this.animate({ height: '0', width: '0' }, function() {
+      $this.css({ visibility: '', height: '', width: '', display: 'none' });
     });
   }
 };
@@ -624,25 +626,25 @@ Drupal.formBuilder.stopPaletteDrag = fun
  *   The jQuery Sortables object containing information about the sortable.
  */
 Drupal.formBuilder.elementIndent = function(e, ui) {
-  var placeholder = ui.placeholder.get(0);
-  var helper = ui.helper.get(0);
-  var item = ui.item.get(0);
+  var placeholder = ui.placeholder;
+  var helper = ui.helper;
+  var item = ui.item;
 
   // Do not affect the elements being dragged from the pallette.
-  if ($(item).is('li')) {
+  if (item.is('li')) {
     return;
   }
 
   // Turn on the placeholder item (which is in the final location) to take some stats.
-  $(placeholder).css('visibility', 'visible');
-  var difference = $(helper).width() - $(placeholder).width();
-  var offset = $(placeholder).offset().left;
-  $(placeholder).css('visibility', 'hidden');
+  placeholder.css('visibility', 'visible');
+  var difference = helper.width() - placeholder.width();
+  var offset = placeholder.offset().left;
+  placeholder.css('visibility', 'hidden');
 
   // Adjust the helper to match the location and width of the real item.
-  var newWidth = $(helper).width() - difference;
-  $(helper).css('width', newWidth + 'px');
-  $(helper).css('left', offset + 'px');
+  var newWidth = helper.width() - difference;
+  helper.css('width', newWidth + 'px');
+  helper.css('left', offset + 'px');
 };
 
 /**
@@ -658,7 +660,7 @@ Drupal.formBuilder.elementIndent = funct
  * @param
  */
 Drupal.formBuilder.checkFieldsets = function(e, ui, expand) {
-  var $fieldsets = $('#form-builder').find('div.form-builder-element > fieldset.form-builder-fieldset');
+  var $fieldsets = $('#form-builder div.form-builder-element > fieldset.form-builder-fieldset');
   var emptyFieldsets = [];
 
   // Remove all current fieldset placeholders.
@@ -666,14 +668,15 @@ Drupal.formBuilder.checkFieldsets = func
 
   // Find all empty fieldsets.
   $fieldsets.each(function() {
+    var $this = $(this);
     // Check for empty collapsible fieldsets.
-    if ($(this).children('div.fieldset-wrapper').length) {
-      if ($(this).children('div.fieldset-wrapper').children(':not(.description):visible, .ui-sortable-placeholder').length == 0) {
+    if ($this.children('div.fieldset-wrapper').length) {
+      if ($this.children('div.fieldset-wrapper').children(':not(.description):visible, .ui-sortable-placeholder').length == 0) {
         emptyFieldsets.push(this);
       }
     }
     // Check for empty normal fieldsets.
-    if ($(this).children(':not(legend, .description):visible, .ui-sortable-placeholder').length == 0) {
+    if ($this.children(':not(legend, .description):visible, .ui-sortable-placeholder').length == 0) {
       emptyFieldsets.push(this);
     }
   });
