0601238e0258b0ae247f8c1aefe85bf50c039405
kate
  Fri Jan 17 17:25:34 2014 -0800
Make cell abbrev table into a collapsible section to reduce clutter on details page
diff --git src/hg/lib/jsHelper.c src/hg/lib/jsHelper.c
index 023310d..7802961 100644
--- src/hg/lib/jsHelper.c
+++ src/hg/lib/jsHelper.c
@@ -419,67 +419,96 @@
 {
 char *regExs[] = {"<script\\s*>[^<]*</script\\s*>",
                    "<script[^>]*>" // handles case where they have an un-closed script tag with a src attribute
 			};
 int i;
 str = cloneString(str);
 for(i=0;i<ArraySize(regExs);i++)
     {
     char *tmp = str;
     str = stripRegEx(str, regExs[i], REG_ICASE);
     freeMem(tmp);
     }
 return str;
 }
 
-void jsBeginCollapsibleSectionFontSize(struct cart *cart, char *track, char *section,
-				       char *sectionTitle, boolean isOpenDefault, char *fontSize)
+static void jsBeginCollapsibleSectionFull(struct cart *cart, char *track, char *section,
+                                   char *sectionTitle, boolean isOpenDefault, char *fontSize,
+                                   boolean oldStyle)
 /* Make the hidden input, collapse/expand button and <TR id=...> needed for utils.js's
- * setTableRowVisibility().  Caller needs to have already created a <TABLE> and <FORM>. */
+ * setTableRowVisibility().  Caller needs to have already created a <TABLE> and <FORM>. 
+ * With support for style variation. "oldStyle" has blue background color in section header
+ * (as in web.c sections). "fontSize" is ignored if oldStyle is TRUE */
 {
 char collapseGroupVar[512];
 safef(collapseGroupVar, sizeof(collapseGroupVar), "%s.section_%s_close", track, section);
 boolean isOpen = !cartUsualBoolean(cart, collapseGroupVar, !isOpenDefault);
 
 // Both plus button and title are now in same <TD>
 // but still colspan=2 because we are lib code and callers own the table.
-printf("<TR><TD colspan=2 style='text-align:left;'>\n");
+puts("<TR");
+if (oldStyle)
+    puts(" class='subheadingBar'");
+puts (">");
+printf("<TD colspan=2 style='text-align:left;'>\n");
 printf("<input type='hidden' name='%s' id='%s' value='%s'>\n",
        collapseGroupVar, collapseGroupVar, isOpen ? "0" : "1");
 #ifdef BUTTONS_BY_CSS
 hPrintf("<span class='pmButton bigBlue' onclick=\"setTableRowVisibility(this, '%s', "
         "'%s.section', 'section', true)\" id='%s_button' title='%s this section'>%c</span>",
         section, track, section, (isOpen ? "Collapse": "Expand"), (isOpen ? '-' : '+'));
 #else///ifndef BUTTONS_BY_CSS
 char *buttonImage = (isOpen ? "../images/remove_sm.gif" : "../images/add_sm.gif");
 printf("<IMG height='18' width='18' "
        "onclick=\"return setTableRowVisibility(this, '%s', '%s.section', 'section', true);\" "
        "id='%s_button' src='%s' alt='%s' title='%s this section' class='bigBlue'"
        " style='cursor:pointer;'>\n",
        section, track,
        section, buttonImage, (isOpen ? "-" : "+"), (isOpen ? "Collapse": "Expand"));
 #endif///ndef BUTTONS_BY_CSS
-printf("<B style='font-size:%s;'>&nbsp;%s</B></TD></TR>\n", fontSize, sectionTitle);
+if (oldStyle || fontSize == NULL)
+    printf("&nbsp;%s</TD></TR>\n", sectionTitle);
+else
+    printf("<B style='font-size:%s;'>&nbsp;%s</B>", fontSize, sectionTitle);
+puts("</TD></TR>\n");
 printf("<TR %s id='%s-%d'><TD colspan=2>", isOpen ? "" : "style='display: none' ", section, 1);
 }
 
+void jsBeginCollapsibleSectionOldStyle(struct cart *cart, char *track, char *section,
+				       char *sectionTitle, boolean isOpenDefault)
+/* Make the hidden input, collapse/expand button and <TR id=...> needed for utils.js's
+ * setTableRowVisibility().  Caller needs to have already created a <TABLE> and <FORM>. 
+ * With support for varying font size */
+{
+jsBeginCollapsibleSectionFull(cart, track, section, sectionTitle, isOpenDefault, NULL, TRUE);
+}
+
+void jsBeginCollapsibleSectionFontSize(struct cart *cart, char *track, char *section,
+				       char *sectionTitle, boolean isOpenDefault, char *fontSize)
+/* Make the hidden input, collapse/expand button and <TR id=...> needed for utils.js's
+ * setTableRowVisibility().  Caller needs to have already created a <TABLE> and <FORM>. 
+ * With support for varying font size */
+{
+jsBeginCollapsibleSectionFull(cart, track, section, sectionTitle, isOpenDefault, fontSize, FALSE);
+}
+
 void jsBeginCollapsibleSection(struct cart *cart, char *track, char *section, char *sectionTitle,
 			       boolean isOpenDefault)
 /* Make the hidden input, collapse/expand button and <TR id=...> needed for utils.js's
  * setTableRowVisibility().  Caller needs to have already created a <TABLE> and <FORM>. */
 {
-jsBeginCollapsibleSectionFontSize(cart, track, section, sectionTitle, isOpenDefault, "larger");
+jsBeginCollapsibleSectionFull(cart, track, section, sectionTitle, isOpenDefault, "larger", FALSE);
 }
 
 void jsEndCollapsibleSection()
 /* End the collapsible <TR id=...>. */
 {
 puts("</TD></TR>");
 }
 
 void jsReloadOnBackButton(struct cart *cart)
 /* Add some javascript to detect that the back button (or reload) has been pressed,
  * and to resubmit in that case to redraw the page with the latest cart contents. */
 // __detectback trick from
 // http://siphon9.net/loune/2009/07/detecting-the-back-or-refresh-button-click/
 // Yes, I know this along with every other inline <script> here belongs in a .js module
 {