src/hg/js/hui.js 1.40

1.40 2009/10/21 19:14:52 tdreszer
Made vis changes work on 3-way matCBs
Index: src/hg/js/hui.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hui.js,v
retrieving revision 1.39
retrieving revision 1.40
diff -b -B -U 4 -r1.39 -r1.40
--- src/hg/js/hui.js	21 Oct 2009 15:48:50 -0000	1.39
+++ src/hg/js/hui.js	21 Oct 2009 19:14:52 -0000	1.40
@@ -20,8 +20,20 @@
 // views are "select" drop downs on a subtrack configuration page
     if( obj.selectedIndex == 0) { // hide
         matSubCBsEnable(false,view);
         hideConfigControls(view);
+
+        // fix 3-way matCBs if necessary
+        var matCBs = matCBsWhichAreComplete(false);
+        if(matCBs.length > 0) {
+            if($("select.viewDD[selectedIndex]").length == 0) {// No views visible so nothing is inconsistent
+                $( matCBs ).each( function (i) { matCbComplete( this, true ); });
+            } else {
+                var classes = matViewClasses('hidden');
+                classes = classes.concat( matZeeCBclasses('unchecked') );
+                $( matCBs ).each( function (i) { matChkBoxNormalize( this, classes ); });
+            }
+        }
     } else {
         // Make main display dropdown show full if currently hide
         compositeName = obj.name.substring(0,obj.name.indexOf(".")); // {trackName}.{view}.vis
         exposeComposite(compositeName);
@@ -105,19 +117,18 @@
         classList = classes.split(" ");
     if(classList.length == 0 )
        matSubCBsCheck(matCB.checked);
     else if(classList.length == 1 )
-       matSubCBsCheck(matCB.checked,classList[0]);
+       matSubCBsCheck(matCB.checked,classList[0]);               // dimX or dimY or dimZ
     else if(classList.length == 2 )
-       matSubCBsCheck(matCB.checked,classList[0],classList[1]);
-    else if(classList.length == 3 )
-       matSubCBsCheck(matCB.checked,classList[0],classList[1],classList[2]); // I don't think it will ever go beyond 4
+       matSubCBsCheck(matCB.checked,classList[0],classList[1]);  // dimX and dimY
     else
-       matSubCBsCheck(matCB.checked,classList[0],classList[1],classList[2],classList[3]);
+        alert("ASSERT in matCbClick(): There should be no more than 2 entries in list:"+classList)
 
     if(isZee) {  // if dimZ then we may have just made indeterminate X and Ys determinate
         if(matCB.checked == false) { // checking new dimZs cannot change indeterminate state.
             var matCBs = matCBsWhichAreComplete(false);
+            if(matCBs.length > 0) {
             if($("input.matCB.dimZ:checked").length == 0)
                 $( matCBs ).each( function (i) { matCbComplete( this, true ); });
             else {
                 var classes = matViewClasses('hidden');
@@ -125,8 +136,9 @@
                 $( matCBs ).each( function (i) { matChkBoxNormalize( this, classes ); });
             }
         }
     }
+    }
 }
 
 function matSetMatrixCheckBoxes(state)
 {
@@ -301,12 +313,12 @@
         } );
     }
     $(matCBs).each( function (i) { matChkBoxNormalize(this,classes); } );
 
-    // For each viewDD not selected, disable associated subtracks
-    $('select.viewDD').not("[selectedIndex]").each( function (i) {
+    // For each viewDD, enable/disable associated subtracks
+    $('select.viewDD').each( function (i) {
         var viewClass = this.name.substring(this.name.indexOf(".") + 1,this.name.lastIndexOf("."));
-        matSubCBsEnable(false,viewClass);
+        matSubCBsEnable((this.selectedIndex > 0),viewClass);
     });
 }
 
 function matCbComplete(matCB,complete)