77dc06c4bdc5e10f5d2705a51300ec028a7d785f
tdreszer
  Fri Oct 1 10:51:48 2010 -0700
FindTracks now finds superTracks (Advanced only) and hgTrackUi now does superTrack reshaping when children have vis changed
diff --git src/hg/js/hgTracks.js src/hg/js/hgTracks.js
index 35e5889..79b859a 100644
--- src/hg/js/hgTracks.js
+++ src/hg/js/hgTracks.js
@@ -1576,7 +1576,7 @@
             var url = "hgTrackUi?hgsid=" + getHgsid() + "&g=";
             var id = selectedMenuItem.id;
             var rec = trackDbJson[id];
-            if (rec.parentTrack && rec.hasChildren == 0)
+            if (tdbHasParent(rec) && tdbIsLeaf(rec))
                 url += rec.parentTrack
             else
                 url = selectedMenuItem.id;
@@ -1792,7 +1792,7 @@
             if(selectedMenuItem) {
             // Add cfg options at just shy of end...
             var o = new Object();
-            if(rec.hasChildren == 0) {
+            if(tdbIsLeaf(rec)) {
                 o["configure "+rec.shortLabel] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_popup"); return true; }};
                 if(rec.parentTrack != undefined)
                     o["configure "+rec.parentLabel+" track set..."] = {onclick: function(menuItemClicked, menuObject) { contextMenuHit(menuItemClicked, menuObject, "hgTrackUi_follow"); return true; }};
@@ -1905,7 +1905,7 @@
 function hgTrackUiPopCfgOk(popObj, trackName)
 { // When hgTrackUi Cfg popup closes with ok, then update cart and refresh parts of page
     var rec = trackDbJson[trackName];
-    var subtrack = rec.isSubtrack ? trackName :undefined;  // If subtrack then vis rules differ
+    var subtrack = tdbIsSubtrack(rec) ? trackName :undefined;  // If subtrack then vis rules differ
     var allVars = getAllVars($('#pop'), subtrack );
     var changedVars = varHashChanges(allVars,popSaveAllVars);
     //warn("cfgVars:"+varHashToQueryString(changedVars));
@@ -1964,7 +1964,7 @@
                                     $(this).dialog("close");
                                }},
                                open: function() {
-                                    var subtrack = trackDbJson[popUpTrackName].isSubtrack ? popUpTrackName :"";  // If subtrack then vis rules differ
+                                    var subtrack = tdbIsSubtrack(trackDbJson[popUpTrackName]) ? popUpTrackName :"";  // If subtrack then vis rules differ
                                     popSaveAllVars = getAllVars( $('#pop'), subtrack );
                                },
                                close: function() {
@@ -2194,20 +2194,20 @@
     var visName = $(seenVis).attr('id');
     var trackName = visName.substring(0,visName.length - "_id".length)
     var hiddenVis = $("input[name='"+trackName+"']");
-    var rec = trackDbJson[trackName];
+    var tdb = tdbGetJsonRecord(trackName);
     if($(seenVis).val() != "hide")
         $(hiddenVis).val($(seenVis).val());
     else {
         var selCb = $("input#"+trackName+"_sel_id");
         $(selCb).attr('checked',false);  // Can't set it to [] because that means default setting is used.  However, we are explicitly hiding this!
         $(seenVis).attr('disabled',true);  // Can't set it to [] because that means default setting is used.  However, we are explicitly hiding this!
-        var needSel = (rec.parentTrack != undefined);
+        var needSel = (tdb.parentTrack != undefined);
         if (needSel) {
             var hiddenSel = $("input[name='"+trackName+"_sel']");
             $(hiddenSel).val('0');  // Can't set it to [] because that means default setting is used.  However, we are explicitly hiding this!
             $(hiddenSel).attr('disabled',false);
         }
-        if(rec.isSubtrack)
+        if(tdbIsSubtrack(tdb))
             $(hiddenVis).val("[]");
         else
             $(hiddenVis).val("hide");
@@ -2224,10 +2224,10 @@
     var seenVis = $('select#' + trackName + "_id");
     var hiddenVis = $("input[name='"+trackName+"']");
     var tr = $(selCb).parents('tr.found');
-    var rec = trackDbJson[trackName];
-    var needSel = (rec.parentTrack != undefined);
-    var shouldPack = rec.canPack;
-    if (shouldPack && rec.shouldPack != undefined && !rec.shouldPack)
+    var tdb = tdbGetJsonRecord(trackName);
+    var needSel = (tdb.parentTrack != undefined);
+    var shouldPack = tdb.canPack;
+    if (shouldPack && tdb.shouldPack != undefined && !tdb.shouldPack)
         shouldPack = false;
     var checked = $(selCb).attr('checked');
     //warn(trackName +" selName:"+selName +" justClicked:"+justClicked +" hiddenSel:"+$(hiddenSel).attr('name') +" seenVis:"+$(seenVis).attr('id') +" hiddenVis:"+$(hiddenVis).attr('name') +" needSel:"+needSel +" shouldPack:"+shouldPack);
@@ -2236,7 +2236,9 @@
     if(checked) {
         $(seenVis).attr('disabled', false);
         if($(seenVis).attr('selectedIndex') == 0) {
-            if(shouldPack)
+            if(tdbIsFolder(tdb))
+                $(seenVis).attr('selectedIndex',1);  // show
+            else if(shouldPack)
                 $(seenVis).attr('selectedIndex',3);  // packed  // FIXME: Must be a better way to select pack/full
             else
                 $(seenVis).attr('selectedIndex',$(seenVis).attr('length') - 1);
@@ -2260,7 +2262,7 @@
     if(setHiddenInputs) {
         if(checked)
             $(hiddenVis).val($(seenVis).val());
-        else if(rec.isSubtrack)
+        else if(tdbIsSubtrack(tdb))
             $(hiddenVis).val("[]");
         else
             $(hiddenVis).val("hide");
