8919f6a1c66e7e87af5b343cb9efe668a4914b70
tdreszer
  Wed Apr 24 10:44:09 2013 -0700
Adding alleles.js which will handle the Gene Haploptype Alleles section of hgGene.  Since this section could be added to hgc for any genePred model, the js code is not being put into a 'hgGene' specific file.
diff --git src/hg/js/utils.js src/hg/js/utils.js
index 8a1f9d6..1065bb0 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -1384,58 +1384,70 @@
 
     // Sorting a table by columns relies upon the columns obj, whose C equivalent would look like:
     //struct column
     //    {
     //    char *  tags[];     // a list of field names in sort order (e.g. 'cell', 'shortLabel')
     //    boolean reverse[];  // the sort direction for each sort field
     //    int     cellIxs[];  // The indexes of the columns in the table to be sorted
     //    boolean useAbbr[];  // Compare on Abbr or on text()?
     //    };
 
     // These 2 globals are used during setTimeout, so that rows can be hidden while sorting
     // and javascript timeout on slow (IE) browsers is less likely
     columns: null,
     tbody: null,
     loadingId: null,
+    caseSensitive: false, // sorts are case INSENSITIVE by default
+
+    sortCaseSensitive: function (sensitive)
+    {   // set case senstivity, which can be added to each sortable columnn's onclick event.
+        // or set for the whole table right after initialize()
+        sortTable.caseSensitive = sensitive;
+    },
 
     row: function (tr,sortColumns,row)  // UNUSED: sortTable.fieldCmp works fine
     {
         this.fields  = new Array();
         this.reverse = new Array();
         this.row     = row;
         for(var ix=0;ix<sortColumns.cellIxs.length;ix++)
             {
             var th = tr.cells[sortColumns.cellIxs[ix]];
-            this.fields[ix]  = (sortColumns.useAbbr[ix] ? th.abbr : $(th).text()).toLowerCase(); // case insensitive sorts
+            this.fields[ix]  = (sortColumns.useAbbr[ix] ? th.abbr : $(th).text());
+            if (!sortTable.caseSensitive) 
+                this.fields[ix]  = this.fields[ix].toLowerCase(); // case insensitive sorts
             this.reverse[ix] = sortColumns.reverse[ix];
             }
     },
 
     rowCmp: function (a,b)  // UNUSED: sortTable.fieldCmp works fine
     {
         for(var ix=0;ix<a.fields.length;ix++) {
             if (a.fields[ix] > b.fields[ix])
                 return (a.reverse[ix] ? -1:1);
             else if (a.fields[ix] < b.fields[ix])
                 return (a.reverse[ix] ? 1:-1);
         }
         return 0;
     },
 
     field: function (value,reverse,row)
     {
-        this.value   = value.toLowerCase(); // case insensitive sorts NOTE: Do not need to define every field
+        if (sortTable.caseSensitive) 
+            this.value   = value;
+        else
+            this.value   = value.toLowerCase(); // case insensitive sorts
         this.reverse = reverse;
         this.row     = row;
     },
 
     fieldCmp: function (a,b)
     {
         if (a.value > b.value)
             return (a.reverse ? -1:1);
         else if (a.value < b.value)
             return (a.reverse ? 1:-1);
         return 0;
     },
 
     sort: function (tbody,sortColumns)
     {// Sorts table based upon rules passed in by function reference