ce138738e24cb6e84502440b79490c412f6786f8 max Tue Jan 27 03:13:16 2026 -0800 Reapply "changing superTrack TrackUi quite a bit. This reverts commit e6ee88658405177aee46ddb8902ae93aee5b1378. diff --git src/hg/hgTrackUi/hgTrackUi.c src/hg/hgTrackUi/hgTrackUi.c index 67510854f67..a16aa2f2f22 100644 --- src/hg/hgTrackUi/hgTrackUi.c +++ src/hg/hgTrackUi/hgTrackUi.c @@ -2738,91 +2738,145 @@ { struct trackDb *tdb; for (tdb = tdbList; tdb != NULL; tdb = tdb->next) if (tdb == target) return TRUE; return FALSE; } #endif /* UNUSED */ void superTrackUi(struct trackDb *superTdb, struct trackDb *tdbList) /* List tracks in this collection, with visibility controls and UI links */ { jsIncludeFile("hui.js",NULL); printf("

"); printf("Tracks that are part of this container are listed below. Use the buttons below to set their visibilities.

"); -printf("\n"); +printf("\n
"); tdbRefSortPrioritiesFromCart(cart, &superTdb->children); struct slRef *childRef; char javascript[1024]; for (childRef = superTdb->children; childRef != NULL; childRef = childRef->next) { struct trackDb *tdb = childRef->val; if (childRef == superTdb->children) // first time through { - printf("\n\n"); } printf("\n\n\n"); printf(""); } printf("
"); - printf(""); - jsOnEventById("click", "btn_plus_all", "superT.plusMinus(true);"); - printf(""); - jsOnEventById("click", "btn_minus_all", "superT.plusMinus(false);"); - printf(" All
"); + printf("
\n"); + + printf("Apply visibility: \n"); + printf("\n"); + + printInfoIcon("The 'Apply to all' button sets all tracks below to the visibility selected on this dropdown. The 'Apply to all visible' button sets this visibility on all tracks below that are not hidden."); + + // First button: set all selectors that are not on 'hide' to the current value of the top select + printf("\n"); + jsOnEventById("click", "superVizApplyButton", "let newVal = $('#superSubViz').val(); $('#superTrackTable select').filter(function() { return $(this).val() !== 'hide'; }).val(newVal).trigger('change').removeClass('hiddenText').addClass('normalText'); "); + + // Second button: set all selectors to the current value of the top select + printf(" \n"); + jsOnEventById("click", "superVizApplyAllButton", "let newVal = $('#superSubViz').val(); $('#superTrackTable select').val(newVal).trigger('change').removeClass('hiddenText').addClass('normalText');"); + printf("
"); if (!tdbIsDownloadsOnly(tdb)) { char id[256]; enum trackVisibility tv = hTvFromString(cartUsualString(cart, tdb->track,hStringFromTv(tdb->visibility))); - // Don't use cheapCgi code... no name and no boolshad... just js safef(id, sizeof id, "%s_check", tdb->track); - printf("", + printf("", id, (tv != tvHide?" CHECKED":"")); - jsOnEventById("change", id, "superT.childChecked(this);"); - safef(javascript, sizeof(javascript), "superT.selChanged(this)"); struct slPair *event = slPairNew("change", cloneString(javascript)); + + char *onlyVis = trackDbSetting(tdb, "onlyVisibility"); hTvDropDownClassVisOnlyAndExtra(tdb->track, tv, tdb->canPack, (tv == tvHide ? "hiddenText":"normalText"), - trackDbSetting(tdb, "onlyVisibility"), + onlyVis, event); + // print a group of buttons that act like radiobuttons (see javascript lines below) + printf("
", tdb->track); + char *trackVizStr = hStringFromTv(tv); + + // vizList is e.g. {"hide", "dense", "squish", "pack", "full"}, but can be shorter, e.g. when canPack=false + char **vizList = hTvGetVizArr(tv, tdb->canPack, onlyVis); + int vizListLen = arrNullLen(vizList); + for (int i = 0; i < vizListLen; i++) { + char *buttonViz = vizList[i]; + // the currently active viz mode is an 'active' button = pressed + if (strcasecmp(buttonViz, trackVizStr) == 0) + printf(""); + } + puts("
"); + printf("
"); hPrintPennantIcon(tdb); safef(id, sizeof id, "%s_link", tdb->track); + // the "); printf("%s ",tdb->shortLabel); } printf("%s", tdb->longLabel); printf("  "); printDataVersion(database, tdb); //printf("  %s", dataVersion); printf("
"); + +// Now configure the elements above with Javascript: + +// * Clicking a button sets the dropdown to the button's text +jsOnEventBySelector("click", ".seg-btn-group > button", "let dropdown = $('#' + $(this).parent().data('trackname')); let buttonText=$(this).text().toLowerCase(); dropdown.val(buttonText).removeClass('hiddenText').addClass('normalText');"); +// * Clicking buttons does not submit the form (default action of