13e3bdbc4767d3dc557c9921e56d81c115767a32 kent Mon Feb 1 16:11:15 2021 -0800 Adding some anchors and IDs so that when select a facet it will tend to come back to about where you were in the page rather than popping you back up to the top. diff --git src/hg/lib/tablesTables.c src/hg/lib/tablesTables.c index 14518a0..437e8fa 100644 --- src/hg/lib/tablesTables.c +++ src/hg/lib/tablesTables.c @@ -527,124 +527,142 @@ printf("
\n"); printf("%s\n", facetBar->string); printf("
\n"); } if (!isEmpty(where) || gotSelected) printf("
\n"); dyStringFree(&facetBar); } printf("
\n"); // parent container if (visibleFacetList) { - // left column printf("
\n"); struct slName *visList = slNameListFromComma(visibleFacetList); struct slName *vis; for (vis = visList; vis != NULL; vis = vis->next) { + char selfId[256]; + safef(selfId, sizeof(selfId), "%s_self_a_%s", varPrefix, vis->name); + subChar(selfId, ' ', '_'); + int f = fieldedTableMustFindFieldIx(table, vis->name); struct facetField *field = ffArray[f]; - htmlPrintf("
\n"); + htmlPrintf("
\n", selfId); htmlPrintf("
%s
\n", field->fieldName); struct facetVal *val; if (!field->allSelected) // add reset facet link { char *op = "reset"; htmlPrintf("
%s
\n", returnUrl, varPrefix, op, varPrefix, field->fieldName, varPrefix, "", varPrefix, "Clear" ); } int valuesShown = 0; int valuesNotShown = 0; if (field->showAllValues) // Sort alphabetically if they want all values { slSort(&field->valList, facetValCmp); } + int extraAnchorPeriod = 10; + int extraAnchorPos = 0; for (val = field->valList; val; val=val->next) { boolean specificallySelected = (val->selected && !field->allSelected); if ((val->selectCount > 0 && (field->showAllValues || valuesShown < facetUsualSize)) || specificallySelected) { ++valuesShown; + ++extraAnchorPos; char *op = "add"; if (specificallySelected) op = "remove"; - printf("
\n"); + printf("
= extraAnchorPeriod) + { + safef(selfId, sizeof(selfId), "%s_self_a_%s_%s", varPrefix, vis->name, + val->val); + subChar(selfId, ' ', '_'); + printf(" id=\"%s\"", selfId); + extraAnchorPos= 0; + } + printf(">\n"); htmlPrintf(" ", specificallySelected ? "true" : "false", specificallySelected ? "checked" : ""); htmlPrintf("", returnUrl, varPrefix, - op, varPrefix, field->fieldName, varPrefix, val->val, varPrefix + op, varPrefix, field->fieldName, varPrefix, val->val, varPrefix, selfId ); htmlPrintf("%s (%d)", val->val, val->selectCount); printf("
\n"); } else if (val->selectCount > 0) { ++valuesNotShown; } } // show "See More" link when facet has lots of values if (valuesNotShown > 0) { char *op = "showAllValues"; htmlPrintf("
See %d More
\n", returnUrl, varPrefix, op, - varPrefix, field->fieldName, varPrefix, "", varPrefix, valuesNotShown + varPrefix, field->fieldName, varPrefix, "", + varPrefix, selfId, valuesNotShown ); } // show "See Fewer" link when facet has lots of values if (field->showAllValues && valuesShown >= facetUsualSize) { + safef(selfId, sizeof(selfId), "%s_self_a_%s", varPrefix, vis->name); + subChar(selfId, ' ', '_'); char *op = "showSomeValues"; htmlPrintf("
%s
\n", returnUrl, varPrefix, op, varPrefix, field->fieldName, varPrefix, "", varPrefix, - "See Fewer" + selfId, "See Fewer" ); } htmlPrintf("
\n"); } printf("
\n"); // Clicking a checkbox is actually a click on the following link jsInlineF( "$(function () {\n" " $('.ttFsCheckBox').click(function() {\n" " this.nextSibling.nextSibling.click();\n" " });\n" "});\n"); } // start right column, if there are two columns