089f386d5e2960f2845e1352983defcc30f3cf6c
kate
Wed Jan 13 14:34:37 2016 -0800
add 'noAltColors' class to sortable table to suppress alternating colored rows
diff --git src/hg/js/utils.js src/hg/js/utils.js
index 6394fe2..65e7f48 100644
--- src/hg/js/utils.js
+++ src/hg/js/utils.js
@@ -2149,30 +2149,31 @@
// arrow and the column's sort order: e.g. ↓2
// NOTE: If no sup is found but addSuperscript is requested, then they will be added.
// TBODY.sortable: (NOTE: created if not found) The TBODY class='sortable' contains the
// table rows that get sorted:
// TBODY->TR & ->TD: Each row contains a TD for each sortable column.
// The innerHTML (entire contents) of the cell will be used for sorting.
// TRICK: You can use the 'abbr' field to subtly alter the sortable contents.
// Otherwise sorts on td contents ($(td).text()). Use the abbr field to make
// case-insensitive sorts or force exceptions to alpha-text order
// (such as ZCTRL vs Control forcing controls to bottom). e.g.:
//
Control |
// IMPORTANT: You must add abbr='use' to the TH.sortable definitions.
// Finally if you want the tableSort to alternate the table row colors
// (using #FFFEE8 and #FFF9D2) then TBODY.sortable should also have class 'altColors'
// NOTE: This class can be added by using the altColors option to this function
+ // To override, specify
if (altColors === undefined || altColors === null) // explicitly default this boolean
altColors = false;
if ($(table).hasClass('sortable') === false) {
warn('Table is not sortable');
return;
}
var tr = $(table).find('tr.sortable')[0];
if (!tr) {
tr = $(table).find('tr')[0];
if (!tr) {
warn('Sortable table has no rows');
return;
}
@@ -2184,31 +2185,32 @@
return;
}
// If not TBODY is found, then create, wrapping all but those already in a thead
tbody = $(table).find('tbody')[0];
if (!tbody) {
trs = $(table).find('tr').not('thead tr');
$(trs).wrapAll("");
tbody = $(table).find('tbody')[0];
//warn('Wrapped all trs not in thead.sortable in tbody.sortable');
}
if ($(tbody).hasClass('sortable') === false) {
$(tbody).addClass('sortable');
//warn('Added sortable class to tbody');
}
- if (altColors && $(tbody).hasClass('altColors') === false) {
+ if (altColors && $(tbody).hasClass('altColors') === false &&
+ $(tbody).hasClass('noAltColors') === false) {
$(tbody).addClass('altColors');
//warn('Added altColors class to tbody.sortable');
}
$(tbody).hide();
// If not THEAD is found, then create, wrapping first row.
thead = $(table).find('thead')[0];
if (!thead) {
$(tr).wrapAll("");
thead = $(table).find('thead')[0];
$(thead).insertBefore(tbody);
//warn('Wrapped tr.sortable with thead.sortable');
}
if ($(thead).hasClass('sortable') === false) {
$(thead).addClass('sortable');