0cc76b8a1e9ab5b02f12e7463893dc324760e838
galt
Thu Jun 8 20:53:26 2017 -0700
cdwWebBrowse: Adding navigation first prev next last links. Also made it reset the page number back to 1 if anything changed such as: clear search button pressed, search changed, filters changed. FYI sort-change already took care of resetting the page number.
diff --git src/hg/lib/tablesTables.c src/hg/lib/tablesTables.c
index 9c860be..9fd88d0 100644
--- src/hg/lib/tablesTables.c
+++ src/hg/lib/tablesTables.c
@@ -27,49 +27,49 @@
while ((row = sqlNextRow(sr)) != NULL)
fieldedTableAdd(table, row, fieldCount, ++i);
sqlFreeResult(&sr);
return table;
}
static void showTableFilterInstructionsEtc(struct fieldedTable *table,
char *itemPlural, struct fieldedTableSegment *largerContext, void (*addFunc)(void))
/* Print instructional text, and basic summary info on who passes filter, and a submit
* button just in case user needs it */
{
/* Print info on matching */
int matchCount = slCount(table->rowList);
if (largerContext != NULL) // Need to page?
matchCount = largerContext->tableSize;
+
cgiMakeButton("submit", "search");
-printf("   ");
+
+printf("  ");
+cgiMakeOnClickButton("clearButton",
+"$(':input').not(':button, :submit, :reset, :hidden, :checkbox, :radio').val('');\n"
+"$('[name=cdwBrowseFiles_page]').val('1');\n"
+"$('#submit').click();\n"
+, "clear search");
+printf("
");
printf("%d %s found. ", matchCount, itemPlural);
if (addFunc)
addFunc();
printf("
\n");
printf("You can further filter search results field by field below. ");
printf("Wildcard * and ? characters are allowed in text fields. ");
printf(">min or <max are allowed in numerical fields.
\n");
-printf("Reset all filters\n");
-jsInlineF(
-"$(function() {\n"
-" $('#resetLink').click( function() { "
-" $(':input').not(':button, :submit, :reset, :hidden, :checkbox, :radio').val('');\n"
-" $('#submit').click();\n"
-" });"
-"});\n");
}
static void printSuggestScript(char *id, struct slName *suggestList)
/* Print out a little javascript to wrap auto-suggester around control with given ID */
{
struct dyString *dy = dyStringNew(256);
dyStringPrintf(dy,"$(document).ready(function() {\n");
dyStringPrintf(dy," $('#%s').autocomplete({\n", id);
dyStringPrintf(dy," delay: 100,\n");
dyStringPrintf(dy," minLength: 0,\n");
dyStringPrintf(dy," source: [");
char *separator = "";
struct slName *suggest;
for (suggest = suggestList; suggest != NULL; suggest = suggest->next)
{
@@ -80,30 +80,43 @@
dyStringPrintf(dy," });\n");
dyStringPrintf(dy,"});\n");
jsInline(dy->string);
dyStringFree(&dy);
}
static void printWatermark(char *id, char *watermark)
/* Print light text filter prompt as watermark. */
{
jsInlineF(
"$(function() {\n"
" $('#%s').watermark(\"%s\");\n"
"});\n", id, watermark);
}
+static void resetPageNumberOnChange(char *id)
+/* On change, reset page number to 1. */
+{
+jsInlineF(
+"$(function() {\n"
+" $('form').delegate('#%s','change keyup paste',function(e){\n"
+" $('[name=cdwBrowseFiles_page]').val('1');\n"
+" });\n"
+"});\n"
+, id);
+}
+
+
static void showTableFilterControlRow(struct fieldedTable *table, struct cart *cart,
char *varPrefix, int maxLenField, struct hash *suggestHash)
/* Assuming we are in table already drow control row.
* The suggestHash is keyed by field name. If something is there we'll assume
* it's value is slName list of suggestion values */
{
/* Include javascript and style we need */
webIncludeResourceFile("jquery-ui.css");
jsIncludeFile("jquery.js", NULL);
jsIncludeFile("jquery.plugins.js", NULL);
jsIncludeFile("jquery-ui.js", NULL);
jsIncludeFile("jquery.watermark.js", NULL);
int i;
printf("