023eb1bbf8ea362cb2e4e7c4950b40a959419cfc kent Sun Mar 8 13:07:49 2015 -0700 Trying another shot at watermarks on the filter row. Seems to work with new library. diff --git src/hg/lib/tablesTables.c src/hg/lib/tablesTables.c index 517e140..738b9ab 100644 --- src/hg/lib/tablesTables.c +++ src/hg/lib/tablesTables.c @@ -1,24 +1,25 @@ /* tablesTables - this module deals with two types of tables SQL tables in a database, * and fieldedTable objects in memory. It has routines to do sortable, filterable web * displays on tables. */ #include "common.h" #include "hash.h" #include "obscure.h" #include "linefile.h" #include "jksql.h" +#include "jsHelper.h" #include "sqlSanity.h" #include "fieldedTable.h" #include "cheapcgi.h" #include "web.h" #include "cart.h" #include "tablesTables.h" struct fieldedTable *fieldedTableFromDbQuery(struct sqlConnection *conn, char *query) /* Return fieldedTable from a database query */ { struct sqlResult *sr = sqlGetResult(conn, query); char **fields; int fieldCount = sqlResultFieldArray(sr, &fields); struct fieldedTable *table = fieldedTableNew(query, fields, fieldCount); char **row; @@ -61,47 +62,52 @@ struct slName *suggest; for (suggest = suggestList; suggest != NULL; suggest = suggest->next) { printf("%s\"%s\"", separator, suggest->name); separator = ","; } printf("]\n"); printf(" });\n"); printf("});\n"); printf("\n"); } static void printWatermark(char *id, char *watermark) /* Print light text filter prompt as watermark. */ { -#ifdef SOON printf("\n"); -#endif /* SOON */ } 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 */ { -printf(""); +/* 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(""); for (i=0; ifieldCount; ++i) { char *field = table->fields[i]; char varName[256]; safef(varName, sizeof(varName), "%s_f_%s", varPrefix, field); webPrintLinkCellStart(); #ifdef MAKES_TOO_WIDE /* Print out input control. As you can see from all the commented out bits * this part has been a challenge. We'd like to make the input cell fit the * table size, but if we do it with style it makes whole table wider. */ char *oldVal = cartUsualString(cart, varName, ""); printf("", varName, oldVal); #endif /* MAKES_TOO_WIDE */ @@ -112,38 +118,38 @@ size = maxLenField; #ifdef ACTUALLY_WORKS /* This way does work last I checked and is just a line of code. * Getting an id= property on the input tag though isn't possible this way. */ cartMakeTextVar(cart, varName, "", size + 1); #endif /* Print input control getting previous value from cart. Set an id= * so auto-suggest can find this control. */ char *oldVal = cartUsualString(cart, varName, ""); printf("\n", varName, varName, size+1, oldVal); /* Write out javascript to initialize autosuggest on control */ + printWatermark(varName, " filter "); if (suggestHash != NULL) { struct slName *suggestList = hashFindVal(suggestHash, field); if (suggestList != NULL) { printSuggestScript(varName, suggestList); } - printWatermark(varName, "filter"); } webPrintLinkCellEnd(); } printf(""); } static void showTableSortingLabelRow(struct fieldedTable *table, struct cart *cart, char *varPrefix, char *returnUrl) /* Put up the label row with sorting fields attached. ALso actually sort table. */ { /* Get order var */ char orderVar[256]; safef(orderVar, sizeof(orderVar), "%s_order", varPrefix);