src/hg/js/hui.js 1.52

1.52 2010/04/30 00:27:21 tdreszer
Support for javascript to tie view level and subtrack level controls together in hgTrackUi
Index: src/hg/js/hui.js
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/js/hui.js,v
retrieving revision 1.51
retrieving revision 1.52
diff -b -B -U 4 -r1.51 -r1.52
--- src/hg/js/hui.js	27 Apr 2010 00:17:23 -0000	1.51
+++ src/hg/js/hui.js	30 Apr 2010 00:27:21 -0000	1.52
@@ -411,27 +411,41 @@
     }
 }
 
 /////////////////// subtrack configuration support ////////////////
-
 function compositeCfgUpdateSubtrackCfgs(inp)
 {
 // Updates all subtrack configuration values when the composite cfg is changed
+    // If view association then find it:
+    var view = "";
+    var daddy = $(inp).parents(".blueBox");
+    if(daddy.length == 1) {
+        var classList = $(daddy[0]).attr("class").split(" ");
+        if(classList.length == 2) {
+            view = classList[1];
+        }
+    }
     var suffix = inp.name.substring(inp.name.indexOf("."));  // Includes '.'
     //if(suffix.length==0)
     //    suffix = inp.name.substring(inp.name.indexOf("_"));
     if(suffix.length==0) {
-        alert("Unable to parse '"+inp.name+"'");
+        warn("Unable to parse '"+inp.name+"'");
         return true;
     }
     if(inp.type.indexOf("select") == 0) {
         var list = $("select[name$='"+suffix+"']").not("[name='"+inp.name+"']"); // Exclude self from list
+        if(view != "") { list =  $(list).filter(function(index) { return $(this).parents(".blueBox." + view).length == 1; });}
         if($(list).length>0) {
             if(inp.multiple != true)
                 $(list).attr('selectedIndex',inp.selectedIndex);
             else {
-                $(list).each(function() {  // for all dependent (subtrack) multi-selects
+                $(list).each(function(view) {  // for all dependent (subtrack) multi-selects
                     sel = this;
+                    if(view != "") {
+                        var hasClass = $(this).parents(".blueBox." + view);
+                        if(hasClass.length != 0)
+                            return;
+                    }
                     $(this).children('option').each(function() {  // for all options of dependent mult-selects
                         $(this).attr('selected',$(inp).children('option:eq('+this.index+')').attr('selected')); // set selected state to independent (parent) selected state
                     });
                     $(this).attr('size',$(inp).attr('size'));
@@ -440,19 +454,22 @@
         }
     }
     else if(inp.type.indexOf("checkbox") == 0) {
         var list = $("checkbox[name$='"+suffix+"']").not("[name='"+inp.name+"']"); // Exclude self from list
+        if(view != "") { list =  $(list).filter(function(index) { return $(this).parents(".blueBox." + view).length == 1; });}
         if($(list).length>0)
             $(list).attr("checked",$(inp).attr("checked"));
     }
     else if(inp.type.indexOf("radio") == 0) {
         var list = $("input:radio[name$='"+suffix+"']").not("[name='"+inp.name+"']");
         list = $(list).filter("[value='"+inp.value+"']")
+        if(view != "") { list =  $(list).filter(function(index) { return $(this).parents(".blueBox." + view).length == 1; });}
         if($(list).length>0)
             $(list).attr("checked",true);
     }
     else {  // Various types of inputs
         var list = $("input[name$='"+suffix+"']").not("[name='"+inp.name+"']");//.not("[name^='boolshad.']"); // Exclude self from list
+        if(view != "") { list =  $(list).filter(function(index) { return $(this).parents(".blueBox." + view).length == 1; });}
         if($(list).length>0)
             $(list).val(inp.value);
         //else {
         //    alert("Unsupported type of multi-level cfg setting type='"+inp.type+"'");