Index: misc/tabledrag.js
===================================================================
RCS file: /cvs/drupal/drupal/misc/tabledrag.js,v
retrieving revision 1.29
diff -u -p -r1.29 tabledrag.js
--- misc/tabledrag.js	10 Jun 2009 05:06:57 -0000	1.29
+++ misc/tabledrag.js	24 Aug 2009 03:06:25 -0000
@@ -92,6 +92,11 @@ Drupal.tableDrag = function (table, tabl
   // Hide columns containing affected form elements.
   this.hideColumns();
 
+  // Add a link after the table to show/hide this column 
+  var showhide = '<a href="#" class="showhide">' + Drupal.t('Show/hide weight fields') +'</a><br/>';
+  $(this.table).after(showhide);
+  $('a.showhide').click(function () { self.showHideColumns(self); return false; });
+
   // Add mouse bindings to the document. The self variable is passed along
   // as event handlers do not have direct access to the tableDrag object.
   $(document).bind('mousemove', function (event) { return self.dragRow(event, self); });
@@ -115,7 +120,7 @@ Drupal.tableDrag.prototype.hideColumns =
     }
 
     // Hide the column containing this field.
-    if (hidden && cell[0] && cell.css('display') != 'none') {
+    if (hidden && cell[0]) {
       // Add 1 to our indexes. The nth-child selector is 1 based, not 0 based.
       // Match immediate children of the parent element to allow nesting.
       var columnIndex = $('> td', cell.parent()).index(cell.get(0)) + 1;
@@ -135,20 +140,45 @@ Drupal.tableDrag.prototype.hideColumns =
           cell = row.children(':nth-child(' + index + ')');
           if (cell[0].colSpan > 1) {
             // If this cell has a colspan, simply reduce it.
-            cell[0].colSpan = cell[0].colSpan - 1;
+            cell[0].addClass('tabledrag-reduced-colspan').colSpan = cell[0].colSpan - 1;
           }
           else {
             // Hide table body cells, but remove table header cells entirely
             // (Safari doesn't hide properly).
-            parentTag == 'thead' ? cell.remove() : cell.css('display', 'none');
+            parentTag == cell.css('display', 'none').addClass('tabledrag-display-none');
           }
         }
       });
     }
+
   }
 };
 
 /**
+ * Un-hide the columns containing form elements according to the settings for
+ * this tableDrag instance. Undo hideColumns().
+ */
+Drupal.tableDrag.prototype.unHideColumns = function () {
+  // Add colspan back where it was reduced
+  $('.tabledrag-reduced-colspan').each( function() { this.colSpan = this.colSpan + 1; } );
+  // Set display block where it was display:none
+  $('.tabledrag-display-none').css('display', 'block');
+}
+
+/**
+ * Show or hide the columns by calling unHideColumns() or hideColumns().
+ */
+Drupal.tableDrag.prototype.showHideColumns = function (self) {
+  if (self.unHiddenColumns) {
+    self.hideColumns()
+    self.unHiddenColumns = false;
+  } else {
+    self.unHideColumns();
+    self.unHiddenColumns = true;
+  }
+}
+
+/**
  * Find the target used within a particular row and group.
  */
 Drupal.tableDrag.prototype.rowSettings = function (group, row) {
