9a71b6794ec910cbb1864bcba0a910d3995fadc3
tdreszer
  Tue Oct 25 17:38:23 2011 -0700
Long overdue checkboxes added to superTrack config page.
diff --git src/hg/js/hui.js src/hg/js/hui.js
index 2b6483e..4382e5c 100644
--- src/hg/js/hui.js
+++ src/hg/js/hui.js
@@ -86,32 +86,34 @@
         }
     }
     matSubCBsSelected();
     obj.lastIndex = obj.selectedIndex;
 }
 
 function matSelectViewForSubTracks(obj,view)
 {
     waitOnFunction( _matSelectViewForSubTracks, obj,view);
 }
 
 function exposeAll()
 {
     // Make main display dropdown show full if currently hide
     var visDD = $("select.visDD"); // limit to hidden
-    if ($(visDD).length == 1 && $(visDD).attr('selectedIndex') == 0)   // limit to hidden
+    if ($(visDD).length == 1 && $(visDD).attr('selectedIndex') == 0) {  // limit to hidden
         $(visDD).attr('selectedIndex',$(visDD).children('option').length - 1);
+        $(visDD).change();// trigger on change code, which may trigger supertrack reshaping
+    }
 }
 
 function matSubCbClick(subCB)
 {
 // subCB:onclick  When a subtrack checkbox is clicked, it may result in
 // Clicking/unclicking the corresponding matrix CB.  Also the
 // subtrack may be hidden as a result.
     matSubCBsetShadow(subCB);
     hideOrShowSubtrack(subCB);
     // When subCBs are clicked, 3-state matCBs may need to be set
     var classes = matViewClasses('hidden');
     classes = classes.concat( matAbcCBclasses(false) );
     var matCB = matCbFindFromSubCb( subCB );
     if( matCB != undefined ) {
         matChkBoxNormalize( matCB, classes );
@@ -1134,30 +1136,120 @@
             }
         });
     }
 }
 
 function tableSortAtButtonPress(anchor,tagId)
 { // Special ONLY for hgTrackUi sorting.  Others use utils.js::tableSortOnButtonPress()
     var table = $( anchor ).parents("table.sortable");
     if (table) {
         subtrackCfgHideAll(table);
         waitOnFunction( _tableSortOnButtonPressEncapsulated, anchor, tagId);
     }
     return false;  // called by link so return false means don't try to go anywhere
 }
 
+  ////////////////////
+ //// superTrack ////
+////////////////////
+var superT = {
+
+    submitAndLink: function (obj)
+    {
+        var thisForm=$(obj).parents('form');
+        if(thisForm != undefined && $(thisForm).length == 1) {
+           thisForm = thisForm[0];
+           $(thisForm).attr('action',obj.href); // just attach the straight href
+           $(thisForm).submit();
+           return false;  // should not get here!
+        }
+        return true;
+    },
+
+    topVis: function (show)
+    {
+        var superSel = $('select.visDD');
+        if (superSel != undefined && superSel.length == 1) {
+            superSel = superSel[0];
+            if (show) {
+                $(superSel).addClass('normalText');
+                $(superSel).attr('selectedIndex',1);
+                $(superSel).removeClass('hiddenText');
+            } else {
+                $(superSel).attr('selectedIndex',0);
+                $(superSel).removeClass('normalText');
+                $(superSel).addClass('hiddenText');
+            }
+        }
+    },
+
+    plusMinus: function (check)
+    {
+        $("input:checkbox").each(function (i) {
+            $(this).attr("checked",check);
+            superT.childChecked(this,1);
+            if (!check) // all are unchecked so we can hide this whole thing.
+                superT.topVis(check);
+        });
+    },
+
+    childChecked: function (cb,defaultVis)
+    {
+        var sel = $('select[name="' + cb.id + '"]');
+        if (sel != undefined && sel.length == 1) {
+            sel = sel[0];
+            var selIx = $(sel).attr('selectedIndex');
+            if (cb.checked && selIx.toString() == "0") {
+                // What can be done to more intelligently default this?
+                // All to dense?  Probably the best idea
+                // When first rendering page?  Then how to save?
+                // Logic is: from [+][-] then dense;  from cb, then full
+                if (defaultVis == undefined)
+                    defaultVis = (sel.options.length - 1); // full
+                superT.selChanged(sel,defaultVis);
+            } else if (!(cb.checked) && selIx.toString() != "0") {
+                superT.selChanged(sel,0);
+            }
+        }
+    },
+
+    selChanged: function(sel,val)
+    {
+        var selIx = val;
+        if (val == undefined) // onchange event
+            selIx = $(sel).attr('selectedIndex');
+        else // called from childChecked() so set value
+            $(sel).attr('selectedIndex',val);
+
+        if (selIx == 0) {
+            $(sel).removeClass('normalText');
+            $(sel).addClass('hiddenText');
+        } else {
+            $(sel).removeClass('hiddenText');
+            $(sel).addClass('normalText');
+            superT.topVis(true);
+        }
+        if (val == undefined) { // onchange event only
+            var cb = $('input#'+sel.name);
+            if (cb != undefined && cb.length == 1) {
+                cb = cb[0];
+                $(cb).attr('checked',(selIx > 0));
+            }
+        }
+    }
+}
+
 // The following js depends upon the jQuery library
 $(document).ready(function()
 {
     // Initialize sortable tables
     $('table.sortable').each(function (ix) {
         sortTableInitialize(this,true,true);
     });
 
     // Register tables with drag and drop
     $("table.tableWithDragAndDrop").each(function (ix) {
         tableDragAndDropRegister(this);
     });
 
     $('.halfVis').css('opacity', '0.5'); // The 1/2 opacity just doesn't get set from cgi!