d05639bbaee755e013b3abe1e7abfbfb6a3679f2 tdreszer Tue Feb 8 17:00:58 2011 -0800 Got dropdownchecklist to work within hgTracks popup cfg diff --git src/hg/lib/hui.c src/hg/lib/hui.c index acb7594..44aa311 100644 --- src/hg/lib/hui.c +++ src/hg/lib/hui.c @@ -3327,31 +3327,31 @@ struct slName *val = filterBy->slValues; for(;val!=NULL;val=val->next) { // chip the color off the end of value name color = strchr(val->name,'{'); if (color == NULL && filterBy->colorFollows) { warn("Using filterBy but only some values contain colors in form of value{#color} or value|label{#color}."); filterBy->colorFollows = FALSE; break; } else if (color != NULL && filterBy->colorFollows) { assert(*(color + 1) == '#'); *color++ = 0; // The color is found inside the filters->svValues as the next string beyond value or label - color = strchr(val->name,'}'); // There could be a closing '}' + color = strchr(color,'}'); // There could be a closing '}' if (color != NULL) *color = 0; } // now chip the label off the end of value name char * lab =strchr(val->name,'|'); if (lab == NULL && filterBy->valueAndLabel) { warn("Using filterBy but only some values contain labels in form of value|label."); filterBy->valueAndLabel = FALSE; break; } if (lab != NULL && filterBy->valueAndLabel) { *lab++ = 0; // The label is found inside the filters->svValues as the next string @@ -3537,46 +3537,52 @@ //#define FILTER_COMPOSITE_OPEN_SIZE 16 // TODO: columnCount (Number of filterBoxes per row) should be configurable through tdb setting #define FILTER_BY_FORMAT "<SELECT id='fbc%d' name='%s.filterBy.%s' multiple style='display: none;' class='filterComp filterBy'><BR>\n" printf(FILTER_BY_FORMAT,ix,tdb->track,filterBy->column); ix++; printf("<OPTION%s>All</OPTION>\n",(filterBy->slChoices == NULL || slNameInList(filterBy->slChoices,"All")?" SELECTED":"") ); struct slName *slValue; if(filterBy->useIndex) { int ix=1; for(slValue=filterBy->slValues;slValue!=NULL;slValue=slValue->next,ix++) { char varName[32]; safef(varName, sizeof(varName), "%d",ix); char *name = strSwapChar(cloneString(slValue->name),'_',' '); - printf("<OPTION%s value=%s>%s</OPTION>\n",(filterBy->slChoices != NULL && slNameInList(filterBy->slChoices,varName)?" SELECTED":""),varName,name); + printf("<OPTION"); + if (filterBy->slChoices != NULL && slNameInList(filterBy->slChoices,varName)) + printf(" SELECTED"); + printf(" value='%s'",varName); + if (filterBy->colorFollows) + printf(" style='color: %s;'",slValue->name + strlen(slValue->name)+1); + printf(">%s</OPTION>\n",name); freeMem(name); } } else { for(slValue=filterBy->slValues;slValue!=NULL;slValue=slValue->next) { char *label = (filterBy->valueAndLabel? slValue->name + strlen(slValue->name)+1: slValue->name); printf("<OPTION"); if (filterBy->slChoices != NULL && slNameInList(filterBy->slChoices,slValue->name)) printf(" SELECTED"); if (filterBy->valueAndLabel) printf(" value='%s'",slValue->name); if (filterBy->colorFollows) - printf(" style='background-color: %s;'",label + strlen(label)+1); + printf(" style='color: %s;'",label + strlen(label)+1); printf(">%s</OPTION>\n",label); } } } printf("</SELECT>\n"); // The following is needed to make msie scroll to selected option. printf("<script type='text/javascript'>onload=function(){ if( $.browser.msie ) { $(\"select[name^='%s.filterBy.']\").children('option[selected]').each( function(i) { $(this).attr('selected',true); }); }}</script>\n",tdb->track); puts("</TR></TABLE>"); return; } #define COLOR_BG_DEFAULT_IX 0 #define COLOR_BG_ALTDEFAULT_IX 1