4c479e3bbf02d10115c867a5f7a6e25d89146567 kate Mon Jan 25 16:04:43 2016 -0800 Cleanup styling. diff --git src/hg/lib/gtexUi.c src/hg/lib/gtexUi.c index e4ae2cd..93f954d 100644 --- src/hg/lib/gtexUi.c +++ src/hg/lib/gtexUi.c @@ -8,42 +8,51 @@ #include "hui.h" #include "trackDb.h" #include "jsHelper.h" #include "gtexTissue.h" #include "gtexUi.h" #define SYSTEM_BRAIN "Brain" #define SYSTEM_REPRODUCTIVE "Reproductive" #define SYSTEM_GASTRO "Digestive" #define SYSTEM_ENDOCRINE "Endocrine" #define SYSTEM_CARDIO "Cardiovascular" #define SYSTEM_OTHER "Other" +static void initTissueTableStyle() +{ +puts("<style>\n" + "#tissueTable th, #tissueTable td {\n" + "font-size: 75%;\n" + "}\n" + "</style>\n"); +} + static char *makeTissueColorPatch(struct gtexTissue *tis) { char buf[256]; -safef(buf, sizeof(buf), "<td style='width:10px; font-size:75%%;' bgcolor=%X></td>", tis->color); +safef(buf, sizeof(buf), "<td style='width:10px;' bgcolor=%X></td>", tis->color); return(cloneString(buf)); } static char *makeTissueLabel(struct gtexTissue *tis) { char buf[256]; -safef(buf, sizeof(buf), "<td style='width:10px; font-size:75%%;' bgcolor=%X></td>" - "<td style='font-size:75%%'> %s</td>", +safef(buf, sizeof(buf), "<td style='width:10px;' bgcolor=%X></td>" + "<td> %s</td>", tis->color, tis->description); return(cloneString(buf)); } static char *getSystem(struct gtexTissue *tis) { if (startsWith("brain", tis->name)) return(SYSTEM_BRAIN); else if (sameString(tis->name, "uterus") || sameString(tis->name, "testis") || sameString(tis->name, "vagina") || sameString(tis->name, "prostate") || sameString(tis->name, "ovary") || sameString(tis->name, "breastMamTissue") || sameString(tis->name, "ectocervix") || sameString(tis->name, "endocervix") || sameString(tis->name, "fallopianTube")) return(SYSTEM_REPRODUCTIVE); else if (startsWith("esophagus", tis->name) || startsWith("colon", tis->name) || @@ -58,31 +67,31 @@ else return(SYSTEM_OTHER); } struct tissueSelect { struct tissueSelect *next; char *name; char *label; boolean checked; }; static void makeGroupCheckboxes(char *name, char *title, struct tissueSelect *tisSelects) { if (title != NULL) - printf("<tr><td colspan=10 style='font-size:75%%'><i><b>%s</b></i></td></tr><tr>\n", title); + printf("<tr><td colspan=10><i><b>%s</b></i></td></tr><tr>\n", title); int count = slCount(tisSelects); struct tissueSelect **tisArray; AllocArray(tisArray, count); int i=0; struct tissueSelect *tsel; for (i=0, tsel = tisSelects; tsel != NULL; tsel = tsel->next, i++) tisArray[i] = tsel; int col=0; int row=0; int tableColumns=3; for (i=0; i<count; i++) { int j = row + col*(count/tableColumns+1); if (j>=count) { @@ -121,95 +130,96 @@ else tsel->checked = (hashLookup(checkHash, tis->name) != NULL); slAddHead(&allTissues, tsel); } slReverse(&allTissues); makeGroupCheckboxes(name, NULL, allTissues); puts("</tr></table>"); char buf[512]; safef(buf, sizeof(buf), "%s%s", cgiMultListShadowPrefix(), name); cgiMakeHiddenVar(buf, "0"); } static void makeTableTissueCheckboxes(char *name, struct gtexTissue *tissues, struct slName *checked, struct cart *cart) { +initTissueTableStyle(); char *onClick = ""; // Sortable table can't be displayed when UI is activated from right-click (popup mode) if (!cartVarExists(cart, "ajax")) { jsIncludeFile("hui.js", NULL); onClick = "'tableSortAtButtonPress(this);"; } struct hash *checkHash = hashNew(0); struct slName *sel; for (sel = checked; sel != NULL; sel = sel->next) hashAdd(checkHash, sel->name, sel->name); //puts("<table borderwidth=0><tr>"); puts("\n<table id='tissueTable' cellspacing='2' cellpadding='0' border='0' class='sortable'>"); /* table header */ char orderVar[256]; safef(orderVar, sizeof(orderVar), "%s.sortOrder", name); char *sortOrder = cartCgiUsualString(cart, orderVar, "tissue=+ samples=+ organ=+ system=+"); puts("\n<thead class='sortable'>"); puts("\n<tr class='sortable'>"); printf("\n<th> <input type=hidden name='%s' class='sortOrder' value='%s'></th>\n", orderVar, sortOrder); puts("<th> </th>"); -printf("<th id='tissue' class='sortable sort1' style='font-size:75%%' %s " +printf("<th id='tissue' class='sortable sort1' %s " "align='left' title='Sort on tissue'> Tissue</th>", onClick); -printf("<th id='samples' abbr='use' class='sortable sort2' style='font-size:75%%' %s " +printf("<th id='samples' abbr='use' class='sortable sort2' %s " "align='left' title='Sort on sample count'> Samples</th>", onClick); -printf("<th id='organ' class='sortable sort3' style='font-size:75%%' %s " +printf("<th id='organ' class='sortable sort3' %s " "align='left' title='Sort on organ'> Organ</th>", onClick); -printf("<th id='system' class='sortable sort4' style='font-size:75%%' %s " +printf("<th id='system' class='sortable sort4' %s " "align='left' title='Sort on system'> System</th>", onClick); puts("\n</tr>"); puts("</thead>"); /* table body */ printf("<tbody class='sortable noAltColors initBySortOrder'>"); struct hash *tscHash = gtexGetTissueSampleCount(); struct gtexTissue *tis; boolean isChecked = FALSE; for (tis = tissues; tis != NULL; tis = tis->next) { puts("\n<tr valign='top'>"); // checkbox if (hashNumEntries(checkHash) == 0) isChecked = TRUE; else isChecked = (hashLookup(checkHash, tis->name) != NULL); printf("<td><input type=checkbox name=\"%s\" value=\"%s\" %s></td>", name, tis->name, isChecked ? "checked" : ""); // color patch printf("\n%s", makeTissueColorPatch(tis)); // tissue name - printf("\n<td style='font-size:75%%'> %s</td>", tis->description); + printf("\n<td> %s</td>", tis->description); // sample count int samples = hashIntValDefault(tscHash, tis->name, 0); - printf("\n<td abbr='%05d' style='font-size:75%%; text-align: right; padding-right: 10px''> %d</td>", samples, samples); + printf("\n<td abbr='%05d' style='text-align: right; padding-right: 10px'> %d</td>", samples, samples); // organ - printf("\n<td style='font-size:75%%; padding-right: 10px'> %s</td>", tis->organ); + printf("\n<td style='padding-right: 10px'> %s</td>", tis->organ); // system - printf("\n<td style='font-size:75%%'> %s</td>", getSystem(tis)); + printf("\n<td> %s</td>", getSystem(tis)); puts("\n</tr>"); } puts("</tbody>"); puts("</table>"); char buf[512]; safef(buf, sizeof(buf), "%s%s", cgiMultListShadowPrefix(), name); cgiMakeHiddenVar(buf, "0"); } static void makeGroupedTissueCheckboxes(char *name, struct gtexTissue *tissues, struct slName *checked) { struct hash *checkHash = hashNew(0); struct slName *sel; for (sel = checked; sel != NULL; sel = sel->next)