69e8424f77f7d2513fcf8082aea972d539665540
tdreszer
  Fri Nov 18 13:14:56 2011 -0800
More touches on BUTTONS_BY_CSS
diff --git src/hg/js/utils.js src/hg/js/utils.js
index 25607ea..e4d3385 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -426,47 +426,65 @@
             $(divit).children('table').addClass(bgClass);
         }
     }
     $(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;
+	var newVal = -1;
         if(arguments.length > 5)
             newVal = arguments[5] ? 0 : 1;
-        else
+        var oldSrc = $(button).attr("src");
+        if (oldSrc != undefined && oldSrc.length > 0) {
+            // Old img version of the toggleButton
+            if (newVal == -1)
             newVal = oldSrc.indexOf("/remove") > 0 ? 1 : 0;
-        var newSrc;
+            if(newVal == 1)
+                $(button).attr("src", oldSrc.replace("/remove", "/add") );
+            else
+                $(button).attr("src", oldSrc.replace("/add", "/remove") );
+        } else {
+            // new BUTTONS_BY_CSS
+            if (newVal == -1) {
+                oldSrc = $(button).text();
+                if (oldSrc != undefined && oldSrc.length == 1)
+                    newVal = $(button).text() == "+" ? 0 : 1;
+                else {
+                    warn("Uninterpretable toggleButton!");
+                    newVal = 0;
+                }
+            }
+            if(newVal == 1)
+                $(button).text('+');
+            else
+                $(button).text('-');
+        }
         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; ";