c3a989e32fb4ef526070e77d7cb9bc024decf7ec
angie
  Mon Jan 10 16:49:42 2011 -0800
Moved almost all functionality of toggleTrackGroupVisibility fromhgTracks.js into utils.js's setTableRowVisibility so hgc can use it too.

diff --git src/hg/js/utils.js src/hg/js/utils.js
index 20d154f..0048d64 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -425,30 +425,64 @@
     var divit = $("#div_"+trackName+"_meta");
     if($(divit).css('display') == 'none') {
         $("#div_"+trackName+"_cfg").hide();  // Hide any configuration when opening metadata
 
         if($(divit).find('table').length == 0)
             lookupMetadata(trackName,showLonglabel,showShortLabel);
     }
     var tr = $(divit).parents('tr');
     if (tr.length > 0) {
         $(divit).children('table').css('backgroundColor',$(tr[0]).css('backgroundColor'));
     }
     $(divit).toggle();  // jQuery hide/show
     return false;
 }
 
+function setTableRowVisibility(button, prefix, hiddenPrefix, titleDesc, doAjax)
+{
+// Show or hide one or more table rows whose id's begin with prefix followed by "-".
+// This code also modifies the corresponding hidden field (cart variable) and the
+// src of the +/- img button.
+    var retval = true;
+    var hidden = $("input[name='"+hiddenPrefix+"_"+prefix+"_close']");
+    if($(button) != undefined && $(hidden) != undefined && $(hidden).length > 0) {
+        var oldSrc = $(button).attr("src");
+	var newVal;
+        if(arguments.length > 5)
+            newVal = arguments[5] ? 0 : 1;
+        else
+            newVal = oldSrc.indexOf("/remove") > 0 ? 1 : 0;
+        var newSrc;
+        if(newVal == 1) {
+            newSrc = oldSrc.replace("/remove", "/add");
+            $(button).attr('title', 'Expand this '+titleDesc);
+            $("tr[id^='"+prefix+"-']").hide();
+        } else {
+            newSrc = oldSrc.replace("/add", "/remove");
+            $(button).attr('title', 'Collapse this '+titleDesc);
+            $("tr[id^='"+prefix+"-']").show();
+        }
+        $(button).attr("src", newSrc);
+        $(hidden).val(newVal);
+	if (doAjax) {
+	    setCartVar(hiddenPrefix+"_"+prefix+"_close", newVal);
+	}
+        retval = false;
+    }
+    return retval;
+}
+
 function warnBoxJsSetup()
 {   // Sets up warnBox if not already established.  This is duplicated from htmshell.c
     var html = "";
     html += "<center>";
     html += "<div id='warnBox' style='display:none; background-color:Beige; ";
     html += "border: 3px ridge DarkRed; width:640px; padding:10px; margin:10px; ";
     html += "text-align:left;'>";
     html += "<CENTER><B id='warnHead' style='color:DarkRed;'></B></CENTER>";
     html += "<UL id='warnList'></UL>";
     html += "<CENTER><button id='warnOK' onclick='hideWarnBox();return false;'></button></CENTER>";
     html += "</div></center>";
 
     html += "<script type='text/javascript'>";
     html += "function showWarnBox() {";
     html += "document.getElementById('warnOK').innerHTML='&nbsp;OK&nbsp;';";