mirror of
https://github.com/Mottie/tablesorter.git
synced 2025-01-12 15:24:21 +00:00
Core: merge in modified addInstanceMethods. Closes #826
Removed `$columnHeader` & replaced it with new `$headerIndexed` variable
This commit is contained in:
parent
4171325819
commit
a69a746fdf
30
dist/js/jquery.tablesorter.js
vendored
30
dist/js/jquery.tablesorter.js
vendored
@ -154,6 +154,9 @@
|
||||
nextNone : 'activate to remove the sort'
|
||||
};
|
||||
|
||||
// These methods can be applied on table.config instance
|
||||
ts.instanceMethods = {};
|
||||
|
||||
/* debuging utils */
|
||||
function log() {
|
||||
var a = arguments[0],
|
||||
@ -256,7 +259,7 @@
|
||||
if (rows.length) {
|
||||
l = c.columns; // rows[j].cells.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
h = c.$headers.filter('[data-column="' + i + '"]:last');
|
||||
h = c.$headerIndexed[i];
|
||||
// get column indexed table cell
|
||||
ch = ts.getColumnData( table, c.headers, i );
|
||||
// get column parser/extractor
|
||||
@ -445,8 +448,7 @@
|
||||
}
|
||||
|
||||
function buildHeaders(table) {
|
||||
var ch, $t,
|
||||
h, i, t, lock, time,
|
||||
var ch, $t, h, i, t, lock, time, indx,
|
||||
c = table.config;
|
||||
c.headerList = [];
|
||||
c.headerContent = [];
|
||||
@ -495,6 +497,13 @@
|
||||
if (c.tabIndex) { $t.attr('tabindex', 0); }
|
||||
return elem;
|
||||
}));
|
||||
// cache headers per column
|
||||
c.$headerIndexed = [];
|
||||
for (indx = 0; indx < c.columns; indx++) {
|
||||
$t = c.$headers.filter('[data-column="' + indx + '"]');
|
||||
// target sortable column cells, unless there are none, then use non-sortable cells
|
||||
c.$headerIndexed[indx] = $t.not('.sorter-false').length ? $t.not('.sorter-false').last() : $t.last();
|
||||
}
|
||||
$(table).find(c.selectorHeaders).attr({
|
||||
scope: 'col',
|
||||
role : 'columnheader'
|
||||
@ -603,8 +612,9 @@
|
||||
// ensure all sortList values are numeric - fixes #127
|
||||
col = parseInt(val[0], 10);
|
||||
// make sure header exists
|
||||
header = c.$headers.filter('[data-column="' + col + '"]:last')[0];
|
||||
header = c.$headerIndexed[col][0];
|
||||
if (header) { // prevents error if sorton array is wrong
|
||||
// o.count = o.count + 1;
|
||||
dir = ('' + val[1]).match(/^(1|d|s|o|n)/);
|
||||
dir = dir ? dir[0] : '';
|
||||
// 0/(a)sc (default), 1/(d)esc, (s)ame, (o)pposite, (n)ext
|
||||
@ -706,7 +716,7 @@
|
||||
// reverse the sorting direction
|
||||
for (col = 0; col < c.sortList.length; col++) {
|
||||
s = c.sortList[col];
|
||||
order = c.$headers.filter('[data-column="' + s[0] + '"]:last')[0];
|
||||
order = c.$headerIndexed[ s[0] ][0];
|
||||
if (s[0] === indx) {
|
||||
// order.count seems to be incorrect when compared to cell.count
|
||||
s[1] = order.order[cell.count];
|
||||
@ -1052,7 +1062,7 @@
|
||||
return this.each(function() {
|
||||
var table = this,
|
||||
// merge & extend config options
|
||||
c = $.extend(true, {}, ts.defaults, settings);
|
||||
c = $.extend(true, {}, ts.defaults, settings, ts.instanceMethods);
|
||||
// save initial settings
|
||||
c.originalSettings = settings;
|
||||
// create a table from data (build table widget)
|
||||
@ -1601,6 +1611,12 @@
|
||||
}
|
||||
};
|
||||
|
||||
// Use it to add a set of methods to table.config which will be available for all tables.
|
||||
// This should be done before table initialization
|
||||
ts.addInstanceMethods = function(methods) {
|
||||
$.extend(ts.instanceMethods, methods);
|
||||
};
|
||||
|
||||
ts.getParserById = function(name) {
|
||||
/*jshint eqeqeq:false */
|
||||
if (name == 'false') { return false; }
|
||||
@ -1966,7 +1982,7 @@
|
||||
if (s) {
|
||||
var date, d,
|
||||
c = table.config,
|
||||
ci = c.$headers.filter('[data-column="' + cellIndex + '"]:last'),
|
||||
ci = c.$headerIndexed[ cellIndex ],
|
||||
format = ci.length && ci[0].dateFormat || ts.getData( ci, ts.getColumnData( table, c.headers, cellIndex ), 'dateFormat') || c.dateFormat;
|
||||
d = s.replace(/\s+/g, ' ').replace(/[\-.,]/g, '/'); // escaped - because JSHint in Firefox was showing it as an error
|
||||
if (format === 'mmddyyyy') {
|
||||
|
4
dist/js/jquery.tablesorter.min.js
vendored
4
dist/js/jquery.tablesorter.min.js
vendored
File diff suppressed because one or more lines are too long
22
dist/js/jquery.tablesorter.widgets.js
vendored
22
dist/js/jquery.tablesorter.widgets.js
vendored
@ -1,4 +1,4 @@
|
||||
/*! tablesorter (FORK) widgets - updated 02-26-2015 (v2.20.1)*/
|
||||
/*! tablesorter (FORK) widgets - updated 02-27-2015 (v2.20.1)*/
|
||||
/* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */
|
||||
/*! Widget: storage */
|
||||
;(function ($, window, document) {
|
||||
@ -552,7 +552,7 @@ ts.filter = {
|
||||
parsed = data.parsed[index],
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed);
|
||||
// look for an exact match with the "or" unless the "filter-match" class is found
|
||||
if (!c.$headers.filter('[data-column="' + index + '"]:last').hasClass('filter-match') && /\|/.test(query)) {
|
||||
if (!c.$headerIndexed[index].hasClass('filter-match') && /\|/.test(query)) {
|
||||
// show all results while using filter match. Fixes #727
|
||||
if (query[ query.length - 1 ] === '|') { query += '*'; }
|
||||
query = data.anyMatch && $.isArray(data.rowArray) ? '(' + query + ')' : '^(' + query + ')$';
|
||||
@ -673,7 +673,7 @@ ts.filter = {
|
||||
fxn = ts.getColumnData( table, wo.filter_functions, column );
|
||||
if (fxn) {
|
||||
// remove "filter-select" from header otherwise the options added here are replaced with all options
|
||||
$header = c.$headers.filter('[data-column="' + column + '"]:last').removeClass('filter-select');
|
||||
$header = c.$headerIndexed[column].removeClass('filter-select');
|
||||
// don't build select if "filter-false" or "parser-false" set
|
||||
noSelect = !($header.hasClass('filter-false') || $header.hasClass('parser-false'));
|
||||
options = '';
|
||||
@ -846,7 +846,7 @@ ts.filter = {
|
||||
for (column = 0; column < columns; column++) {
|
||||
disabled = false;
|
||||
// assuming last cell of a column is the main column
|
||||
$header = c.$headers.filter('[data-column="' + column + '"]:last');
|
||||
$header = c.$headerIndexed[column];
|
||||
ffxn = ts.getColumnData( table, wo.filter_functions, column );
|
||||
buildSelect = (wo.filter_functions && ffxn && typeof ffxn !== "function" ) ||
|
||||
$header.hasClass('filter-select');
|
||||
@ -1134,7 +1134,7 @@ ts.filter = {
|
||||
data.parsed = c.$headers.map(function(columnIndex) {
|
||||
return c.parsers && c.parsers[columnIndex] && c.parsers[columnIndex].parsed ||
|
||||
// getData won't return "parsed" if other "filter-" class names exist (e.g. <th class="filter-select filter-parsed">)
|
||||
ts.getData && ts.getData(c.$headers.filter('[data-column="' + columnIndex + '"]:last'), ts.getColumnData( table, c.headers, columnIndex ), 'filter') === 'parsed' ||
|
||||
ts.getData && ts.getData(c.$headerIndexed[columnIndex], ts.getColumnData( table, c.headers, columnIndex ), 'filter') === 'parsed' ||
|
||||
$(this).hasClass('filter-parsed');
|
||||
}).get();
|
||||
|
||||
@ -1210,7 +1210,7 @@ ts.filter = {
|
||||
// don't search only filtered if the value is negative ('> -10' => '> -100' will ignore hidden rows)
|
||||
!(/(>=?\s*-\d)/.test(val) || /(<=?\s*\d)/.test(val)) &&
|
||||
// if filtering using a select without a "filter-match" class (exact match) - fixes #593
|
||||
!( val !== '' && c.$filters && c.$filters.eq(indx).find('select').length && !c.$headers.filter('[data-column="' + indx + '"]:last').hasClass('filter-match') );
|
||||
!( val !== '' && c.$filters && c.$filters.eq(indx).find('select').length && !c.$headerIndexed[indx].hasClass('filter-match') );
|
||||
}
|
||||
}
|
||||
notFiltered = $rows.not('.' + wo.filter_filteredRow).length;
|
||||
@ -1340,7 +1340,7 @@ ts.filter = {
|
||||
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
|
||||
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
|
||||
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
|
||||
$cell = c.$headers.filter('[data-column="' + columnIndex + '"]:last');
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
@ -1443,7 +1443,7 @@ ts.filter = {
|
||||
return $.inArray(value, arry) === indx;
|
||||
});
|
||||
|
||||
if (c.$headers.filter('[data-column="' + column + '"]:last').hasClass('filter-select-nosort')) {
|
||||
if (c.$headerIndexed[column].hasClass('filter-select-nosort')) {
|
||||
// unsorted select options
|
||||
return arry;
|
||||
} else {
|
||||
@ -1498,7 +1498,7 @@ ts.filter = {
|
||||
// check if has class filtered
|
||||
if (onlyAvail && row.className.match(wo.filter_filteredRow)) { continue; }
|
||||
// get non-normalized cell content
|
||||
if (wo.filter_useParsedData || c.parsers[column].parsed || c.$headers.filter('[data-column="' + column + '"]:last').hasClass('filter-parsed')) {
|
||||
if (wo.filter_useParsedData || c.parsers[column].parsed || c.$headerIndexed[column].hasClass('filter-parsed')) {
|
||||
arry.push( '' + cache.normalized[rowIndex][column] );
|
||||
} else {
|
||||
cell = row.cells[column];
|
||||
@ -1517,7 +1517,7 @@ ts.filter = {
|
||||
var indx, val, txt, t, $filters, $filter,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
node = c.$headers.filter('[data-column="' + column + '"]:last'),
|
||||
node = c.$headerIndexed[column],
|
||||
// t.data('placeholder') won't work in jQuery older than 1.4.3
|
||||
options = '<option value="">' + ( node.data('placeholder') || node.attr('data-placeholder') || wo.filter_placeholder.select || '' ) + '</option>',
|
||||
// Get curent filter value
|
||||
@ -1572,7 +1572,7 @@ ts.filter = {
|
||||
columns = c.columns;
|
||||
// build default select dropdown
|
||||
for (columnIndex = 0; columnIndex < columns; columnIndex++) {
|
||||
$header = c.$headers.filter('[data-column="' + columnIndex + '"]:last');
|
||||
$header = c.$headerIndexed[columnIndex];
|
||||
noSelect = !($header.hasClass('filter-false') || $header.hasClass('parser-false'));
|
||||
// look for the filter-select class; build/update it if found
|
||||
if (($header.hasClass('filter-select') || ts.getColumnData( table, wo.filter_functions, columnIndex ) === true) && noSelect) {
|
||||
|
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
4
dist/js/jquery.tablesorter.widgets.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/parsers/parser-metric.min.js
vendored
2
dist/js/parsers/parser-metric.min.js
vendored
@ -4,4 +4,4 @@
|
||||
* <th data-metric-name="b|byte">HDD Size</th>
|
||||
* <th data-metric-name="m|meter">Distance</th>
|
||||
*/
|
||||
!function(a){"use strict";var b={"Y|Yotta|yotta":[1e24,Math.pow(1024,8)],"Z|Zetta|zetta":[1e21,Math.pow(1024,7)],"E|Exa|exa":[1e18,Math.pow(1024,6)],"P|Peta|peta":[1e15,Math.pow(1024,5)],"T|Tera|tera":[1e12,Math.pow(1024,4)],"G|Giga|giga":[1e9,Math.pow(1024,3)],"M|Mega|mega":[1e6,Math.pow(1024,2)],"k|Kilo|kilo":[1e3,1024],"h|hecto":[100,100],"da|deka":[10,10],"d|deci":[.1,.1],"c|centi":[.01,.01],"m|milli":[.001,.001],"µ|micro":[1e-6,1e-6],"n|nano":[1e-9,1e-9],"p|pico":[1e-12,1e-12],"f|femto":[1e-15,1e-15],"a|atto":[1e-18,1e-18],"z|zepto":[1e-21,1e-21],"y|yocto":[1e-24,1e-24]},c="(\\d+)(\\s+)?([Zz]etta|[Ee]xa|[Pp]eta|[Tt]era|[Gg]iga|[Mm]ega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|femto|atto|zepto|yocto)(",d="(\\d+)(\\s+)?(Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)(";a.tablesorter.addParser({id:"metric",is:function(){return!1},format:function(e,f,g,h){var i,j,k="m|meter",l=a.tablesorter.formatFloat(e.replace(/[^\w,. \-()]/g,""),f),m=f.config.$headers.filter('[data-column="'+h+'"]'),n=m.data("metric");if(n||(j=(m.attr("data-metric-name")||k).split("|"),n=[j[1]||j[0].substring(1),j[0]],n[2]=new RegExp(c+n[0]+"|"+n[1]+")"),n[3]=new RegExp(d+n[1]+")"),m.data("metric",n)),j=e.match(n[2])||e.match(n[3]))for(k in b)if(j[3].match(k))return i=/^[b|bit|byte|o|octet]/.test(j[4])?1:0,l*b[k][i];return l},type:"numeric"})}(jQuery);
|
||||
!function(a){"use strict";var b={"Y|Yotta|yotta":[1e24,Math.pow(1024,8)],"Z|Zetta|zetta":[1e21,Math.pow(1024,7)],"E|Exa|exa":[1e18,Math.pow(1024,6)],"P|Peta|peta":[1e15,Math.pow(1024,5)],"T|Tera|tera":[1e12,Math.pow(1024,4)],"G|Giga|giga":[1e9,Math.pow(1024,3)],"M|Mega|mega":[1e6,Math.pow(1024,2)],"k|Kilo|kilo":[1e3,1024],"h|hecto":[100,100],"da|deka":[10,10],"d|deci":[.1,.1],"c|centi":[.01,.01],"m|milli":[.001,.001],"µ|micro":[1e-6,1e-6],"n|nano":[1e-9,1e-9],"p|pico":[1e-12,1e-12],"f|femto":[1e-15,1e-15],"a|atto":[1e-18,1e-18],"z|zepto":[1e-21,1e-21],"y|yocto":[1e-24,1e-24]},c="(\\d+)(\\s+)?([Zz]etta|[Ee]xa|[Pp]eta|[Tt]era|[Gg]iga|[Mm]ega|kilo|hecto|deka|deci|centi|milli|micro|nano|pico|femto|atto|zepto|yocto)(",d="(\\d+)(\\s+)?(Z|E|P|T|G|M|k|h|da|d|c|m|µ|n|p|f|a|z|y)(";a.tablesorter.addParser({id:"metric",is:function(){return!1},format:function(e,f,g,h){var i,j,k="m|meter",l=a.tablesorter.formatFloat(e.replace(/[^\w,. \-()]/g,""),f),m=f.config.$headerIndexed[h],n=m.data("metric");if(n||(j=(m.attr("data-metric-name")||k).split("|"),n=[j[1]||j[0].substring(1),j[0]],n[2]=new RegExp(c+n[0]+"|"+n[1]+")"),n[3]=new RegExp(d+n[1]+")"),m.data("metric",n)),j=e.match(n[2])||e.match(n[3]))for(k in b)if(j[3].match(k))return i=/^[b|bit|byte|o|octet]/.test(j[4])?1:0,l*b[k][i];return l},type:"numeric"})}(jQuery);
|
@ -1,4 +1,4 @@
|
||||
/*! Filter widget select2 formatter function - updated 2/7/2015 (v2.19.0)
|
||||
* requires: jQuery 1.7.2+, tableSorter (FORK) 2.16+, filter widget 2.16+ and select2 v3.4.6+ plugin
|
||||
*/
|
||||
!function(a){"use strict";var b=a.tablesorter||{};b.filterFormatter=b.filterFormatter||{},b.filterFormatter.select2=function(c,d,e){var f,g,h=a.extend({cellText:"",match:!0,value:"",multiple:!0,width:"100%"},e),i=c.closest("table")[0].config,j=i.widgetOptions,k=a('<input class="filter" type="hidden">').appendTo(c).bind("change"+i.namespace+"filter",function(){var a=this.value;a=a.replace(/[/()$^]/g,"").split("|"),c.find(".select2").select2("val",a),q()}),l=i.$headers.filter('[data-column="'+d+'"]:last'),m=l.hasClass(j.filter_onlyAvail),n=[],o=h.match?"":"^",p=h.match?"":"$",q=function(){var b=!1,d=c.find(".select2").select2("val")||h.value||"";a.isArray(d)&&(b=!0,d=d.join("\x00")),d=d.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),b&&(d=d.split("\x00")),k.val(a.isArray(d)&&d.length&&""!==d.join("")?"/("+o+(d||[]).join(p+"|"+o)+p+")/":"").trigger("search").end().find(".select2").select2("val",d),n.length&&n.find(".select2").select2("val",d)},r=function(){g=[],f=b.filter.getOptionSource(i.$table[0],d,m)||[],a.each(f,function(a,b){g.push({id:b,text:b})}),h.data=g};return l.toggleClass("filter-match",h.match),h.cellText&&c.prepend("<label>"+h.cellText+"</label>"),h.ajax&&!a.isEmptyObject(h.ajax)||h.data||(r(),m&&i.$table.bind("filterEnd",function(){r(),c.add(n).find(".select2").select2(h)})),a('<input class="select2 select2-'+d+'" type="hidden" />').val(h.value).appendTo(c).select2(h).bind("change",function(){q()}),i.$table.bind("filterFomatterUpdate",function(){var a=i.$table.data("lastSearch")[d]||"";a=a.replace(/^\/\(\^?/,"").replace(/\$\|\^/g,"|").replace(/\$?\)\/$/g,"").split("|"),c.find(".select2").select2("val",a),q(),b.filter.formatterUpdated(c,d)}),i.$table.bind("stickyHeadersInit",function(){n=i.widgetOptions.$sticky.find(".tablesorter-filter-row").children().eq(d).empty(),a('<input class="select2 select2-'+d+'" type="hidden">').val(h.value).appendTo(n).select2(h).bind("change",function(){c.find(".select2").select2("val",n.find(".select2").select2("val")),q()}),h.cellText&&n.prepend("<label>"+h.cellText+"</label>")}),i.$table.bind("filterReset",function(){c.find(".select2").select2("val",h.value||""),setTimeout(function(){q()},0)}),q(),k}}(jQuery);
|
||||
!function(a){"use strict";var b=a.tablesorter||{};b.filterFormatter=b.filterFormatter||{},b.filterFormatter.select2=function(c,d,e){var f,g,h=a.extend({cellText:"",match:!0,value:"",multiple:!0,width:"100%"},e),i=c.closest("table")[0].config,j=i.widgetOptions,k=a('<input class="filter" type="hidden">').appendTo(c).bind("change"+i.namespace+"filter",function(){var a=this.value;a=a.replace(/[/()$^]/g,"").split("|"),c.find(".select2").select2("val",a),q()}),l=i.$headerIndexed[d],m=l.hasClass(j.filter_onlyAvail),n=[],o=h.match?"":"^",p=h.match?"":"$",q=function(){var b=!1,d=c.find(".select2").select2("val")||h.value||"";a.isArray(d)&&(b=!0,d=d.join("\x00")),d=d.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),b&&(d=d.split("\x00")),k.val(a.isArray(d)&&d.length&&""!==d.join("")?"/("+o+(d||[]).join(p+"|"+o)+p+")/":"").trigger("search").end().find(".select2").select2("val",d),n.length&&n.find(".select2").select2("val",d)},r=function(){g=[],f=b.filter.getOptionSource(i.$table[0],d,m)||[],a.each(f,function(a,b){g.push({id:b,text:b})}),h.data=g};return l.toggleClass("filter-match",h.match),h.cellText&&c.prepend("<label>"+h.cellText+"</label>"),h.ajax&&!a.isEmptyObject(h.ajax)||h.data||(r(),m&&i.$table.bind("filterEnd",function(){r(),c.add(n).find(".select2").select2(h)})),a('<input class="select2 select2-'+d+'" type="hidden" />').val(h.value).appendTo(c).select2(h).bind("change",function(){q()}),i.$table.bind("filterFomatterUpdate",function(){var a=i.$table.data("lastSearch")[d]||"";a=a.replace(/^\/\(\^?/,"").replace(/\$\|\^/g,"|").replace(/\$?\)\/$/g,"").split("|"),c.find(".select2").select2("val",a),q(),b.filter.formatterUpdated(c,d)}),i.$table.bind("stickyHeadersInit",function(){n=i.widgetOptions.$sticky.find(".tablesorter-filter-row").children().eq(d).empty(),a('<input class="select2 select2-'+d+'" type="hidden">').val(h.value).appendTo(n).select2(h).bind("change",function(){c.find(".select2").select2("val",n.find(".select2").select2("val")),q()}),h.cellText&&n.prepend("<label>"+h.cellText+"</label>")}),i.$table.bind("filterReset",function(){c.find(".select2").select2("val",h.value||""),setTimeout(function(){q()},0)}),q(),k}}(jQuery);
|
2
dist/js/widgets/widget-filter.min.js
vendored
2
dist/js/widgets/widget-filter.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-formatter.min.js
vendored
2
dist/js/widgets/widget-formatter.min.js
vendored
@ -2,4 +2,4 @@
|
||||
* Requires tablesorter v2.8+ and jQuery 1.7+
|
||||
* by Rob Garrison
|
||||
*/
|
||||
!function(a){"use strict";var b=a.tablesorter;b.formatter={init:function(a){var c=a.widgetOptions.formatter_event+" pagerComplete updateComplete ".split(" ").join(".tsformatter ");a.$table.off(c.replace(/\s+/g," ")).on(c,function(){b.formatter.setup(a)}),b.formatter.setup(a)},setup:function(c){if(!a.isEmptyObject(c.cache)){var d,e,f,g,h,i,j,k=c.widgetOptions,l={config:c,wo:k},m=[],n=[];for(j=0;j<c.columns;j++)n[j]=c.$headers.filter('[data-column="'+j+'"]:last'),m[j]=b.getColumnData(c.table,k.formatter_column,j)||!1;for(e=0;e<c.$tbodies.length;e++){for(d=b.processTbody(c.table,c.$tbodies.eq(e),!0),g=c.cache[e],i=g.normalized.length,f=0;i>f;f++)for(l.$row=g.normalized[f][c.columns].$row,l.$cells=l.$row.children("th, td"),j=0;j<c.columns;j++)m[j]&&(l.columnIndex=j,l.$header=n[j],l.$cell=l.$cells.eq(j),h=l.$cell[0],l.text=h.getAttribute(c.textAttribute)||h.textContent||l.$cell.text(),h.innerHTML=m[j](l.text,l));b.processTbody(c.table,d,!1)}}}},b.addWidget({id:"formatter",priority:100,options:{formatter_column:{},formatter_event:"applyFormatter"},init:function(a){b.formatter.init(a.config)}})}(jQuery);
|
||||
!function(a){"use strict";var b=a.tablesorter;b.formatter={init:function(a){var c=a.widgetOptions.formatter_event+" pagerComplete updateComplete ".split(" ").join(".tsformatter ");a.$table.off(c.replace(/\s+/g," ")).on(c,function(){b.formatter.setup(a)}),b.formatter.setup(a)},setup:function(c){if(!a.isEmptyObject(c.cache)){var d,e,f,g,h,i,j,k=c.widgetOptions,l={config:c,wo:k},m=[],n=[];for(j=0;j<c.columns;j++)n[j]=c.$headerIndexed[j],m[j]=b.getColumnData(c.table,k.formatter_column,j)||!1;for(e=0;e<c.$tbodies.length;e++){for(d=b.processTbody(c.table,c.$tbodies.eq(e),!0),g=c.cache[e],i=g.normalized.length,f=0;i>f;f++)for(l.$row=g.normalized[f][c.columns].$row,l.$cells=l.$row.children("th, td"),j=0;j<c.columns;j++)m[j]&&(l.columnIndex=j,l.$header=n[j],l.$cell=l.$cells.eq(j),h=l.$cell[0],l.text=h.getAttribute(c.textAttribute)||h.textContent||l.$cell.text(),h.innerHTML=m[j](l.text,l));b.processTbody(c.table,d,!1)}}}},b.addWidget({id:"formatter",priority:100,options:{formatter_column:{},formatter_event:"applyFormatter"},init:function(a){b.formatter.init(a.config)}})}(jQuery);
|
2
dist/js/widgets/widget-grouping.min.js
vendored
2
dist/js/widgets/widget-grouping.min.js
vendored
File diff suppressed because one or more lines are too long
@ -5304,14 +5304,14 @@ $('table').trigger( 'search', [['', '', '', '', 'orange']] ); // find orange in
|
||||
<tr id="variable-instanceMethods">
|
||||
<td><a href="#" class="permalink">$.tablesorter.instanceMethods</a></td>
|
||||
<td>Object</td>
|
||||
<td>This is an object of all instance methods of config object. They can be added using the <a href="#function-addInstanceMethods"><code>addInstanceMethods</code></a> function before table initialization.
|
||||
<td>This variable contains all instance methods of the config object. Added using <a href="#function-addInstanceMethods"><code>addInstanceMethods</code></a> function before table initialization (<span class="version">v2.20.2</span>).
|
||||
<div class="collapsible">
|
||||
<pre class="prettyprint lang-js">
|
||||
$.tablesorter.addInstanceMethods({
|
||||
<br>
|
||||
<pre class="prettyprint lang-js">$.tablesorter.addInstanceMethods({
|
||||
columnSum: function(colNumber) {
|
||||
var sum = 0, tbodyIndex, normalizedRows, rowIndex;
|
||||
// `this` refer to config object
|
||||
for (tbodyIndex = 0; tbodyIndex < this.$tbodies.length; ++tbodyIndex){
|
||||
// `this` refers to config object
|
||||
for (tbodyIndex = 0; tbodyIndex < this.$tbodies.length; ++tbodyIndex) {
|
||||
normalizedRows = this.cache[tbodyIndex].normalized;
|
||||
for (rowIndex = 0; rowIndex < normalizedRows.length; ++rowIndex) {
|
||||
sum += normalizedRows[rowIndex][colNumber];
|
||||
@ -5327,12 +5327,7 @@ $.tablesorter.addInstanceMethods({
|
||||
$('table').tablesorter();
|
||||
c = $('table')[0].config;
|
||||
console.log('sum of third column: ' + c.columnSum(2));
|
||||
console.log('mean of third column: ' + c.columnMean(2));
|
||||
</pre>
|
||||
Some predefined instance methods are already defined:
|
||||
<ul>
|
||||
<li><code>c.$columnHeader(n, options)</code> returns n-th header cell.</li>
|
||||
</ul>
|
||||
console.log('mean of third column: ' + c.columnMean(2));</pre>
|
||||
</div>
|
||||
</td>
|
||||
<td></td>
|
||||
@ -5531,6 +5526,39 @@ $('.tablesorter')[0].config.cache[0].normalized[0];
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr id="variable-header-indexed">
|
||||
<td><a href="#" class="permalink">config.$headerIndexed</a></td>
|
||||
<td>Array</td>
|
||||
<td>Internally stored Array of headers that represent each column (<span class="version">v2.20.2</span>)
|
||||
<div class="collapsible">
|
||||
<br>
|
||||
The <code>table.config.$headers</code> variable contains ALL header cells, not all of which contain sorting information (data-attributes, class names or sorting information).
|
||||
<p></p>
|
||||
This variable targets the <em>last sortable header cell</em> in a particular column; unless an entire column is completely unsortable (checkbox column), then it just picks the last cell in that column.
|
||||
<p></p>
|
||||
To make that description less confusing, look at the HTML in the <a href="#variable-headers"><code>config.$headers</code></a> documentation, only the four middle rows (header-index 1-4) will be contained within this variable:
|
||||
<pre class="prettyprint lang-js">// the resulting config.$headerIndexed for the HTML example in config.$headers will look like this:
|
||||
console.log( table.config.$headerIndexed );
|
||||
/* outputs : [
|
||||
$('<th data-column="0">header-index 1</th>'),
|
||||
$('<th data-column="1">header-index 2</th>'),
|
||||
$('<th data-column="2">header-index 3</th>'),
|
||||
$('<th data-column="3">header-index 4</th>')
|
||||
] */</pre>
|
||||
<p></p>
|
||||
<span class="label label-warning">* NOTE *</span> This variable contains an array of jQuery objects, it is <em>not</em> a collection of jQuery objects, i.e.
|
||||
<pre class="prettyprint lang-js">var $column = table.config.$headerIndexed[ 0 ]; // jQuery object returned
|
||||
console.log( $column.hasClass('foo') ); // how to access information
|
||||
|
||||
var $headers = $( table.config.$headerIndexed ); // make a collection of jQuery objects
|
||||
// then use collection manipulation functions
|
||||
$headers.each(function(){
|
||||
console.log( $(this).text() );
|
||||
});</pre></div>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
|
||||
<tr id="variable-headers">
|
||||
<td><a href="#" class="permalink">config.$headers</a></td>
|
||||
<td>jQuery Object</td>
|
||||
@ -5542,7 +5570,7 @@ $('.tablesorter')[0].config.cache[0].normalized[0];
|
||||
Please note that the headers cells are simply an array of all header cells and should not be targeted using a column index. For example, given the following table <code>thead</code> markup, the <code>header-index</code> counts the header <code>th</code> cells and does not actually match the <code>data-column</code> index when extra rows and/or <code>colspan</code> or <code>rowspan</code> are included in any of the header cells:
|
||||
<pre class="prettyprint lang-html"><thead>
|
||||
<tr>
|
||||
<th colspan="4" data-column="0">header-index 0</th>
|
||||
<th colspan="4" data-column="0" class="sorter-false">header-index 0</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th data-column="0">header-index 1</th>
|
||||
@ -5551,8 +5579,8 @@ $('.tablesorter')[0].config.cache[0].normalized[0];
|
||||
<th data-column="3">header-index 4</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th colspan="2" data-column="0">header-index 5</th>
|
||||
<th colspan="2" data-column="2">header-index 6</th>
|
||||
<th colspan="2" data-column="0" class="sorter-false">header-index 5</th>
|
||||
<th colspan="2" data-column="2" class="sorter-false">header-index 6</th>
|
||||
</tr>
|
||||
</thead></pre>
|
||||
So, in the above example, to target the header cell in the second table column (<code>data-column</code> index of 1), use the following code: <code>table.config.$headers.filter('[data-column="1"]')</code> or <code>table.config.$headers.eq(2)</code>.<br>
|
||||
@ -6219,12 +6247,12 @@ $.tablesorter.isValueInArray(2, sortList);</pre>
|
||||
|
||||
<tr id="function-addInstanceMethods">
|
||||
<td><a href="#" class="permalink">addInstanceMethods</a></td>
|
||||
<td>This function allows to add custom methods for config object.
|
||||
<td>This function allows to add custom methods for config object (<span class="version">v2.20.2</span>).
|
||||
<div class="collapsible"><br>
|
||||
Access it as follows:
|
||||
<pre class="prettyprint lang-js">$.tablesorter.addInstanceMethods(methods);</pre>
|
||||
<ul>
|
||||
<li><code>methods</code> - an object containing methods to be added, indexed by method names. These methods can use config object by refering <code>this</code></li>
|
||||
<li><code>methods</code> - an object containing methods to be added, indexed by method names. These methods can use config object by refering <code>this</code>.</li>
|
||||
</ul>
|
||||
Take a look at <a href="#variable-instanceMethods">instanceMethods</a> variable description for more details.
|
||||
</div>
|
||||
|
@ -155,16 +155,7 @@
|
||||
};
|
||||
|
||||
// These methods can be applied on table.config instance
|
||||
ts.instanceMethods = {
|
||||
// Returns a jQuery object of n-th column header
|
||||
$columnHeader: function(n, options) {
|
||||
var $headers, lastOnly;
|
||||
options = options || {},
|
||||
$headers = (options.headers !== undefined) ? $(options.headers) : this.$headers;
|
||||
lastOnly = (options.lastOnly !== undefined) ? options.lastOnly : true;
|
||||
return lastOnly ? $headers.filter('[data-column="' + n + '"]:last') : $headers.filter('[data-column="' + n + '"]');
|
||||
},
|
||||
};
|
||||
ts.instanceMethods = {};
|
||||
|
||||
/* debuging utils */
|
||||
function log() {
|
||||
@ -268,7 +259,7 @@
|
||||
if (rows.length) {
|
||||
l = c.columns; // rows[j].cells.length;
|
||||
for (i = 0; i < l; i++) {
|
||||
h = c.$columnHeader(i);
|
||||
h = c.$headerIndexed[i];
|
||||
// get column indexed table cell
|
||||
ch = ts.getColumnData( table, c.headers, i );
|
||||
// get column parser/extractor
|
||||
@ -457,8 +448,7 @@
|
||||
}
|
||||
|
||||
function buildHeaders(table) {
|
||||
var ch, $t,
|
||||
h, i, t, lock, time,
|
||||
var ch, $t, h, i, t, lock, time, indx,
|
||||
c = table.config;
|
||||
c.headerList = [];
|
||||
c.headerContent = [];
|
||||
@ -507,6 +497,13 @@
|
||||
if (c.tabIndex) { $t.attr('tabindex', 0); }
|
||||
return elem;
|
||||
}));
|
||||
// cache headers per column
|
||||
c.$headerIndexed = [];
|
||||
for (indx = 0; indx < c.columns; indx++) {
|
||||
$t = c.$headers.filter('[data-column="' + indx + '"]');
|
||||
// target sortable column cells, unless there are none, then use non-sortable cells
|
||||
c.$headerIndexed[indx] = $t.not('.sorter-false').length ? $t.not('.sorter-false').last() : $t.last();
|
||||
}
|
||||
$(table).find(c.selectorHeaders).attr({
|
||||
scope: 'col',
|
||||
role : 'columnheader'
|
||||
@ -573,7 +570,7 @@
|
||||
// direction = 2 means reset!
|
||||
if (list[i][1] !== 2) {
|
||||
// multicolumn sorting updating - choose the :last in case there are nested columns
|
||||
f = c.$columnHeader(list[i][0], {lastOnly: (len === 1)}).not('.sorter-false');
|
||||
f = c.$headers.not('.sorter-false').filter('[data-column="' + list[i][0] + '"]' + (len === 1 ? ':last' : '') );
|
||||
if (f.length) {
|
||||
for (j = 0; j < f.length; j++) {
|
||||
if (!f[j].sortDisabled) {
|
||||
@ -615,7 +612,7 @@
|
||||
// ensure all sortList values are numeric - fixes #127
|
||||
col = parseInt(val[0], 10);
|
||||
// make sure header exists
|
||||
header = c.$columnHeader(col)[0];
|
||||
header = c.$headerIndexed[col][0];
|
||||
if (header) { // prevents error if sorton array is wrong
|
||||
// o.count = o.count + 1;
|
||||
dir = ('' + val[1]).match(/^(1|d|s|o|n)/);
|
||||
@ -719,7 +716,7 @@
|
||||
// reverse the sorting direction
|
||||
for (col = 0; col < c.sortList.length; col++) {
|
||||
s = c.sortList[col];
|
||||
order = c.$columnHeader( s[0] )[0];
|
||||
order = c.$headerIndexed[ s[0] ][0];
|
||||
if (s[0] === indx) {
|
||||
// order.count seems to be incorrect when compared to cell.count
|
||||
s[1] = order.order[cell.count];
|
||||
@ -1985,7 +1982,7 @@
|
||||
if (s) {
|
||||
var date, d,
|
||||
c = table.config,
|
||||
ci = c.$columnHeader(cellIndex),
|
||||
ci = c.$headerIndexed[ cellIndex ],
|
||||
format = ci.length && ci[0].dateFormat || ts.getData( ci, ts.getColumnData( table, c.headers, cellIndex ), 'dateFormat') || c.dateFormat;
|
||||
d = s.replace(/\s+/g, ' ').replace(/[\-.,]/g, '/'); // escaped - because JSHint in Firefox was showing it as an error
|
||||
if (format === 'mmddyyyy') {
|
||||
|
@ -4,7 +4,7 @@
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||
*/
|
||||
/*! tablesorter (FORK) widgets - updated 02-26-2015 (v2.20.1)*/
|
||||
/*! tablesorter (FORK) widgets - updated 02-27-2015 (v2.20.1)*/
|
||||
/* Includes: storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort */
|
||||
/*! Widget: storage */
|
||||
;(function ($, window, document) {
|
||||
@ -558,7 +558,7 @@ ts.filter = {
|
||||
parsed = data.parsed[index],
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed);
|
||||
// look for an exact match with the "or" unless the "filter-match" class is found
|
||||
if (!c.$headers.filter('[data-column="' + index + '"]:last').hasClass('filter-match') && /\|/.test(query)) {
|
||||
if (!c.$headerIndexed[index].hasClass('filter-match') && /\|/.test(query)) {
|
||||
// show all results while using filter match. Fixes #727
|
||||
if (query[ query.length - 1 ] === '|') { query += '*'; }
|
||||
query = data.anyMatch && $.isArray(data.rowArray) ? '(' + query + ')' : '^(' + query + ')$';
|
||||
@ -679,7 +679,7 @@ ts.filter = {
|
||||
fxn = ts.getColumnData( table, wo.filter_functions, column );
|
||||
if (fxn) {
|
||||
// remove "filter-select" from header otherwise the options added here are replaced with all options
|
||||
$header = c.$headers.filter('[data-column="' + column + '"]:last').removeClass('filter-select');
|
||||
$header = c.$headerIndexed[column].removeClass('filter-select');
|
||||
// don't build select if "filter-false" or "parser-false" set
|
||||
noSelect = !($header.hasClass('filter-false') || $header.hasClass('parser-false'));
|
||||
options = '';
|
||||
@ -852,7 +852,7 @@ ts.filter = {
|
||||
for (column = 0; column < columns; column++) {
|
||||
disabled = false;
|
||||
// assuming last cell of a column is the main column
|
||||
$header = c.$headers.filter('[data-column="' + column + '"]:last');
|
||||
$header = c.$headerIndexed[column];
|
||||
ffxn = ts.getColumnData( table, wo.filter_functions, column );
|
||||
buildSelect = (wo.filter_functions && ffxn && typeof ffxn !== "function" ) ||
|
||||
$header.hasClass('filter-select');
|
||||
@ -1140,7 +1140,7 @@ ts.filter = {
|
||||
data.parsed = c.$headers.map(function(columnIndex) {
|
||||
return c.parsers && c.parsers[columnIndex] && c.parsers[columnIndex].parsed ||
|
||||
// getData won't return "parsed" if other "filter-" class names exist (e.g. <th class="filter-select filter-parsed">)
|
||||
ts.getData && ts.getData(c.$headers.filter('[data-column="' + columnIndex + '"]:last'), ts.getColumnData( table, c.headers, columnIndex ), 'filter') === 'parsed' ||
|
||||
ts.getData && ts.getData(c.$headerIndexed[columnIndex], ts.getColumnData( table, c.headers, columnIndex ), 'filter') === 'parsed' ||
|
||||
$(this).hasClass('filter-parsed');
|
||||
}).get();
|
||||
|
||||
@ -1216,7 +1216,7 @@ ts.filter = {
|
||||
// don't search only filtered if the value is negative ('> -10' => '> -100' will ignore hidden rows)
|
||||
!(/(>=?\s*-\d)/.test(val) || /(<=?\s*\d)/.test(val)) &&
|
||||
// if filtering using a select without a "filter-match" class (exact match) - fixes #593
|
||||
!( val !== '' && c.$filters && c.$filters.eq(indx).find('select').length && !c.$headers.filter('[data-column="' + indx + '"]:last').hasClass('filter-match') );
|
||||
!( val !== '' && c.$filters && c.$filters.eq(indx).find('select').length && !c.$headerIndexed[indx].hasClass('filter-match') );
|
||||
}
|
||||
}
|
||||
notFiltered = $rows.not('.' + wo.filter_filteredRow).length;
|
||||
@ -1346,7 +1346,7 @@ ts.filter = {
|
||||
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
|
||||
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
|
||||
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
|
||||
$cell = c.$headers.filter('[data-column="' + columnIndex + '"]:last');
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
@ -1449,7 +1449,7 @@ ts.filter = {
|
||||
return $.inArray(value, arry) === indx;
|
||||
});
|
||||
|
||||
if (c.$headers.filter('[data-column="' + column + '"]:last').hasClass('filter-select-nosort')) {
|
||||
if (c.$headerIndexed[column].hasClass('filter-select-nosort')) {
|
||||
// unsorted select options
|
||||
return arry;
|
||||
} else {
|
||||
@ -1504,7 +1504,7 @@ ts.filter = {
|
||||
// check if has class filtered
|
||||
if (onlyAvail && row.className.match(wo.filter_filteredRow)) { continue; }
|
||||
// get non-normalized cell content
|
||||
if (wo.filter_useParsedData || c.parsers[column].parsed || c.$headers.filter('[data-column="' + column + '"]:last').hasClass('filter-parsed')) {
|
||||
if (wo.filter_useParsedData || c.parsers[column].parsed || c.$headerIndexed[column].hasClass('filter-parsed')) {
|
||||
arry.push( '' + cache.normalized[rowIndex][column] );
|
||||
} else {
|
||||
cell = row.cells[column];
|
||||
@ -1523,7 +1523,7 @@ ts.filter = {
|
||||
var indx, val, txt, t, $filters, $filter,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
node = c.$headers.filter('[data-column="' + column + '"]:last'),
|
||||
node = c.$headerIndexed[column],
|
||||
// t.data('placeholder') won't work in jQuery older than 1.4.3
|
||||
options = '<option value="">' + ( node.data('placeholder') || node.attr('data-placeholder') || wo.filter_placeholder.select || '' ) + '</option>',
|
||||
// Get curent filter value
|
||||
@ -1578,7 +1578,7 @@ ts.filter = {
|
||||
columns = c.columns;
|
||||
// build default select dropdown
|
||||
for (columnIndex = 0; columnIndex < columns; columnIndex++) {
|
||||
$header = c.$headers.filter('[data-column="' + columnIndex + '"]:last');
|
||||
$header = c.$headerIndexed[columnIndex];
|
||||
noSelect = !($header.hasClass('filter-false') || $header.hasClass('parser-false'));
|
||||
// look for the filter-select class; build/update it if found
|
||||
if (($header.hasClass('filter-select') || ts.getColumnData( table, wo.filter_functions, columnIndex ) === true) && noSelect) {
|
||||
|
@ -47,7 +47,7 @@
|
||||
b, t,
|
||||
// process number here to get a numerical format (us or eu)
|
||||
n = $.tablesorter.formatFloat(s.replace(/[^\w,. \-()]/g, ""), table),
|
||||
$t = table.config.$columnHeader(cellIndex, {lastOnly: false}),
|
||||
$t = table.config.$headerIndexed[cellIndex],
|
||||
m = $t.data('metric');
|
||||
if (!m) {
|
||||
// stored values
|
||||
|
@ -36,7 +36,7 @@ ts.filterFormatter.select2 = function($cell, indx, select2Def) {
|
||||
$cell.find('.select2').select2('val', val);
|
||||
updateSelect2();
|
||||
}),
|
||||
$header = c.$columnHeader(indx),
|
||||
$header = c.$headerIndexed[indx],
|
||||
onlyAvail = $header.hasClass(wo.filter_onlyAvail),
|
||||
$shcell = [],
|
||||
matchPrefix = o.match ? '' : '^',
|
||||
|
@ -209,7 +209,7 @@ ts.filter = {
|
||||
parsed = data.parsed[index],
|
||||
query = ts.filter.parseFilter(c, data.iFilter.replace(ts.filter.regex.orReplace, "|"), index, parsed);
|
||||
// look for an exact match with the "or" unless the "filter-match" class is found
|
||||
if (!c.$columnHeader(index).hasClass('filter-match') && /\|/.test(query)) {
|
||||
if (!c.$headerIndexed[index].hasClass('filter-match') && /\|/.test(query)) {
|
||||
// show all results while using filter match. Fixes #727
|
||||
if (query[ query.length - 1 ] === '|') { query += '*'; }
|
||||
query = data.anyMatch && $.isArray(data.rowArray) ? '(' + query + ')' : '^(' + query + ')$';
|
||||
@ -330,7 +330,7 @@ ts.filter = {
|
||||
fxn = ts.getColumnData( table, wo.filter_functions, column );
|
||||
if (fxn) {
|
||||
// remove "filter-select" from header otherwise the options added here are replaced with all options
|
||||
$header = c.$columnHeader(column).removeClass('filter-select');
|
||||
$header = c.$headerIndexed[column].removeClass('filter-select');
|
||||
// don't build select if "filter-false" or "parser-false" set
|
||||
noSelect = !($header.hasClass('filter-false') || $header.hasClass('parser-false'));
|
||||
options = '';
|
||||
@ -469,17 +469,12 @@ ts.filter = {
|
||||
}
|
||||
// if no filters saved, then check default settings
|
||||
if (filters.join('') === '') {
|
||||
<<<<<<< HEAD
|
||||
// allow adding default setting to external filters
|
||||
$filters = c.$headers.add( wo.filter_$externalFilters ).filter('[' + wo.filter_defaultAttrib + ']');
|
||||
for (indx = 0; indx <= c.columns; indx++) {
|
||||
// include data-column="all" external filters
|
||||
col = indx === c.columns ? 'all' : indx;
|
||||
filters[indx] = $filters.filter('[data-column="' + col + '"]').attr(wo.filter_defaultAttrib) || filters[indx] || '';
|
||||
=======
|
||||
for (indx = 0; indx < c.columns; indx++) {
|
||||
filters[indx] = c.$columnHeader(indx).attr(wo.filter_defaultAttrib) || filters[indx];
|
||||
>>>>>>> c71e8f6220bc41a458e55f0d35076b9782bb53fc
|
||||
}
|
||||
}
|
||||
c.$table.data('lastSearch', filters);
|
||||
@ -508,7 +503,7 @@ ts.filter = {
|
||||
for (column = 0; column < columns; column++) {
|
||||
disabled = false;
|
||||
// assuming last cell of a column is the main column
|
||||
$header = c.$columnHeader(column);
|
||||
$header = c.$headerIndexed[column];
|
||||
ffxn = ts.getColumnData( table, wo.filter_functions, column );
|
||||
buildSelect = (wo.filter_functions && ffxn && typeof ffxn !== "function" ) ||
|
||||
$header.hasClass('filter-select');
|
||||
@ -796,7 +791,7 @@ ts.filter = {
|
||||
data.parsed = c.$headers.map(function(columnIndex) {
|
||||
return c.parsers && c.parsers[columnIndex] && c.parsers[columnIndex].parsed ||
|
||||
// getData won't return "parsed" if other "filter-" class names exist (e.g. <th class="filter-select filter-parsed">)
|
||||
ts.getData && ts.getData(c.$columnHeader(columnIndex), ts.getColumnData( table, c.headers, columnIndex ), 'filter') === 'parsed' ||
|
||||
ts.getData && ts.getData(c.$headerIndexed[columnIndex], ts.getColumnData( table, c.headers, columnIndex ), 'filter') === 'parsed' ||
|
||||
$(this).hasClass('filter-parsed');
|
||||
}).get();
|
||||
|
||||
@ -872,7 +867,7 @@ ts.filter = {
|
||||
// don't search only filtered if the value is negative ('> -10' => '> -100' will ignore hidden rows)
|
||||
!(/(>=?\s*-\d)/.test(val) || /(<=?\s*\d)/.test(val)) &&
|
||||
// if filtering using a select without a "filter-match" class (exact match) - fixes #593
|
||||
!( val !== '' && c.$filters && c.$filters.eq(indx).find('select').length && !c.$columnHeader(indx).hasClass('filter-match') );
|
||||
!( val !== '' && c.$filters && c.$filters.eq(indx).find('select').length && !c.$headerIndexed[indx].hasClass('filter-match') );
|
||||
}
|
||||
}
|
||||
notFiltered = $rows.not('.' + wo.filter_filteredRow).length;
|
||||
@ -1002,7 +997,7 @@ ts.filter = {
|
||||
// data.iFilter = case insensitive (if wo.filter_ignoreCase is true), data.filter = case sensitive
|
||||
data.iFilter = wo.filter_ignoreCase ? (data.filter || '').toLocaleLowerCase() : data.filter;
|
||||
fxn = ts.getColumnData( table, wo.filter_functions, columnIndex );
|
||||
$cell = c.$columnHeader(columnIndex);
|
||||
$cell = c.$headerIndexed[columnIndex];
|
||||
hasSelect = $cell.hasClass('filter-select');
|
||||
if ( fxn || ( hasSelect && val ) ) {
|
||||
if (fxn === true || hasSelect) {
|
||||
@ -1105,7 +1100,7 @@ ts.filter = {
|
||||
return $.inArray(value, arry) === indx;
|
||||
});
|
||||
|
||||
if (c.$columnHeader(column).hasClass('filter-select-nosort')) {
|
||||
if (c.$headerIndexed[column].hasClass('filter-select-nosort')) {
|
||||
// unsorted select options
|
||||
return arry;
|
||||
} else {
|
||||
@ -1160,7 +1155,7 @@ ts.filter = {
|
||||
// check if has class filtered
|
||||
if (onlyAvail && row.className.match(wo.filter_filteredRow)) { continue; }
|
||||
// get non-normalized cell content
|
||||
if (wo.filter_useParsedData || c.parsers[column].parsed || c.$columnHeader(column).hasClass('filter-parsed')) {
|
||||
if (wo.filter_useParsedData || c.parsers[column].parsed || c.$headerIndexed[column].hasClass('filter-parsed')) {
|
||||
arry.push( '' + cache.normalized[rowIndex][column] );
|
||||
} else {
|
||||
cell = row.cells[column];
|
||||
@ -1179,7 +1174,7 @@ ts.filter = {
|
||||
var indx, val, txt, t, $filters, $filter,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
node = c.$columnHeader(column),
|
||||
node = c.$headerIndexed[column],
|
||||
// t.data('placeholder') won't work in jQuery older than 1.4.3
|
||||
options = '<option value="">' + ( node.data('placeholder') || node.attr('data-placeholder') || wo.filter_placeholder.select || '' ) + '</option>',
|
||||
// Get curent filter value
|
||||
@ -1234,7 +1229,7 @@ ts.filter = {
|
||||
columns = c.columns;
|
||||
// build default select dropdown
|
||||
for (columnIndex = 0; columnIndex < columns; columnIndex++) {
|
||||
$header = c.$columnHeader(columnIndex);
|
||||
$header = c.$headerIndexed[columnIndex];
|
||||
noSelect = !($header.hasClass('filter-false') || $header.hasClass('parser-false'));
|
||||
// look for the filter-select class; build/update it if found
|
||||
if (($header.hasClass('filter-select') || ts.getColumnData( table, wo.filter_functions, columnIndex ) === true) && noSelect) {
|
||||
|
@ -29,7 +29,7 @@
|
||||
$headers = [];
|
||||
// set up variables
|
||||
for ( column = 0; column < c.columns; column++ ) {
|
||||
$headers[ column ] = c.$columnHeader(column);
|
||||
$headers[ column ] = c.$headerIndexed[ column ];
|
||||
formatter[ column ] = ts.getColumnData( c.table, wo.formatter_column, column ) || false;
|
||||
}
|
||||
// main loop
|
||||
|
@ -66,12 +66,12 @@ ts.grouping = {
|
||||
// clear pager saved spacer height (in case the rows are collapsed)
|
||||
c.$table.data('pagerSavedHeight', 0);
|
||||
}
|
||||
if (column >= 0 && !c.$columnHeader(column).hasClass('group-false')) {
|
||||
if (column >= 0 && !c.$headerIndexed[column].hasClass('group-false')) {
|
||||
wo.group_currentGroup = ''; // save current groups
|
||||
wo.group_currentGroups = {};
|
||||
|
||||
// group class finds "group-{word/separator/letter/number/date/false}-{optional:#/year/month/day/week/time}"
|
||||
groupClass = (c.$columnHeader(column).attr('class') || '').match(/(group-\w+(-\w+)?)/g);
|
||||
groupClass = (c.$headerIndexed[column].attr('class') || '').match(/(group-\w+(-\w+)?)/g);
|
||||
// grouping = [ 'group', '{word/separator/letter/number/date/false}', '{#/year/month/day/week/time}' ]
|
||||
grouping = groupClass ? groupClass[0].split('-') : ['group','letter',1]; // default to letter 1
|
||||
|
||||
@ -96,15 +96,15 @@ ts.grouping = {
|
||||
if ( $rows.eq(rowIndex).is(':visible') ) {
|
||||
// fixes #438
|
||||
if (ts.grouping.types[grouping[1]]) {
|
||||
currentGroup = norm_rows[rowIndex] ?
|
||||
ts.grouping.types[grouping[1]]( c, c.$columnHeader(column), norm_rows[rowIndex][column], /date/.test(groupClass) ?
|
||||
currentGroup = norm_rows[rowIndex] ?
|
||||
ts.grouping.types[grouping[1]]( c, c.$headerIndexed[column], norm_rows[rowIndex][column], /date/.test(groupClass) ?
|
||||
grouping[2] : parseInt(grouping[2] || 1, 10) || 1, group, lang ) : currentGroup;
|
||||
if (group !== currentGroup) {
|
||||
group = currentGroup;
|
||||
// show range if number > 1
|
||||
if (grouping[1] === 'number' && grouping[2] > 1 && currentGroup !== '') {
|
||||
currentGroup += ' - ' + (parseInt(currentGroup, 10) +
|
||||
((parseInt(grouping[2],10) - 1) * (c.$columnHeader(column).hasClass(ts.css.sortAsc) ? 1 : -1)));
|
||||
((parseInt(grouping[2],10) - 1) * (c.$headerIndexed[column].hasClass(ts.css.sortAsc) ? 1 : -1)));
|
||||
}
|
||||
if ($.isFunction(wo.group_formatter)) {
|
||||
currentGroup = wo.group_formatter((currentGroup || '').toString(), column, table, c, wo) || currentGroup;
|
||||
|
@ -97,7 +97,7 @@ tablereflow = {
|
||||
|
||||
// add <b> to every table cell with thead cell contents
|
||||
for (i = 0; i < cols; i++) {
|
||||
$hdr = c.$columnHeader(i, {lastOnly: false});
|
||||
$hdr = c.$headers.filter('[data-column="' + i + '"]');
|
||||
if ($hdr.length > 1) {
|
||||
txt = [];
|
||||
/*jshint loopfunc:true */
|
||||
|
@ -109,7 +109,7 @@ ts.addWidget({
|
||||
.bind('mousedown', function(event) {
|
||||
// save header cell and mouse position
|
||||
$target = $(event.target).closest('th');
|
||||
var $header = c.$columnHeader($target.attr('data-column'), {lastOnly: false});
|
||||
var $header = c.$headers.filter('[data-column="' + $target.attr('data-column') + '"]');
|
||||
if ($header.length > 1) { $target = $target.add($header); }
|
||||
// if table is not as wide as it's parent, then resize the table
|
||||
$next = event.shiftKey ? $target.parent().find('th').not('.resizable-false').filter(':last') : $target.nextAll(':not(.resizable-false)').eq(0);
|
||||
|
@ -130,9 +130,9 @@ ts.addWidget({
|
||||
}
|
||||
}
|
||||
for (i = 0; i < c.columns; i++) {
|
||||
$header = c.$columnHeader(i, {headers: c.$headers.add(c.$extraHeaders), lastOnly: false}).not('.sorter-false');
|
||||
$header = c.$headers.add(c.$extraHeaders).not('.sorter-false').filter('[data-column="' + i + '"]');
|
||||
$icon = (ts.css.icon) ? $header.find('.' + ts.css.icon) : $();
|
||||
$h = c.$columnHeader(i, {headers: $headers}).not('.sorter-false');
|
||||
$h = $headers.not('.sorter-false').filter('[data-column="' + i + '"]:last');
|
||||
if ($h.length) {
|
||||
$header.removeClass(remove);
|
||||
$icon.removeClass(iconRmv);
|
||||
|
Loading…
Reference in New Issue
Block a user