mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Overall: update debug logging to use console
This commit is contained in:
parent
319149816d
commit
b5485f4992
@ -218,7 +218,7 @@
|
||||
fixHeight(table, p);
|
||||
if (p.initialized && completed !== false) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerComplete');
|
||||
console.log('Pager: Triggering pagerComplete');
|
||||
}
|
||||
c.$table.trigger('pagerComplete', p);
|
||||
// save pager info to storage
|
||||
@ -390,7 +390,7 @@
|
||||
|
||||
if ( exception ) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: >> Ajax Error', xhr, exception);
|
||||
console.error('Pager: >> Ajax Error', xhr, exception);
|
||||
}
|
||||
ts.showError(table,
|
||||
xhr.status === 0 ? 'Not connected, verify Network' :
|
||||
@ -489,7 +489,7 @@
|
||||
// multiple applyWidget blocking code from blocking this trigger
|
||||
setTimeout(function(){
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerChange');
|
||||
console.log('Pager: Triggering pagerChange');
|
||||
}
|
||||
$table
|
||||
.trigger('applyWidgets')
|
||||
@ -504,7 +504,7 @@
|
||||
p.initialized = true;
|
||||
p.initializing = false;
|
||||
if (table.config.debug) {
|
||||
ts.log('Pager: Triggering pagerInitialized');
|
||||
console.log('Pager: Triggering pagerInitialized');
|
||||
}
|
||||
$(table)
|
||||
.trigger('applyWidgets')
|
||||
@ -544,7 +544,7 @@
|
||||
}
|
||||
};
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Ajax initialized', p.ajaxObject);
|
||||
console.log('Pager: Ajax initialized', p.ajaxObject);
|
||||
}
|
||||
$.ajax(p.ajaxObject);
|
||||
}
|
||||
@ -588,7 +588,7 @@
|
||||
url = p.customAjaxUrl(table, url);
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Ajax url = ' + url);
|
||||
console.log('Pager: Ajax url = ' + url);
|
||||
}
|
||||
return url;
|
||||
},
|
||||
@ -603,7 +603,7 @@
|
||||
e = p.size;
|
||||
if ( l < 1 ) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: >> No rows for pager to render');
|
||||
console.warn('Pager: >> No rows for pager to render');
|
||||
}
|
||||
// empty table, abort!
|
||||
return;
|
||||
@ -616,7 +616,7 @@
|
||||
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
||||
if (p.initialized) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerChange');
|
||||
console.log('Pager: Triggering pagerChange');
|
||||
}
|
||||
$t.trigger('pagerChange', p);
|
||||
}
|
||||
@ -647,7 +647,7 @@
|
||||
updatePageDisplay(table, p);
|
||||
if (table.isUpdating) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering updateComplete');
|
||||
console.log('Pager: Triggering updateComplete');
|
||||
}
|
||||
$t.trigger('updateComplete', [ table, true ]);
|
||||
}
|
||||
@ -671,7 +671,7 @@
|
||||
renderTable(table, table.config.rowsCopy, p);
|
||||
$(table).trigger('applyWidgets');
|
||||
if (table.config.debug) {
|
||||
ts.log('Pager: Disabled');
|
||||
console.log('Pager: Disabled');
|
||||
}
|
||||
}
|
||||
// disable size selector
|
||||
@ -730,7 +730,7 @@
|
||||
(l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
|
||||
l.sortList === (c.sortList || []).join(',') ) { return; }
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Changing to page ' + p.page);
|
||||
console.log('Pager: Changing to page ' + p.page);
|
||||
}
|
||||
p.last = {
|
||||
page : p.page,
|
||||
@ -750,14 +750,14 @@
|
||||
$.data(table, 'pagerLastPage', p.page);
|
||||
if (p.initialized && pageMoved !== false) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pageMoved');
|
||||
console.log('Pager: Triggering pageMoved');
|
||||
}
|
||||
$t
|
||||
.trigger('pageMoved', p)
|
||||
.trigger('applyWidgets');
|
||||
if (table.isUpdating) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering updateComplete');
|
||||
console.log('Pager: Triggering updateComplete');
|
||||
}
|
||||
$t.trigger('updateComplete', [ table, true ]);
|
||||
}
|
||||
@ -837,7 +837,7 @@
|
||||
setPageSize(table, p.size, p);
|
||||
hideRowsSetup(table, p);
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Enabled');
|
||||
console.log('Pager: Enabled');
|
||||
}
|
||||
}
|
||||
};
|
||||
@ -872,7 +872,7 @@
|
||||
// save a copy of the original settings
|
||||
p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Initializing');
|
||||
console.log('Pager: Initializing');
|
||||
}
|
||||
p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
|
||||
c.appender = $this.appender;
|
||||
@ -970,7 +970,7 @@
|
||||
ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
|
||||
fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
|
||||
if (c.debug && !pager.length) {
|
||||
ts.log('Pager: >> Container not found');
|
||||
console.warn('Pager: >> Container not found');
|
||||
}
|
||||
pager.find(ctrls.join(','))
|
||||
.attr('tabindex', 0)
|
||||
@ -999,7 +999,7 @@
|
||||
updatePageDisplay(table, p, false);
|
||||
});
|
||||
} else if (c.debug) {
|
||||
ts.log('Pager: >> Goto selector not found');
|
||||
console.warn('Pager: >> Goto selector not found');
|
||||
}
|
||||
// page size selector
|
||||
p.$size = pager.find(p.cssPageSize);
|
||||
@ -1015,7 +1015,7 @@
|
||||
return false;
|
||||
});
|
||||
} else if (c.debug) {
|
||||
ts.log('Pager: >> Size selector not found');
|
||||
console.warn('Pager: >> Size selector not found');
|
||||
}
|
||||
|
||||
// clear initialized flag
|
||||
@ -1045,7 +1045,7 @@
|
||||
p.initialized = true;
|
||||
moveToPage(table, p);
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerInitialized');
|
||||
console.log('Pager: Triggering pagerInitialized');
|
||||
}
|
||||
c.$table.trigger('pagerInitialized', p);
|
||||
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
|
||||
|
@ -76,7 +76,7 @@ $.tablesorter.addWidget({
|
||||
if (endIndex >= 0 && lastIndx === endIndex) { return false; }
|
||||
lastIndx = endIndex;
|
||||
if (c.debug) {
|
||||
ts.log( endIndex === 0 ? 'target before column 0' : endIndex === len ? 'target after last column' : 'target between columns ' + startIndex + ' and ' + endIndex);
|
||||
console.log( endIndex === 0 ? 'target before column 0' : endIndex === len ? 'target after last column' : 'target between columns ' + startIndex + ' and ' + endIndex);
|
||||
}
|
||||
$bar.css('left', offsets[i-1]);
|
||||
return false;
|
||||
@ -98,7 +98,7 @@ $.tablesorter.addWidget({
|
||||
if ( s > -1 && endIndex > -1 && s != endIndex && s + 1 !== endIndex ) {
|
||||
adj = endIndex !== 0;
|
||||
if (c.debug) {
|
||||
ts.log( 'Inserting column ' + s + (adj ? ' after' : ' before') + ' column ' + (endIndex - adj ? 1 : 0) );
|
||||
console.log( 'Inserting column ' + s + (adj ? ' after' : ' before') + ' column ' + (endIndex - adj ? 1 : 0) );
|
||||
}
|
||||
rows.each(function() {
|
||||
cols = $(this).children();
|
||||
|
2
dist/js/extras/jquery.dragtable.mod.min.js
vendored
2
dist/js/extras/jquery.dragtable.mod.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
174
dist/js/jquery.tablesorter.combined.js
vendored
174
dist/js/jquery.tablesorter.combined.js
vendored
@ -1,4 +1,4 @@
|
||||
/*! tablesorter (FORK) - updated 07-23-2015 (v2.22.2)*/
|
||||
/*! tablesorter (FORK) - updated 07-24-2015 (v2.22.2)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -166,24 +166,6 @@
|
||||
// These methods can be applied on table.config instance
|
||||
ts.instanceMethods = {};
|
||||
|
||||
/* debuging utils */
|
||||
function log() {
|
||||
var a = arguments[0],
|
||||
s = arguments.length > 1 ? Array.prototype.slice.call(arguments) : a;
|
||||
if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
|
||||
console[ /error/i.test(a) ? 'error' : /warn/i.test(a) ? 'warn' : 'log' ](s);
|
||||
} else {
|
||||
alert(s);
|
||||
}
|
||||
}
|
||||
|
||||
function benchmark(s, d) {
|
||||
log(s + ' (' + (new Date().getTime() - d.getTime()) + 'ms)');
|
||||
}
|
||||
|
||||
ts.log = log;
|
||||
ts.benchmark = benchmark;
|
||||
|
||||
// $.isEmptyObject from jQuery v1.4
|
||||
function isEmptyObject(obj) {
|
||||
/*jshint forin: false */
|
||||
@ -231,7 +213,7 @@
|
||||
nodeValue = ts.getElementText(c, node, cellIndex);
|
||||
$node = $(node);
|
||||
if (c.debug) {
|
||||
log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
console.log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
}
|
||||
} else {
|
||||
keepLooking = false;
|
||||
@ -278,16 +260,16 @@
|
||||
var rows, list, l, i, h, ch, np, p, e, time, tb, len,
|
||||
table = c.table,
|
||||
j = 0,
|
||||
parsersDebug = '';
|
||||
debug = {};
|
||||
// update table bodies in case we start with an empty table
|
||||
c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')');
|
||||
tb = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
|
||||
len = tb.length;
|
||||
if ( len === 0) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
} else if (c.debug) {
|
||||
time = new Date();
|
||||
log('Detecting parsers for each column');
|
||||
console[ console.group ? 'group' : 'log' ]('Detecting parsers for each column');
|
||||
}
|
||||
list = {
|
||||
extractors: [],
|
||||
@ -320,7 +302,12 @@
|
||||
p = detectParserForColumn(c, rows, -1, i);
|
||||
}
|
||||
if (c.debug) {
|
||||
parsersDebug += 'column:' + i + '; extractor:' + e.id + '; parser:' + p.id + '; string:' + c.strings[i] + '; empty: ' + c.empties[i] + '\n';
|
||||
debug[ '(' + i + ') ' + h.text() ] = {
|
||||
parser : p.id,
|
||||
extractor : e ? e.id : 'none',
|
||||
string : c.strings[i],
|
||||
empty : c.empties[i]
|
||||
};
|
||||
}
|
||||
list.parsers[i] = p;
|
||||
list.extractors[i] = e;
|
||||
@ -329,8 +316,13 @@
|
||||
j += (list.parsers.length) ? len : 1;
|
||||
}
|
||||
if ( c.debug ) {
|
||||
log(parsersDebug ? parsersDebug : 'No parsers detected');
|
||||
benchmark('Completed detecting parsers', time);
|
||||
if ( !isEmptyObject( debug ) ) {
|
||||
console[ console.table ? 'table' : 'log' ]( debug );
|
||||
} else {
|
||||
console.warn( ' No parsers detected!' );
|
||||
}
|
||||
console.log( 'Completed detecting parsers' + ts.benchmark( time ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
c.parsers = list.parsers;
|
||||
c.extractors = list.extractors;
|
||||
@ -349,7 +341,7 @@
|
||||
c.totalRows = 0;
|
||||
// if no parsers found, return - it's an empty table.
|
||||
if (!parsers) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a cache') : '';
|
||||
}
|
||||
if (c.debug) {
|
||||
cacheTime = new Date();
|
||||
@ -402,7 +394,7 @@
|
||||
for ( j = 0; j < c.columns; ++j ) {
|
||||
if (typeof parsers[ j ] === 'undefined') {
|
||||
if ( c.debug ) {
|
||||
log( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
console.warn( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -428,7 +420,7 @@
|
||||
ts.isProcessing( table ); // remove processing icon
|
||||
}
|
||||
if ( c.debug ) {
|
||||
benchmark( 'Building cache for ' + totalRows + ' rows', cacheTime );
|
||||
console.log( 'Building cache for ' + totalRows + ' rows' + ts.benchmark( cacheTime ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -472,7 +464,7 @@
|
||||
c.appender(table, rows);
|
||||
}
|
||||
if (c.debug) {
|
||||
benchmark('Rebuilt table', appendTime);
|
||||
console.log( 'Rebuilt table' + ts.benchmark(appendTime) );
|
||||
}
|
||||
// apply table widgets; but not before ajax completes
|
||||
if (!init && !c.appender) { ts.applyWidget(table); }
|
||||
@ -553,8 +545,8 @@
|
||||
// enable/disable sorting
|
||||
updateHeader(table);
|
||||
if (c.debug) {
|
||||
benchmark('Built headers:', time);
|
||||
log(c.$headers);
|
||||
console.log( 'Built headers:' + ts.benchmark( time ) );
|
||||
console.log( c.$headers );
|
||||
}
|
||||
}
|
||||
|
||||
@ -877,7 +869,9 @@
|
||||
return a[c.columns].order - b[c.columns].order;
|
||||
});
|
||||
}
|
||||
if (c.debug) { benchmark('Sorting on ' + sortList.toString() + ' and dir ' + order + ' time', sortTime); }
|
||||
if (c.debug) {
|
||||
console.log( 'Sorting on ' + sortList.toString() + ' and dir ' + order + ' time' + ts.benchmark(sortTime) );
|
||||
}
|
||||
}
|
||||
|
||||
function resortComplete(c, callback){
|
||||
@ -1121,7 +1115,14 @@
|
||||
ts.setup = function(table, c) {
|
||||
// if no thead or tbody, or tablesorter is already present, quit
|
||||
if (!table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true) {
|
||||
return c.debug ? log('ERROR: stopping initialization! No table, thead, tbody or tablesorter has already been initialized') : '';
|
||||
if ( c.debug ) {
|
||||
if ( table.hasInitialized ) {
|
||||
console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
|
||||
} else {
|
||||
console.error( 'Stopping initialization! No table, thead or tbody' );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var k = '',
|
||||
@ -1135,7 +1136,10 @@
|
||||
table.config = c;
|
||||
// save the settings where they read
|
||||
$.data(table, 'tablesorter', c);
|
||||
if (c.debug) { $.data( table, 'startoveralltimer', new Date()); }
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter' );
|
||||
$.data( table, 'startoveralltimer', new Date());
|
||||
}
|
||||
|
||||
// removing this in version 3 (only supports jQuery 1.7+)
|
||||
c.supportsDataObject = (function(version) {
|
||||
@ -1234,7 +1238,8 @@
|
||||
table.hasInitialized = true;
|
||||
table.isProcessing = false;
|
||||
if (c.debug) {
|
||||
ts.benchmark('Overall initialization time', $.data( table, 'startoveralltimer'));
|
||||
console.log( 'Overall initialization time: ' + ts.benchmark( $.data( table, 'startoveralltimer') ) );
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
$table.trigger('tablesorter-initialized', table);
|
||||
if (typeof c.initialized === 'function') { c.initialized(table); }
|
||||
@ -1477,6 +1482,7 @@
|
||||
var events,
|
||||
$t = $(table),
|
||||
c = table.config,
|
||||
debug = c.debug,
|
||||
$h = $t.find('thead:first'),
|
||||
$r = $h.find('tr.' + ts.css.headerRow).removeClass(ts.css.headerRow + ' ' + c.cssHeaderRow),
|
||||
$f = $t.find('tfoot:first > tr').children('th, td');
|
||||
@ -1508,6 +1514,9 @@
|
||||
if (typeof callback === 'function') {
|
||||
callback(table);
|
||||
}
|
||||
if (debug) {
|
||||
console.log( 'tablesorter has been removed' );
|
||||
}
|
||||
};
|
||||
|
||||
// *** sort functions ***
|
||||
@ -1731,7 +1740,7 @@
|
||||
|
||||
ts.applyWidget = function(table, init, callback) {
|
||||
table = $(table)[0]; // in case this is called externally
|
||||
var indx, len, name,
|
||||
var indx, len, names, widget, name, applied,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
tableClass = ' ' + c.table.className + ' ',
|
||||
@ -1759,11 +1768,11 @@
|
||||
c.widgets = $.grep(c.widgets, function(v, k){
|
||||
return $.inArray(v, c.widgets) === k;
|
||||
});
|
||||
name = c.widgets || [];
|
||||
len = name.length;
|
||||
names = c.widgets || [];
|
||||
len = names.length;
|
||||
// build widget array & add priority as needed
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
wd = ts.getWidgetById(name[indx]);
|
||||
wd = ts.getWidgetById(names[indx]);
|
||||
if (wd && wd.id) {
|
||||
// set priority to 10 if not defined
|
||||
if (!wd.priority) { wd.priority = 10; }
|
||||
@ -1776,28 +1785,47 @@
|
||||
});
|
||||
// add/update selected widgets
|
||||
len = widgets.length;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
|
||||
}
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (widgets[indx]) {
|
||||
if ( init || !( c.widgetInit[ widgets[indx].id ] ) ) {
|
||||
widget = widgets[indx];
|
||||
if (widget) {
|
||||
name = widget.id;
|
||||
applied = false;
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
|
||||
if ( init || !( c.widgetInit[ name ] ) ) {
|
||||
// set init flag first to prevent calling init more than once (e.g. pager)
|
||||
c.widgetInit[ widgets[indx].id ] = true;
|
||||
c.widgetInit[ name ] = true;
|
||||
if (table.hasInitialized) {
|
||||
// don't reapply widget options on tablesorter init
|
||||
ts.applyWidgetOptions( table, c );
|
||||
}
|
||||
if ( 'init' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].init(table, widgets[indx], c, wo);
|
||||
if (c.debug) { ts.benchmark('Initializing ' + widgets[indx].id + ' widget', time2); }
|
||||
if ( 'init' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
|
||||
}
|
||||
widget.init(table, widget, c, wo);
|
||||
}
|
||||
}
|
||||
if ( !init && 'format' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].format(table, c, wo, false);
|
||||
if (c.debug) { ts.benchmark( ( init ? 'Initializing ' : 'Applying ' ) + widgets[indx].id + ' widget', time2); }
|
||||
if ( !init && 'format' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
|
||||
}
|
||||
widget.format(table, c, wo, false);
|
||||
}
|
||||
if (c.debug) {
|
||||
if (applied) {
|
||||
console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time2 ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
// callback executed on init only
|
||||
if (!init && typeof callback === 'function') {
|
||||
callback(table);
|
||||
@ -1809,7 +1837,7 @@
|
||||
}, 0);
|
||||
if (c.debug) {
|
||||
w = c.widgets.length;
|
||||
benchmark('Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : ''), time);
|
||||
console.log( 'Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : '') + ts.benchmark(time) );
|
||||
}
|
||||
};
|
||||
|
||||
@ -1837,7 +1865,10 @@
|
||||
widget = ts.getWidgetById(name[i]);
|
||||
indx = $.inArray( name[i], c.widgets );
|
||||
if ( widget && 'remove' in widget ) {
|
||||
if (c.debug && indx >= 0) { log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if (c.debug && indx >= 0) { console.log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if ( c.debug ) {
|
||||
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[i] + '" widget' );
|
||||
}
|
||||
widget.remove(table, c, c.widgetOptions, refreshing);
|
||||
c.widgetInit[ name[i] ] = false;
|
||||
}
|
||||
@ -1885,7 +1916,11 @@
|
||||
allColumns = column === 'all',
|
||||
data = { raw : [], parsed: [], $cell: [] },
|
||||
c = table.config;
|
||||
if ( !isEmptyObject( c ) ) {
|
||||
if ( isEmptyObject( c ) ) {
|
||||
if ( c.debug ) {
|
||||
console.warn( 'No cache found - aborting getColumnText function!' );
|
||||
}
|
||||
} else {
|
||||
tbodyLen = c.$tbodies.length;
|
||||
for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
|
||||
cache = c.cache[ tbodyIndex ].normalized;
|
||||
@ -1981,6 +2016,23 @@
|
||||
tablesorter: ts.construct
|
||||
});
|
||||
|
||||
// set up debug logs
|
||||
if ( !( console && console.log ) ) {
|
||||
ts.logs = [];
|
||||
/*jshint -W020 */
|
||||
console = {};
|
||||
console.log = console.warn = console.error = console.table = function() {
|
||||
ts.logs.push( [ Date.now(), arguments ] );
|
||||
};
|
||||
}
|
||||
|
||||
ts.log = function(){
|
||||
console.log( arguments );
|
||||
};
|
||||
ts.benchmark = function( diff ) {
|
||||
return ( ' (' + ( new Date().getTime() - diff.getTime() ) + 'ms)' );
|
||||
};
|
||||
|
||||
// add default parsers
|
||||
ts.addParser({
|
||||
id: 'no-parser',
|
||||
@ -2242,7 +2294,7 @@
|
||||
window[storageType].removeItem('_tmptest');
|
||||
} catch (error) {
|
||||
if (c && c.debug) {
|
||||
ts.log( storageType + ' is not supported in this browser' );
|
||||
console.warn( storageType + ' is not supported in this browser' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2440,7 +2492,7 @@
|
||||
}
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.benchmark('Applying ' + theme + ' theme', time);
|
||||
console.log('Applying ' + theme + ' theme' + ts.benchmark(time));
|
||||
}
|
||||
},
|
||||
remove: function(table, c, wo, refreshing) {
|
||||
@ -3671,7 +3723,7 @@
|
||||
}
|
||||
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Starting filter widget search', filters );
|
||||
console.log( 'Filter: Starting filter widget search', filters );
|
||||
time = new Date();
|
||||
}
|
||||
// filtered rows count
|
||||
@ -3761,7 +3813,7 @@
|
||||
// can't search when all rows are hidden - this happens when looking for exact matches
|
||||
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Searching through ' +
|
||||
console.log( 'Filter: Searching through ' +
|
||||
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
|
||||
}
|
||||
if ( data.anyMatchFlag ) {
|
||||
@ -3847,7 +3899,7 @@
|
||||
ts.storage( table, 'tablesorter-filters', storedFilters );
|
||||
}
|
||||
if ( c.debug ) {
|
||||
ts.benchmark( 'Completed filter widget search', time );
|
||||
console.log( 'Completed filter widget search' + ts.benchmark(time) );
|
||||
}
|
||||
if ( wo.filter_initialized ) {
|
||||
c.$table.trigger( 'filterEnd', c );
|
||||
@ -4869,7 +4921,7 @@
|
||||
if (saveSort && table.hasInitialized && ts.storage) {
|
||||
ts.storage( table, 'tablesorter-savesort', sortList );
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort widget: Saving last sort: ' + c.sortList, time);
|
||||
console.log('saveSort widget: Saving last sort: ' + c.sortList + ts.benchmark(time));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -4881,7 +4933,7 @@
|
||||
stored = ts.storage( table, 'tablesorter-savesort' );
|
||||
sortList = (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort: Last sort loaded: "' + sortList + '"', time);
|
||||
console.log('saveSort: Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
|
||||
}
|
||||
$table.bind('saveSortReset', function(event) {
|
||||
event.stopPropagation();
|
||||
|
8
dist/js/jquery.tablesorter.combined.min.js
vendored
8
dist/js/jquery.tablesorter.combined.min.js
vendored
File diff suppressed because one or more lines are too long
158
dist/js/jquery.tablesorter.js
vendored
158
dist/js/jquery.tablesorter.js
vendored
@ -164,24 +164,6 @@
|
||||
// These methods can be applied on table.config instance
|
||||
ts.instanceMethods = {};
|
||||
|
||||
/* debuging utils */
|
||||
function log() {
|
||||
var a = arguments[0],
|
||||
s = arguments.length > 1 ? Array.prototype.slice.call(arguments) : a;
|
||||
if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
|
||||
console[ /error/i.test(a) ? 'error' : /warn/i.test(a) ? 'warn' : 'log' ](s);
|
||||
} else {
|
||||
alert(s);
|
||||
}
|
||||
}
|
||||
|
||||
function benchmark(s, d) {
|
||||
log(s + ' (' + (new Date().getTime() - d.getTime()) + 'ms)');
|
||||
}
|
||||
|
||||
ts.log = log;
|
||||
ts.benchmark = benchmark;
|
||||
|
||||
// $.isEmptyObject from jQuery v1.4
|
||||
function isEmptyObject(obj) {
|
||||
/*jshint forin: false */
|
||||
@ -229,7 +211,7 @@
|
||||
nodeValue = ts.getElementText(c, node, cellIndex);
|
||||
$node = $(node);
|
||||
if (c.debug) {
|
||||
log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
console.log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
}
|
||||
} else {
|
||||
keepLooking = false;
|
||||
@ -276,16 +258,16 @@
|
||||
var rows, list, l, i, h, ch, np, p, e, time, tb, len,
|
||||
table = c.table,
|
||||
j = 0,
|
||||
parsersDebug = '';
|
||||
debug = {};
|
||||
// update table bodies in case we start with an empty table
|
||||
c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')');
|
||||
tb = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
|
||||
len = tb.length;
|
||||
if ( len === 0) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
} else if (c.debug) {
|
||||
time = new Date();
|
||||
log('Detecting parsers for each column');
|
||||
console[ console.group ? 'group' : 'log' ]('Detecting parsers for each column');
|
||||
}
|
||||
list = {
|
||||
extractors: [],
|
||||
@ -318,7 +300,12 @@
|
||||
p = detectParserForColumn(c, rows, -1, i);
|
||||
}
|
||||
if (c.debug) {
|
||||
parsersDebug += 'column:' + i + '; extractor:' + e.id + '; parser:' + p.id + '; string:' + c.strings[i] + '; empty: ' + c.empties[i] + '\n';
|
||||
debug[ '(' + i + ') ' + h.text() ] = {
|
||||
parser : p.id,
|
||||
extractor : e ? e.id : 'none',
|
||||
string : c.strings[i],
|
||||
empty : c.empties[i]
|
||||
};
|
||||
}
|
||||
list.parsers[i] = p;
|
||||
list.extractors[i] = e;
|
||||
@ -327,8 +314,13 @@
|
||||
j += (list.parsers.length) ? len : 1;
|
||||
}
|
||||
if ( c.debug ) {
|
||||
log(parsersDebug ? parsersDebug : 'No parsers detected');
|
||||
benchmark('Completed detecting parsers', time);
|
||||
if ( !isEmptyObject( debug ) ) {
|
||||
console[ console.table ? 'table' : 'log' ]( debug );
|
||||
} else {
|
||||
console.warn( ' No parsers detected!' );
|
||||
}
|
||||
console.log( 'Completed detecting parsers' + ts.benchmark( time ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
c.parsers = list.parsers;
|
||||
c.extractors = list.extractors;
|
||||
@ -347,7 +339,7 @@
|
||||
c.totalRows = 0;
|
||||
// if no parsers found, return - it's an empty table.
|
||||
if (!parsers) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a cache') : '';
|
||||
}
|
||||
if (c.debug) {
|
||||
cacheTime = new Date();
|
||||
@ -400,7 +392,7 @@
|
||||
for ( j = 0; j < c.columns; ++j ) {
|
||||
if (typeof parsers[ j ] === 'undefined') {
|
||||
if ( c.debug ) {
|
||||
log( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
console.warn( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -426,7 +418,7 @@
|
||||
ts.isProcessing( table ); // remove processing icon
|
||||
}
|
||||
if ( c.debug ) {
|
||||
benchmark( 'Building cache for ' + totalRows + ' rows', cacheTime );
|
||||
console.log( 'Building cache for ' + totalRows + ' rows' + ts.benchmark( cacheTime ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -470,7 +462,7 @@
|
||||
c.appender(table, rows);
|
||||
}
|
||||
if (c.debug) {
|
||||
benchmark('Rebuilt table', appendTime);
|
||||
console.log( 'Rebuilt table' + ts.benchmark(appendTime) );
|
||||
}
|
||||
// apply table widgets; but not before ajax completes
|
||||
if (!init && !c.appender) { ts.applyWidget(table); }
|
||||
@ -551,8 +543,8 @@
|
||||
// enable/disable sorting
|
||||
updateHeader(table);
|
||||
if (c.debug) {
|
||||
benchmark('Built headers:', time);
|
||||
log(c.$headers);
|
||||
console.log( 'Built headers:' + ts.benchmark( time ) );
|
||||
console.log( c.$headers );
|
||||
}
|
||||
}
|
||||
|
||||
@ -875,7 +867,9 @@
|
||||
return a[c.columns].order - b[c.columns].order;
|
||||
});
|
||||
}
|
||||
if (c.debug) { benchmark('Sorting on ' + sortList.toString() + ' and dir ' + order + ' time', sortTime); }
|
||||
if (c.debug) {
|
||||
console.log( 'Sorting on ' + sortList.toString() + ' and dir ' + order + ' time' + ts.benchmark(sortTime) );
|
||||
}
|
||||
}
|
||||
|
||||
function resortComplete(c, callback){
|
||||
@ -1119,7 +1113,14 @@
|
||||
ts.setup = function(table, c) {
|
||||
// if no thead or tbody, or tablesorter is already present, quit
|
||||
if (!table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true) {
|
||||
return c.debug ? log('ERROR: stopping initialization! No table, thead, tbody or tablesorter has already been initialized') : '';
|
||||
if ( c.debug ) {
|
||||
if ( table.hasInitialized ) {
|
||||
console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
|
||||
} else {
|
||||
console.error( 'Stopping initialization! No table, thead or tbody' );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var k = '',
|
||||
@ -1133,7 +1134,10 @@
|
||||
table.config = c;
|
||||
// save the settings where they read
|
||||
$.data(table, 'tablesorter', c);
|
||||
if (c.debug) { $.data( table, 'startoveralltimer', new Date()); }
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter' );
|
||||
$.data( table, 'startoveralltimer', new Date());
|
||||
}
|
||||
|
||||
// removing this in version 3 (only supports jQuery 1.7+)
|
||||
c.supportsDataObject = (function(version) {
|
||||
@ -1232,7 +1236,8 @@
|
||||
table.hasInitialized = true;
|
||||
table.isProcessing = false;
|
||||
if (c.debug) {
|
||||
ts.benchmark('Overall initialization time', $.data( table, 'startoveralltimer'));
|
||||
console.log( 'Overall initialization time: ' + ts.benchmark( $.data( table, 'startoveralltimer') ) );
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
$table.trigger('tablesorter-initialized', table);
|
||||
if (typeof c.initialized === 'function') { c.initialized(table); }
|
||||
@ -1475,6 +1480,7 @@
|
||||
var events,
|
||||
$t = $(table),
|
||||
c = table.config,
|
||||
debug = c.debug,
|
||||
$h = $t.find('thead:first'),
|
||||
$r = $h.find('tr.' + ts.css.headerRow).removeClass(ts.css.headerRow + ' ' + c.cssHeaderRow),
|
||||
$f = $t.find('tfoot:first > tr').children('th, td');
|
||||
@ -1506,6 +1512,9 @@
|
||||
if (typeof callback === 'function') {
|
||||
callback(table);
|
||||
}
|
||||
if (debug) {
|
||||
console.log( 'tablesorter has been removed' );
|
||||
}
|
||||
};
|
||||
|
||||
// *** sort functions ***
|
||||
@ -1729,7 +1738,7 @@
|
||||
|
||||
ts.applyWidget = function(table, init, callback) {
|
||||
table = $(table)[0]; // in case this is called externally
|
||||
var indx, len, name,
|
||||
var indx, len, names, widget, name, applied,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
tableClass = ' ' + c.table.className + ' ',
|
||||
@ -1757,11 +1766,11 @@
|
||||
c.widgets = $.grep(c.widgets, function(v, k){
|
||||
return $.inArray(v, c.widgets) === k;
|
||||
});
|
||||
name = c.widgets || [];
|
||||
len = name.length;
|
||||
names = c.widgets || [];
|
||||
len = names.length;
|
||||
// build widget array & add priority as needed
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
wd = ts.getWidgetById(name[indx]);
|
||||
wd = ts.getWidgetById(names[indx]);
|
||||
if (wd && wd.id) {
|
||||
// set priority to 10 if not defined
|
||||
if (!wd.priority) { wd.priority = 10; }
|
||||
@ -1774,28 +1783,47 @@
|
||||
});
|
||||
// add/update selected widgets
|
||||
len = widgets.length;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
|
||||
}
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (widgets[indx]) {
|
||||
if ( init || !( c.widgetInit[ widgets[indx].id ] ) ) {
|
||||
widget = widgets[indx];
|
||||
if (widget) {
|
||||
name = widget.id;
|
||||
applied = false;
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
|
||||
if ( init || !( c.widgetInit[ name ] ) ) {
|
||||
// set init flag first to prevent calling init more than once (e.g. pager)
|
||||
c.widgetInit[ widgets[indx].id ] = true;
|
||||
c.widgetInit[ name ] = true;
|
||||
if (table.hasInitialized) {
|
||||
// don't reapply widget options on tablesorter init
|
||||
ts.applyWidgetOptions( table, c );
|
||||
}
|
||||
if ( 'init' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].init(table, widgets[indx], c, wo);
|
||||
if (c.debug) { ts.benchmark('Initializing ' + widgets[indx].id + ' widget', time2); }
|
||||
if ( 'init' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
|
||||
}
|
||||
widget.init(table, widget, c, wo);
|
||||
}
|
||||
}
|
||||
if ( !init && 'format' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].format(table, c, wo, false);
|
||||
if (c.debug) { ts.benchmark( ( init ? 'Initializing ' : 'Applying ' ) + widgets[indx].id + ' widget', time2); }
|
||||
if ( !init && 'format' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
|
||||
}
|
||||
widget.format(table, c, wo, false);
|
||||
}
|
||||
if (c.debug) {
|
||||
if (applied) {
|
||||
console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time2 ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
// callback executed on init only
|
||||
if (!init && typeof callback === 'function') {
|
||||
callback(table);
|
||||
@ -1807,7 +1835,7 @@
|
||||
}, 0);
|
||||
if (c.debug) {
|
||||
w = c.widgets.length;
|
||||
benchmark('Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : ''), time);
|
||||
console.log( 'Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : '') + ts.benchmark(time) );
|
||||
}
|
||||
};
|
||||
|
||||
@ -1835,7 +1863,10 @@
|
||||
widget = ts.getWidgetById(name[i]);
|
||||
indx = $.inArray( name[i], c.widgets );
|
||||
if ( widget && 'remove' in widget ) {
|
||||
if (c.debug && indx >= 0) { log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if (c.debug && indx >= 0) { console.log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if ( c.debug ) {
|
||||
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[i] + '" widget' );
|
||||
}
|
||||
widget.remove(table, c, c.widgetOptions, refreshing);
|
||||
c.widgetInit[ name[i] ] = false;
|
||||
}
|
||||
@ -1883,7 +1914,11 @@
|
||||
allColumns = column === 'all',
|
||||
data = { raw : [], parsed: [], $cell: [] },
|
||||
c = table.config;
|
||||
if ( !isEmptyObject( c ) ) {
|
||||
if ( isEmptyObject( c ) ) {
|
||||
if ( c.debug ) {
|
||||
console.warn( 'No cache found - aborting getColumnText function!' );
|
||||
}
|
||||
} else {
|
||||
tbodyLen = c.$tbodies.length;
|
||||
for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
|
||||
cache = c.cache[ tbodyIndex ].normalized;
|
||||
@ -1979,6 +2014,23 @@
|
||||
tablesorter: ts.construct
|
||||
});
|
||||
|
||||
// set up debug logs
|
||||
if ( !( console && console.log ) ) {
|
||||
ts.logs = [];
|
||||
/*jshint -W020 */
|
||||
console = {};
|
||||
console.log = console.warn = console.error = console.table = function() {
|
||||
ts.logs.push( [ Date.now(), arguments ] );
|
||||
};
|
||||
}
|
||||
|
||||
ts.log = function(){
|
||||
console.log( arguments );
|
||||
};
|
||||
ts.benchmark = function( diff ) {
|
||||
return ( ' (' + ( new Date().getTime() - diff.getTime() ) + 'ms)' );
|
||||
};
|
||||
|
||||
// add default parsers
|
||||
ts.addParser({
|
||||
id: 'no-parser',
|
||||
|
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
16
dist/js/jquery.tablesorter.widgets.js
vendored
16
dist/js/jquery.tablesorter.widgets.js
vendored
@ -1,4 +1,4 @@
|
||||
/*! tablesorter (FORK) - updated 07-23-2015 (v2.22.2)*/
|
||||
/*! tablesorter (FORK) - updated 07-24-2015 (v2.22.2)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -62,7 +62,7 @@
|
||||
window[storageType].removeItem('_tmptest');
|
||||
} catch (error) {
|
||||
if (c && c.debug) {
|
||||
ts.log( storageType + ' is not supported in this browser' );
|
||||
console.warn( storageType + ' is not supported in this browser' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -260,7 +260,7 @@
|
||||
}
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.benchmark('Applying ' + theme + ' theme', time);
|
||||
console.log('Applying ' + theme + ' theme' + ts.benchmark(time));
|
||||
}
|
||||
},
|
||||
remove: function(table, c, wo, refreshing) {
|
||||
@ -1491,7 +1491,7 @@
|
||||
}
|
||||
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Starting filter widget search', filters );
|
||||
console.log( 'Filter: Starting filter widget search', filters );
|
||||
time = new Date();
|
||||
}
|
||||
// filtered rows count
|
||||
@ -1581,7 +1581,7 @@
|
||||
// can't search when all rows are hidden - this happens when looking for exact matches
|
||||
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Searching through ' +
|
||||
console.log( 'Filter: Searching through ' +
|
||||
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
|
||||
}
|
||||
if ( data.anyMatchFlag ) {
|
||||
@ -1667,7 +1667,7 @@
|
||||
ts.storage( table, 'tablesorter-filters', storedFilters );
|
||||
}
|
||||
if ( c.debug ) {
|
||||
ts.benchmark( 'Completed filter widget search', time );
|
||||
console.log( 'Completed filter widget search' + ts.benchmark(time) );
|
||||
}
|
||||
if ( wo.filter_initialized ) {
|
||||
c.$table.trigger( 'filterEnd', c );
|
||||
@ -2689,7 +2689,7 @@
|
||||
if (saveSort && table.hasInitialized && ts.storage) {
|
||||
ts.storage( table, 'tablesorter-savesort', sortList );
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort widget: Saving last sort: ' + c.sortList, time);
|
||||
console.log('saveSort widget: Saving last sort: ' + c.sortList + ts.benchmark(time));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -2701,7 +2701,7 @@
|
||||
stored = ts.storage( table, 'tablesorter-savesort' );
|
||||
sortList = (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort: Last sort loaded: "' + sortList + '"', time);
|
||||
console.log('saveSort: Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
|
||||
}
|
||||
$table.bind('saveSortReset', function(event) {
|
||||
event.stopPropagation();
|
||||
|
6
dist/js/jquery.tablesorter.widgets.min.js
vendored
6
dist/js/jquery.tablesorter.widgets.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-build-table.min.js
vendored
2
dist/js/widgets/widget-build-table.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-columnSelector.min.js
vendored
2
dist/js/widgets/widget-columnSelector.min.js
vendored
File diff suppressed because one or more lines are too long
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
4
dist/js/widgets/widget-math.min.js
vendored
4
dist/js/widgets/widget-math.min.js
vendored
@ -1,9 +1,9 @@
|
||||
/*! Widget: math - updated 5/17/2015 (v2.22.0) */
|
||||
!function(a){"use strict";var b=a.tablesorter,c={events:"tablesorter-initialized update updateAll updateRows addRows updateCell filterReset filterEnd ".split(" ").join(".tsmath "),getRow:function(c,d,e,f){var g,h,i=c.config,j=[],k=e.closest("tr"),l=k.children().not("["+f+"=ignore]");return k.hasClass(d.filter_filteredRow||"filtered")||(d.math_ignore.length&&(l=l.not("[data-column="+d.math_ignore.join("],[data-column=")+"]")),j=l.not(e).map(function(){return g=a(this),h=g.attr(i.textAttribute),"undefined"==typeof h&&(h=this.textContent||g.text()),h=b.formatFloat(h.replace(/[^\w,. \-()]/g,""),c)||0,isNaN(h)?0:h}).get()),j},getColumn:function(c,d,e,f,g){var h,i,j,k,l,m=[],n=c.config,o=d.filter_filteredRow||"filtered",p=parseInt(e.attr("data-column"),10),q=n.$table.children("tbody").children(),r=e.closest("tr");if("above"===f)for(k=q.index(r),h=k;h>=0;)j=q.eq(h).children().filter("[data-column="+p+"]"),l=j.filter("["+g+"^=above]").length,(!q.eq(h).hasClass(o)&&q.eq(h).not("["+g+"=ignore]").length&&h!==k||l&&h!==k)&&(l?h=0:j.length&&(i=j.attr(n.textAttribute),"undefined"==typeof i&&(i=j[0].textContent||j.text()),i=b.formatFloat(i.replace(/[^\w,. \-()]/g,""),c)||0,m.push(isNaN(i)?0:i))),h--;else q.not("["+g+"=ignore]").each(function(){j=a(this).children().filter("[data-column="+p+"]"),a(this).hasClass(o)||!j.not("["+g+"^=above],["+g+"^=col]").length||j.is(e)||(i=j.attr(n.textAttribute),"undefined"==typeof i&&(i=(j[0]?j[0].textContent:"")||j.text()),i=b.formatFloat(i.replace(/[^\w,. \-()]/g,""),c)||0,m.push(isNaN(i)?0:i))});return m},getAll:function(c,d,e){var f,g,h,i=[],j=c.config,k=d.filter_filteredRow||"filtered",l=j.$table.children("tbody").children();return l.each(function(){a(this).hasClass(k)||a(this).children().each(function(){g=a(this),h=parseInt(g.attr("data-column"),10),!g.filter("["+e+"]").length&&a.inArray(h,d.math_ignore)<0&&(f=g.attr(j.textAttribute),"undefined"==typeof f&&(f=(g[0]?g[0].textContent:"")||g.text()),f=b.formatFloat(f.replace(/[^\w,. \-()]/g,""),c)||0,i.push(isNaN(f)?0:f))})}),i},recalculate:function(a,d,e,f){if(d&&(!e.math_isUpdating||f)){f&&b.computeColumnIndex(d.$table.children("tbody").children());var g="data-"+(e.math_data||"math"),h=d.$tbodies.find("["+g+"]");c.mathType(a,e,h,e.math_priority,g),h=d.$table.find("."+d.cssInfoBlock+", tfoot").find("["+g+"]"),c.mathType(a,e,h,e.math_priority,g),c.mathType(a,e,d.$table.find("["+g+"^=all]"),["all"],g),e.math_isUpdating=!0,d.$table.trigger("update")}},mathType:function(d,e,f,g,h){if(f.length){var i,j,k,l,m,n=b.equations;"all"===g[0]&&(m=c.getAll(d,e,h)),a.each(g,function(b,g){f.filter("["+h+"^="+g+"]").each(function(){k=a(this),i=(k.attr(h)||"").replace(g+"-",""),l="row"===g?c.getRow(d,e,k,h):"all"===g?m:c.getColumn(d,e,k,g,h),n[i]&&(j=n[i](l),d.config.debug&&console&&console.log&&console.log(k.attr(h),l,"=",j),c.output(k,e,j,l))})})}},output:function(c,d,e,f){var g=b.formatMask(c.attr("data-"+d.math_data+"-mask")||d.math_mask,e,d.math_wrapPrefix,d.math_wrapSuffix);a.isFunction(d.math_complete)&&(g=d.math_complete(c,d,g,e,f)),g!==!1&&c.html(g)}};/**
|
||||
!function(a){"use strict";var b=a.tablesorter,c={error:{0:"Infinity result: Divide by zero",1:"Need more than one element to make this calculation",undef:"No elements found"},invalid:function(a,b){return console.log(a,c.error[b]),"none"},events:"tablesorter-initialized update updateAll updateRows addRows updateCell filterReset filterEnd ".split(" ").join(".tsmath "),processText:function(a,c){var d=c.attr(a.textAttribute);return"undefined"==typeof d&&(d=c[0].textContent||c.text()),d=b.formatFloat(d.replace(/[^\w,. \-()]/g,""),a.table)||0,isNaN(d)?0:d},getRow:function(b,d){var e=b.widgetOptions,f=[],g=d.closest("tr"),h=g.children().not("["+e.math_dataAttrib+"=ignore]");return g.hasClass(e.filter_filteredRow||"filtered")||(e.math_ignore.length&&(h=h.not("[data-column="+e.math_ignore.join("],[data-column=")+"]")),f=h.not(d).map(function(){return c.processText(b,a(this))}).get()),f},getColumn:function(a,b,d){var e,f,g,h,i,j=[],k=a.widgetOptions,l=k.filter_filteredRow||"filtered",m=parseInt(b.attr("data-column"),10),n=a.$table.children("tbody").children(),o=b.closest("tr");if("above"===d)for(g=n.index(o),e=g;e>=0;)f=n.eq(e).children().filter("[data-column="+m+"]"),i=f.filter("["+k.math_dataAttrib+"^=above]").length,(!n.eq(e).hasClass(l)&&n.eq(e).not("["+k.math_dataAttrib+"=ignore]").length&&e!==g||i&&e!==g)&&(i?e=0:f.length&&j.push(c.processText(a,f))),e--;else for(h=n.not("["+k.math_dataAttrib+"=ignore]"),g=h.length,e=0;g>e;e++)f=h.eq(e).children().filter("[data-column="+m+"]"),h.eq(e).hasClass(l)||!f.not("["+k.math_dataAttrib+"^=above],["+k.math_dataAttrib+"^=col]").length||f.is(b)||j.push(c.processText(a,f));return j},getAll:function(b){var d,e,f,g,h,i,j,k,l=[],m=b.widgetOptions,n=m.filter_filteredRow||"filtered",o=b.$table.children("tbody").children().not("["+m.math_dataAttrib+"=ignore]");for(h=o.length,g=0;h>g;g++)if(f=o.eq(g),!f.hasClass(n))for(i=f.children().not("["+m.math_dataAttrib+"=ignore]"),k=i.length,j=0;k>j;j++)d=i.eq(j),e=parseInt(d.attr("data-column"),10),!d.filter("["+m.math_dataAttrib+"]").length&&a.inArray(e,m.math_ignore)<0&&l.push(c.processText(b,d));return l},recalculate:function(a,d,e,f){if(d&&(!e.math_isUpdating||f)){f&&b.computeColumnIndex(d.$table.children("tbody").children()),e.math_dataAttrib="data-"+(e.math_data||"math");var g=d.$tbodies.find("["+e.math_dataAttrib+"]");c.mathType(d,g,e.math_priority),g=d.$table.children("."+d.cssInfoBlock+", tfoot").find("["+e.math_dataAttrib+"]"),c.mathType(d,g,e.math_priority),g=d.$table.find("["+e.math_dataAttrib+"^=all]"),c.mathType(d,g,["all"]),e.math_isUpdating=!0,d.debug&&console[console.group?"group":"log"]("Math widget triggering an update after recalculation"),d.$table.trigger("update")}},mathType:function(d,e,f){if(e.length){var g,h,i,j,k,l,m,n,o=d.widgetOptions,p=b.equations;"all"===f[0]&&(k=c.getAll(d)),d.debug&&console[console.group?"group":"log"]("Tablesorter Math widget recalculation"),a.each(f,function(a,b){if(l=e.filter("["+o.math_dataAttrib+"^="+b+"]"),n=l.length){for(d.debug&&console[console.group?"group":"log"](b),m=0;n>m;m++)i=l.eq(m),g=(i.attr(o.math_dataAttrib)||"").replace(b+"-",""),j="row"===b?c.getRow(d,i):"all"===b?k:c.getColumn(d,i,b),p[g]&&(j.length?(h=p[g](j),d.debug&&console.log(i.attr(o.math_dataAttrib),j,"=",h)):h=c.invalid(g,"mean"===g?0:"undef"),c.output(i,o,h,j));d.debug&&console.groupEnd&&console.groupEnd()}}),d.debug&&console.groupEnd&&console.groupEnd()}},output:function(a,c,d,e){var f=a.attr("data-"+c.math_data+"-mask")||c.math_mask,g=b.formatMask(f,d,c.math_wrapPrefix,c.math_wrapSuffix);"function"==typeof c.math_complete&&(g=c.math_complete(a,c,g,d,e)),g!==!1&&a.html(g)}};/**
|
||||
* @preserve IntegraXor Web SCADA - JavaScript Number Formatter
|
||||
* http:// www.integraxor.com/
|
||||
* author: KPL, KHL
|
||||
* (c)2011 ecava
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*/
|
||||
b.formatMask=function(a,b,c,d){if(!a||isNaN(+b))return b;var e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x="",y="";if(s=a.length,t=a.search(/[0-9\-\+#]/),u=t>0?a.substring(0,t):"",x=u,t>0&&c&&(x=/\{content\}/.test(c||"")?(c||"").replace(/\{content\}/g,u||""):(c||"")+u),w=a.split("").reverse().join(""),v=w.search(/[0-9\-\+#]/),q=s-v,q+="."===a.substring(q,q+1)?1:0,u=v>0?a.substring(q,s):"",y=u,""!==u&&d&&(y=/\{content\}/.test(d||"")?(d||"").replace(/\{content\}/g,u||""):u+(d||"")),a=a.substring(t,q),b="-"==a.charAt(0)?-b:+b,e=0>b?b=-b:0,f=a.match(/[^\d\-\+#]/g),g=f&&f[f.length-1]||".",h=f&&f[1]&&f[0]||",",a=a.split(g),b=b.toFixed(a[1]&&a[1].length),b=+b+"",j=a[1]&&a[1].lastIndexOf("0"),l=b.split("."),(!l[1]||l[1]&&l[1].length<=j)&&(b=(+b).toFixed(j+1)),m=a[0].split(h),a[0]=m.join(""),i=a[0]&&a[0].indexOf("0"),i>-1)for(;l[0].length<a[0].length-i;)l[0]="0"+l[0];else 0===+l[0]&&(l[0]="");if(b=b.split("."),b[0]=l[0],k=m[1]&&m[m.length-1].length){for(n=b[0],o="",p=n.length%k,r=n.length,q=0;r>q;q++)o+=n.charAt(q),!((q-p+1)%k)&&r-k>q&&(o+=h);b[0]=o}return b[1]=a[1]&&b[1]?g+b[1]:"",x+((e?"-":"")+b[0]+b[1])+y},b.equations={count:function(a){return a.length},sum:function(b){var c=0;return a.each(b,function(a){c+=b[a]}),c},mean:function(a){var c=b.equations.sum(a);return c/a.length},median:function(a){a.sort(function(a,b){return a-b});var b=Math.floor(a.length/2);return a.length%2?a[b]:(a[b-1]+a[b])/2},mode:function(a){if(0===a.length)return"none";var b,c,d={},e=1,f=[a[0]];for(b=0;b<a.length;b++)c=a[b],d[c]=d[c]?d[c]+1:1,d[c]>e?(f=[c],e=d[c]):d[c]===e&&(f.push(c),e=d[c]);return f.sort(function(a,b){return a-b})},max:function(a){return Math.max.apply(Math,a)},min:function(a){return Math.min.apply(Math,a)},range:function(a){var b=a.sort(function(a,b){return a-b});return b[a.length-1]-b[0]},variance:function(a,c){for(var d=b.equations.mean(a),e=0,f=a.length;f--;)e+=Math.pow(a[f]-d,2);return e/=a.length-(c?0:1)},varp:function(a){return b.equations.variance(a,!0)},vars:function(a){return b.equations.variance(a)},stdevs:function(a){var c=b.equations.variance(a);return Math.sqrt(c)},stdevp:function(a){var c=b.equations.variance(a,!0);return Math.sqrt(c)}},b.addWidget({id:"math",priority:100,options:{math_data:"math",math_ignore:[],math_mask:"#,##0.00",math_complete:null,math_priority:["row","above","col"],math_prefix:"",math_suffix:"",math_event:"recalculate"},init:function(a,d,e,f){e.$table.off((c.events+" updateComplete.tsmath "+f.math_event).replace(/\s+/g," ")).on(c.events+" "+f.math_event,function(d){var g="tablesorter-initialized"===d.type;(!f.math_isUpdating||g)&&(/filter/.test(d.type)||b.computeColumnIndex(e.$table.children("tbody").children()),c.recalculate(a,e,f,g))}).on("updateComplete.tsmath",function(){setTimeout(function(){f.math_isUpdating=!1},20)}),f.math_isUpdating=!1},remove:function(b,d,e,f){f||a(b).off((c.events+" updateComplete.tsmath "+e.math_event).replace(/\s+/g," ")).find("[data-"+e.math_data+"]").empty()}})}(jQuery);
|
||||
b.formatMask=function(a,b,c,d){if(!a||isNaN(+b))return b;var e,f,g,h,i,j,k,m,n,o,p,q,r,s,t,u="",v=a.length,w=a.search(/[0-9\-\+#]/),x=w>0?a.substring(0,w):"",y=x;if(w>0&&c&&(y=/\{content\}/.test(c||"")?(c||"").replace(/\{content\}/g,x||""):(c||"")+x),t=a.split("").reverse().join(""),s=t.search(/[0-9\-\+#]/),r=v-s,r+="."===a.substring(r,r+1)?1:0,x=s>0?a.substring(r,v):"",u=x,""!==x&&d&&(u=/\{content\}/.test(d||"")?(d||"").replace(/\{content\}/g,x||""):x+(d||"")),a=a.substring(w,r),b="-"==a.charAt(0)?-b:+b,e=0>b?b=-b:0,f=a.match(/[^\d\-\+#]/g),g=f&&f[f.length-1]||".",h=f&&f[1]&&f[0]||",",a=a.split(g),b=b.toFixed(a[1]&&a[1].length),b=+b+"",j=a[1]&&a[1].lastIndexOf("0"),m=b.split("."),(!m[1]||m[1]&&m[1].length<=j)&&(b=(+b).toFixed(j+1)),n=a[0].split(h),a[0]=n.join(""),i=a[0]&&a[0].indexOf("0"),i>-1)for(;m[0].length<a[0].length-i;)m[0]="0"+m[0];else 0===+m[0]&&(m[0]="");if(b=b.split("."),b[0]=m[0],k=n[1]&&n[n.length-1].length){for(o=b[0],p="",q=o.length%k,v=o.length,r=0;v>r;r++)p+=o.charAt(r),!((r-q+1)%k)&&r<l-k&&(p+=h);b[0]=p}return b[1]=a[1]&&b[1]?g+b[1]:"",y+((e?"-":"")+b[0]+b[1])+u},b.equations={count:function(a){return a.length},sum:function(a){var b,c=a.length,d=0;for(b=0;c>b;b++)d+=a[b];return d},mean:function(a){var c=b.equations.sum(a);return c/a.length},median:function(a){var b,d=a.length;return d>1?(a.sort(function(a,b){return a-b}),b=Math.floor(d/2),d%2?a[b]:(a[b-1]+a[b])/2):c.invalid("median",1)},mode:function(a){var b,c,d,e={},f=1,g=[a[0]];for(b=0;b<a.length;b++)c=a[b],e[c]=e[c]?e[c]+1:1,d=e[c],d>f?(g=[c],f=d):d===f&&(g.push(c),f=d);return g.sort(function(a,b){return a-b})},max:function(a){return Math.max.apply(Math,a)},min:function(a){return Math.min.apply(Math,a)},range:function(a){var b=a.sort(function(a,b){return a-b});return b[a.length-1]-b[0]},variance:function(a,d){for(var e,f=b.equations.mean(a),g=0,h=a.length;h--;)g+=Math.pow(a[h]-f,2);return e=a.length-(d?0:1),0===e?c.invalid("variance",0):g/=e},varp:function(a){return b.equations.variance(a,!0)},vars:function(a){return b.equations.variance(a)},stdevs:function(a){var c=b.equations.variance(a);return Math.sqrt(c)},stdevp:function(a){var c=b.equations.variance(a,!0);return Math.sqrt(c)}},b.addWidget({id:"math",priority:100,options:{math_data:"math",math_ignore:[],math_mask:"#,##0.00",math_complete:null,math_priority:["row","above","col"],math_prefix:"",math_suffix:"",math_event:"recalculate"},init:function(a,d,e,f){var g=b.hasWidget(a,"filter")?"filterEnd":"updateComplete";e.$table.off((c.events+" updateComplete.tsmath "+f.math_event).replace(/\s+/g," ")).on(c.events+" "+f.math_event,function(d){var g="tablesorter-initialized"===d.type;(!f.math_isUpdating||g)&&(/filter/.test(d.type)||b.computeColumnIndex(e.$table.children("tbody").children()),c.recalculate(a,e,f,g))}).on(g+".tsmath",function(){setTimeout(function(){f.math_isUpdating&&e.debug&&console.groupEnd&&console.groupEnd(),f.math_isUpdating=!1},40)}),f.math_isUpdating=!1},remove:function(a,b,d,e){e||b.$table.off((c.events+" updateComplete.tsmath "+d.math_event).replace(/\s+/g," ")).find("[data-"+d.math_data+"]").empty()}})}(jQuery);
|
2
dist/js/widgets/widget-pager.min.js
vendored
2
dist/js/widgets/widget-pager.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-saveSort.min.js
vendored
2
dist/js/widgets/widget-saveSort.min.js
vendored
@ -1,2 +1,2 @@
|
||||
/*! Widget: saveSort */
|
||||
!function(a){"use strict";var b=a.tablesorter||{};b.addWidget({id:"saveSort",priority:20,options:{saveSort:!0},init:function(a,b,c,d){b.format(a,c,d,!0)},format:function(c,d,e,f){var g,h,i=d.$table,j=e.saveSort!==!1,k={sortList:d.sortList};d.debug&&(h=new Date),i.hasClass("hasSaveSort")?j&&c.hasInitialized&&b.storage&&(b.storage(c,"tablesorter-savesort",k),d.debug&&b.benchmark("saveSort widget: Saving last sort: "+d.sortList,h)):(i.addClass("hasSaveSort"),k="",b.storage&&(g=b.storage(c,"tablesorter-savesort"),k=g&&g.hasOwnProperty("sortList")&&a.isArray(g.sortList)?g.sortList:"",d.debug&&b.benchmark('saveSort: Last sort loaded: "'+k+'"',h),i.bind("saveSortReset",function(a){a.stopPropagation(),b.storage(c,"tablesorter-savesort","")})),f&&k&&k.length>0?d.sortList=k:c.hasInitialized&&k&&k.length>0&&i.trigger("sorton",[k]))},remove:function(a,c){c.$table.removeClass("hasSaveSort"),b.storage&&b.storage(a,"tablesorter-savesort","")}})}(jQuery);
|
||||
!function(a){"use strict";var b=a.tablesorter||{};b.addWidget({id:"saveSort",priority:20,options:{saveSort:!0},init:function(a,b,c,d){b.format(a,c,d,!0)},format:function(c,d,e,f){var g,h,i=d.$table,j=e.saveSort!==!1,k={sortList:d.sortList};d.debug&&(h=new Date),i.hasClass("hasSaveSort")?j&&c.hasInitialized&&b.storage&&(b.storage(c,"tablesorter-savesort",k),d.debug&&console.log("saveSort widget: Saving last sort: "+d.sortList+b.benchmark(h))):(i.addClass("hasSaveSort"),k="",b.storage&&(g=b.storage(c,"tablesorter-savesort"),k=g&&g.hasOwnProperty("sortList")&&a.isArray(g.sortList)?g.sortList:"",d.debug&&console.log('saveSort: Last sort loaded: "'+k+'"'+b.benchmark(h)),i.bind("saveSortReset",function(a){a.stopPropagation(),b.storage(c,"tablesorter-savesort","")})),f&&k&&k.length>0?d.sortList=k:c.hasInitialized&&k&&k.length>0&&i.trigger("sorton",[k]))},remove:function(a,c){c.$table.removeClass("hasSaveSort"),b.storage&&b.storage(a,"tablesorter-savesort","")}})}(jQuery);
|
2
dist/js/widgets/widget-storage.min.js
vendored
2
dist/js/widgets/widget-storage.min.js
vendored
@ -1,2 +1,2 @@
|
||||
/*! Widget: storage - updated 3/26/2015 (v2.21.3) */
|
||||
!function(a,b,c){"use strict";var d=a.tablesorter||{};d.storage=function(e,f,g,h){e=a(e)[0];var i,j,k,l=!1,m={},n=e.config,o=n&&n.widgetOptions,p=h&&h.useSessionStorage||o&&o.storage_useSessionStorage?"sessionStorage":"localStorage",q=a(e),r=h&&h.id||q.attr(h&&h.group||o&&o.storage_group||"data-table-group")||o&&o.storage_tableId||e.id||a(".tablesorter").index(q),s=h&&h.url||q.attr(h&&h.page||o&&o.storage_page||"data-table-page")||o&&o.storage_fixedUrl||n&&n.fixedUrl||b.location.pathname;if(p in b)try{b[p].setItem("_tmptest","temp"),l=!0,b[p].removeItem("_tmptest")}catch(t){n&&n.debug&&d.log(p+" is not supported in this browser")}return a.parseJSON&&(l?m=a.parseJSON(b[p][f]||"null")||{}:(j=c.cookie.split(/[;\s|=]/),i=a.inArray(f,j)+1,m=0!==i?a.parseJSON(j[i]||"null")||{}:{})),(g||""===g)&&b.JSON&&JSON.hasOwnProperty("stringify")?(m[s]||(m[s]={}),m[s][r]=g,l?b[p][f]=JSON.stringify(m):(k=new Date,k.setTime(k.getTime()+31536e6),c.cookie=f+"="+JSON.stringify(m).replace(/\"/g,'"')+"; expires="+k.toGMTString()+"; path=/"),void 0):m&&m[s]?m[s][r]:""}}(jQuery,window,document);
|
||||
!function(a,b,c){"use strict";var d=a.tablesorter||{};d.storage=function(d,e,f,g){d=a(d)[0];var h,i,j,k=!1,l={},m=d.config,n=m&&m.widgetOptions,o=g&&g.useSessionStorage||n&&n.storage_useSessionStorage?"sessionStorage":"localStorage",p=a(d),q=g&&g.id||p.attr(g&&g.group||n&&n.storage_group||"data-table-group")||n&&n.storage_tableId||d.id||a(".tablesorter").index(p),r=g&&g.url||p.attr(g&&g.page||n&&n.storage_page||"data-table-page")||n&&n.storage_fixedUrl||m&&m.fixedUrl||b.location.pathname;if(o in b)try{b[o].setItem("_tmptest","temp"),k=!0,b[o].removeItem("_tmptest")}catch(s){m&&m.debug&&console.warn(o+" is not supported in this browser")}return a.parseJSON&&(k?l=a.parseJSON(b[o][e]||"null")||{}:(i=c.cookie.split(/[;\s|=]/),h=a.inArray(e,i)+1,l=0!==h?a.parseJSON(i[h]||"null")||{}:{})),(f||""===f)&&b.JSON&&JSON.hasOwnProperty("stringify")?(l[r]||(l[r]={}),l[r][q]=f,k?b[o][e]=JSON.stringify(l):(j=new Date,j.setTime(j.getTime()+31536e6),c.cookie=e+"="+JSON.stringify(l).replace(/\"/g,'"')+"; expires="+j.toGMTString()+"; path=/"),void 0):l&&l[r]?l[r][q]:""}}(jQuery,window,document);
|
2
dist/js/widgets/widget-uitheme.min.js
vendored
2
dist/js/widgets/widget-uitheme.min.js
vendored
@ -1,2 +1,2 @@
|
||||
/*! Widget: uitheme - updated 3/26/2015 (v2.21.3) */
|
||||
!function(a){"use strict";var b=a.tablesorter||{};b.themes={bootstrap:{table:"table table-bordered table-striped",caption:"caption",header:"bootstrap-header",sortNone:"",sortAsc:"",sortDesc:"",active:"",hover:"",icons:"",iconSortNone:"bootstrap-icon-unsorted",iconSortAsc:"icon-chevron-up glyphicon glyphicon-chevron-up",iconSortDesc:"icon-chevron-down glyphicon glyphicon-chevron-down",filterRow:"",footerRow:"",footerCells:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",caption:"ui-widget-content",header:"ui-widget-header ui-corner-all ui-state-default",sortNone:"",sortAsc:"",sortDesc:"",active:"ui-state-active",hover:"ui-state-hover",icons:"ui-icon",iconSortNone:"ui-icon-carat-2-n-s",iconSortAsc:"ui-icon-carat-1-n",iconSortDesc:"ui-icon-carat-1-s",filterRow:"",footerRow:"",footerCells:"",even:"ui-widget-content",odd:"ui-state-default"}},a.extend(b.css,{wrapper:"tablesorter-wrapper"}),b.addWidget({id:"uitheme",priority:10,format:function(c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r=b.themes,s=d.$table.add(a(d.namespace+"_extra_table")),t=d.$headers.add(a(d.namespace+"_extra_headers")),u=d.theme||"jui",v=r[u]||{},w=a.trim([v.sortNone,v.sortDesc,v.sortAsc,v.active].join(" ")),x=a.trim([v.iconSortNone,v.iconSortDesc,v.iconSortAsc].join(" "));for(d.debug&&(i=new Date),s.hasClass("tablesorter-"+u)&&d.theme===d.appliedTheme&&e.uitheme_applied||(e.uitheme_applied=!0,n=r[d.appliedTheme]||{},q=!a.isEmptyObject(n),o=q?[n.sortNone,n.sortDesc,n.sortAsc,n.active].join(" "):"",p=q?[n.iconSortNone,n.iconSortDesc,n.iconSortAsc].join(" "):"",q&&(e.zebra[0]=a.trim(" "+e.zebra[0].replace(" "+n.even,"")),e.zebra[1]=a.trim(" "+e.zebra[1].replace(" "+n.odd,"")),d.$tbodies.children().removeClass([n.even,n.odd].join(" "))),v.even&&(e.zebra[0]+=" "+v.even),v.odd&&(e.zebra[1]+=" "+v.odd),s.children("caption").removeClass(n.caption||"").addClass(v.caption),l=s.removeClass((d.appliedTheme?"tablesorter-"+(d.appliedTheme||""):"")+" "+(n.table||"")).addClass("tablesorter-"+u+" "+(v.table||"")).children("tfoot"),d.appliedTheme=d.theme,l.length&&l.children("tr").removeClass(n.footerRow||"").addClass(v.footerRow).children("th, td").removeClass(n.footerCells||"").addClass(v.footerCells),t.removeClass((q?[n.header,n.hover,o].join(" "):"")||"").addClass(v.header).not(".sorter-false").unbind("mouseenter.tsuitheme mouseleave.tsuitheme").bind("mouseenter.tsuitheme mouseleave.tsuitheme",function(b){a(this)["mouseenter"===b.type?"addClass":"removeClass"](v.hover||"")}),t.each(function(){var c=a(this);c.find("."+b.css.wrapper).length||c.wrapInner('<div class="'+b.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>')}),d.cssIcon&&t.find("."+b.css.icon).removeClass(q?[n.icons,p].join(" "):"").addClass(v.icons||""),s.hasClass("hasFilters")&&s.children("thead").children("."+b.css.filterRow).removeClass(q?n.filterRow||"":"").addClass(v.filterRow||"")),f=0;f<d.columns;f++)j=d.$headers.add(a(d.namespace+"_extra_headers")).not(".sorter-false").filter('[data-column="'+f+'"]'),k=b.css.icon?j.find("."+b.css.icon):a(),m=t.not(".sorter-false").filter('[data-column="'+f+'"]:last'),m.length&&(j.removeClass(w),k.removeClass(x),m[0].sortDisabled?k.removeClass(v.icons||""):(g=v.sortNone,h=v.iconSortNone,m.hasClass(b.css.sortAsc)?(g=[v.sortAsc,v.active].join(" "),h=v.iconSortAsc):m.hasClass(b.css.sortDesc)&&(g=[v.sortDesc,v.active].join(" "),h=v.iconSortDesc),j.addClass(g),k.addClass(h||"")));d.debug&&b.benchmark("Applying "+u+" theme",i)},remove:function(a,c,d,e){if(d.uitheme_applied){var f=c.$table,g=c.appliedTheme||"jui",h=b.themes[g]||b.themes.jui,i=f.children("thead").children(),j=h.sortNone+" "+h.sortDesc+" "+h.sortAsc,k=h.iconSortNone+" "+h.iconSortDesc+" "+h.iconSortAsc;f.removeClass("tablesorter-"+g+" "+h.table),d.uitheme_applied=!1,e||(f.find(b.css.header).removeClass(h.header),i.unbind("mouseenter.tsuitheme mouseleave.tsuitheme").removeClass(h.hover+" "+j+" "+h.active).filter("."+b.css.filterRow).removeClass(h.filterRow),i.find("."+b.css.icon).removeClass(h.icons+" "+k))}}})}(jQuery);
|
||||
!function(a){"use strict";var b=a.tablesorter||{};b.themes={bootstrap:{table:"table table-bordered table-striped",caption:"caption",header:"bootstrap-header",sortNone:"",sortAsc:"",sortDesc:"",active:"",hover:"",icons:"",iconSortNone:"bootstrap-icon-unsorted",iconSortAsc:"icon-chevron-up glyphicon glyphicon-chevron-up",iconSortDesc:"icon-chevron-down glyphicon glyphicon-chevron-down",filterRow:"",footerRow:"",footerCells:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",caption:"ui-widget-content",header:"ui-widget-header ui-corner-all ui-state-default",sortNone:"",sortAsc:"",sortDesc:"",active:"ui-state-active",hover:"ui-state-hover",icons:"ui-icon",iconSortNone:"ui-icon-carat-2-n-s",iconSortAsc:"ui-icon-carat-1-n",iconSortDesc:"ui-icon-carat-1-s",filterRow:"",footerRow:"",footerCells:"",even:"ui-widget-content",odd:"ui-state-default"}},a.extend(b.css,{wrapper:"tablesorter-wrapper"}),b.addWidget({id:"uitheme",priority:10,format:function(c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r=b.themes,s=d.$table.add(a(d.namespace+"_extra_table")),t=d.$headers.add(a(d.namespace+"_extra_headers")),u=d.theme||"jui",v=r[u]||{},w=a.trim([v.sortNone,v.sortDesc,v.sortAsc,v.active].join(" ")),x=a.trim([v.iconSortNone,v.iconSortDesc,v.iconSortAsc].join(" "));for(d.debug&&(i=new Date),s.hasClass("tablesorter-"+u)&&d.theme===d.appliedTheme&&e.uitheme_applied||(e.uitheme_applied=!0,n=r[d.appliedTheme]||{},q=!a.isEmptyObject(n),o=q?[n.sortNone,n.sortDesc,n.sortAsc,n.active].join(" "):"",p=q?[n.iconSortNone,n.iconSortDesc,n.iconSortAsc].join(" "):"",q&&(e.zebra[0]=a.trim(" "+e.zebra[0].replace(" "+n.even,"")),e.zebra[1]=a.trim(" "+e.zebra[1].replace(" "+n.odd,"")),d.$tbodies.children().removeClass([n.even,n.odd].join(" "))),v.even&&(e.zebra[0]+=" "+v.even),v.odd&&(e.zebra[1]+=" "+v.odd),s.children("caption").removeClass(n.caption||"").addClass(v.caption),l=s.removeClass((d.appliedTheme?"tablesorter-"+(d.appliedTheme||""):"")+" "+(n.table||"")).addClass("tablesorter-"+u+" "+(v.table||"")).children("tfoot"),d.appliedTheme=d.theme,l.length&&l.children("tr").removeClass(n.footerRow||"").addClass(v.footerRow).children("th, td").removeClass(n.footerCells||"").addClass(v.footerCells),t.removeClass((q?[n.header,n.hover,o].join(" "):"")||"").addClass(v.header).not(".sorter-false").unbind("mouseenter.tsuitheme mouseleave.tsuitheme").bind("mouseenter.tsuitheme mouseleave.tsuitheme",function(b){a(this)["mouseenter"===b.type?"addClass":"removeClass"](v.hover||"")}),t.each(function(){var c=a(this);c.find("."+b.css.wrapper).length||c.wrapInner('<div class="'+b.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>')}),d.cssIcon&&t.find("."+b.css.icon).removeClass(q?[n.icons,p].join(" "):"").addClass(v.icons||""),s.hasClass("hasFilters")&&s.children("thead").children("."+b.css.filterRow).removeClass(q?n.filterRow||"":"").addClass(v.filterRow||"")),f=0;f<d.columns;f++)j=d.$headers.add(a(d.namespace+"_extra_headers")).not(".sorter-false").filter('[data-column="'+f+'"]'),k=b.css.icon?j.find("."+b.css.icon):a(),m=t.not(".sorter-false").filter('[data-column="'+f+'"]:last'),m.length&&(j.removeClass(w),k.removeClass(x),m[0].sortDisabled?k.removeClass(v.icons||""):(g=v.sortNone,h=v.iconSortNone,m.hasClass(b.css.sortAsc)?(g=[v.sortAsc,v.active].join(" "),h=v.iconSortAsc):m.hasClass(b.css.sortDesc)&&(g=[v.sortDesc,v.active].join(" "),h=v.iconSortDesc),j.addClass(g),k.addClass(h||"")));d.debug&&console.log("Applying "+u+" theme"+b.benchmark(i))},remove:function(a,c,d,e){if(d.uitheme_applied){var f=c.$table,g=c.appliedTheme||"jui",h=b.themes[g]||b.themes.jui,i=f.children("thead").children(),j=h.sortNone+" "+h.sortDesc+" "+h.sortAsc,k=h.iconSortNone+" "+h.iconSortDesc+" "+h.iconSortAsc;f.removeClass("tablesorter-"+g+" "+h.table),d.uitheme_applied=!1,e||(f.find(b.css.header).removeClass(h.header),i.unbind("mouseenter.tsuitheme mouseleave.tsuitheme").removeClass(h.hover+" "+j+" "+h.active).filter("."+b.css.filterRow).removeClass(h.filterRow),i.find("."+b.css.icon).removeClass(h.icons+" "+k))}}})}(jQuery);
|
@ -129,7 +129,7 @@
|
||||
pos = endIndex === cols ? false : endIndex <= startIndex,
|
||||
$rows = c.$table.children().children( 'tr' );
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Inserting column ' + startIndex + ( pos ? ' before' : ' after' ) + ' column ' + endIndex );
|
||||
console.log( 'Inserting column ' + startIndex + ( pos ? ' before' : ' after' ) + ' column ' + endIndex );
|
||||
}
|
||||
$rows.each( function() {
|
||||
$cols = $( this ).children();
|
||||
|
@ -4,7 +4,7 @@
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||
*/
|
||||
/*! tablesorter (FORK) - updated 07-23-2015 (v2.22.2)*/
|
||||
/*! tablesorter (FORK) - updated 07-24-2015 (v2.22.2)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -172,24 +172,6 @@
|
||||
// These methods can be applied on table.config instance
|
||||
ts.instanceMethods = {};
|
||||
|
||||
/* debuging utils */
|
||||
function log() {
|
||||
var a = arguments[0],
|
||||
s = arguments.length > 1 ? Array.prototype.slice.call(arguments) : a;
|
||||
if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
|
||||
console[ /error/i.test(a) ? 'error' : /warn/i.test(a) ? 'warn' : 'log' ](s);
|
||||
} else {
|
||||
alert(s);
|
||||
}
|
||||
}
|
||||
|
||||
function benchmark(s, d) {
|
||||
log(s + ' (' + (new Date().getTime() - d.getTime()) + 'ms)');
|
||||
}
|
||||
|
||||
ts.log = log;
|
||||
ts.benchmark = benchmark;
|
||||
|
||||
// $.isEmptyObject from jQuery v1.4
|
||||
function isEmptyObject(obj) {
|
||||
/*jshint forin: false */
|
||||
@ -237,7 +219,7 @@
|
||||
nodeValue = ts.getElementText(c, node, cellIndex);
|
||||
$node = $(node);
|
||||
if (c.debug) {
|
||||
log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
console.log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
}
|
||||
} else {
|
||||
keepLooking = false;
|
||||
@ -284,16 +266,16 @@
|
||||
var rows, list, l, i, h, ch, np, p, e, time, tb, len,
|
||||
table = c.table,
|
||||
j = 0,
|
||||
parsersDebug = '';
|
||||
debug = {};
|
||||
// update table bodies in case we start with an empty table
|
||||
c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')');
|
||||
tb = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
|
||||
len = tb.length;
|
||||
if ( len === 0) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
} else if (c.debug) {
|
||||
time = new Date();
|
||||
log('Detecting parsers for each column');
|
||||
console[ console.group ? 'group' : 'log' ]('Detecting parsers for each column');
|
||||
}
|
||||
list = {
|
||||
extractors: [],
|
||||
@ -326,7 +308,12 @@
|
||||
p = detectParserForColumn(c, rows, -1, i);
|
||||
}
|
||||
if (c.debug) {
|
||||
parsersDebug += 'column:' + i + '; extractor:' + e.id + '; parser:' + p.id + '; string:' + c.strings[i] + '; empty: ' + c.empties[i] + '\n';
|
||||
debug[ '(' + i + ') ' + h.text() ] = {
|
||||
parser : p.id,
|
||||
extractor : e ? e.id : 'none',
|
||||
string : c.strings[i],
|
||||
empty : c.empties[i]
|
||||
};
|
||||
}
|
||||
list.parsers[i] = p;
|
||||
list.extractors[i] = e;
|
||||
@ -335,8 +322,13 @@
|
||||
j += (list.parsers.length) ? len : 1;
|
||||
}
|
||||
if ( c.debug ) {
|
||||
log(parsersDebug ? parsersDebug : 'No parsers detected');
|
||||
benchmark('Completed detecting parsers', time);
|
||||
if ( !isEmptyObject( debug ) ) {
|
||||
console[ console.table ? 'table' : 'log' ]( debug );
|
||||
} else {
|
||||
console.warn( ' No parsers detected!' );
|
||||
}
|
||||
console.log( 'Completed detecting parsers' + ts.benchmark( time ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
c.parsers = list.parsers;
|
||||
c.extractors = list.extractors;
|
||||
@ -355,7 +347,7 @@
|
||||
c.totalRows = 0;
|
||||
// if no parsers found, return - it's an empty table.
|
||||
if (!parsers) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a cache') : '';
|
||||
}
|
||||
if (c.debug) {
|
||||
cacheTime = new Date();
|
||||
@ -408,7 +400,7 @@
|
||||
for ( j = 0; j < c.columns; ++j ) {
|
||||
if (typeof parsers[ j ] === 'undefined') {
|
||||
if ( c.debug ) {
|
||||
log( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
console.warn( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -434,7 +426,7 @@
|
||||
ts.isProcessing( table ); // remove processing icon
|
||||
}
|
||||
if ( c.debug ) {
|
||||
benchmark( 'Building cache for ' + totalRows + ' rows', cacheTime );
|
||||
console.log( 'Building cache for ' + totalRows + ' rows' + ts.benchmark( cacheTime ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -478,7 +470,7 @@
|
||||
c.appender(table, rows);
|
||||
}
|
||||
if (c.debug) {
|
||||
benchmark('Rebuilt table', appendTime);
|
||||
console.log( 'Rebuilt table' + ts.benchmark(appendTime) );
|
||||
}
|
||||
// apply table widgets; but not before ajax completes
|
||||
if (!init && !c.appender) { ts.applyWidget(table); }
|
||||
@ -559,8 +551,8 @@
|
||||
// enable/disable sorting
|
||||
updateHeader(table);
|
||||
if (c.debug) {
|
||||
benchmark('Built headers:', time);
|
||||
log(c.$headers);
|
||||
console.log( 'Built headers:' + ts.benchmark( time ) );
|
||||
console.log( c.$headers );
|
||||
}
|
||||
}
|
||||
|
||||
@ -883,7 +875,9 @@
|
||||
return a[c.columns].order - b[c.columns].order;
|
||||
});
|
||||
}
|
||||
if (c.debug) { benchmark('Sorting on ' + sortList.toString() + ' and dir ' + order + ' time', sortTime); }
|
||||
if (c.debug) {
|
||||
console.log( 'Sorting on ' + sortList.toString() + ' and dir ' + order + ' time' + ts.benchmark(sortTime) );
|
||||
}
|
||||
}
|
||||
|
||||
function resortComplete(c, callback){
|
||||
@ -1127,7 +1121,14 @@
|
||||
ts.setup = function(table, c) {
|
||||
// if no thead or tbody, or tablesorter is already present, quit
|
||||
if (!table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true) {
|
||||
return c.debug ? log('ERROR: stopping initialization! No table, thead, tbody or tablesorter has already been initialized') : '';
|
||||
if ( c.debug ) {
|
||||
if ( table.hasInitialized ) {
|
||||
console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
|
||||
} else {
|
||||
console.error( 'Stopping initialization! No table, thead or tbody' );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var k = '',
|
||||
@ -1141,7 +1142,10 @@
|
||||
table.config = c;
|
||||
// save the settings where they read
|
||||
$.data(table, 'tablesorter', c);
|
||||
if (c.debug) { $.data( table, 'startoveralltimer', new Date()); }
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter' );
|
||||
$.data( table, 'startoveralltimer', new Date());
|
||||
}
|
||||
|
||||
// removing this in version 3 (only supports jQuery 1.7+)
|
||||
c.supportsDataObject = (function(version) {
|
||||
@ -1240,7 +1244,8 @@
|
||||
table.hasInitialized = true;
|
||||
table.isProcessing = false;
|
||||
if (c.debug) {
|
||||
ts.benchmark('Overall initialization time', $.data( table, 'startoveralltimer'));
|
||||
console.log( 'Overall initialization time: ' + ts.benchmark( $.data( table, 'startoveralltimer') ) );
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
$table.trigger('tablesorter-initialized', table);
|
||||
if (typeof c.initialized === 'function') { c.initialized(table); }
|
||||
@ -1483,6 +1488,7 @@
|
||||
var events,
|
||||
$t = $(table),
|
||||
c = table.config,
|
||||
debug = c.debug,
|
||||
$h = $t.find('thead:first'),
|
||||
$r = $h.find('tr.' + ts.css.headerRow).removeClass(ts.css.headerRow + ' ' + c.cssHeaderRow),
|
||||
$f = $t.find('tfoot:first > tr').children('th, td');
|
||||
@ -1514,6 +1520,9 @@
|
||||
if (typeof callback === 'function') {
|
||||
callback(table);
|
||||
}
|
||||
if (debug) {
|
||||
console.log( 'tablesorter has been removed' );
|
||||
}
|
||||
};
|
||||
|
||||
// *** sort functions ***
|
||||
@ -1737,7 +1746,7 @@
|
||||
|
||||
ts.applyWidget = function(table, init, callback) {
|
||||
table = $(table)[0]; // in case this is called externally
|
||||
var indx, len, name,
|
||||
var indx, len, names, widget, name, applied,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
tableClass = ' ' + c.table.className + ' ',
|
||||
@ -1765,11 +1774,11 @@
|
||||
c.widgets = $.grep(c.widgets, function(v, k){
|
||||
return $.inArray(v, c.widgets) === k;
|
||||
});
|
||||
name = c.widgets || [];
|
||||
len = name.length;
|
||||
names = c.widgets || [];
|
||||
len = names.length;
|
||||
// build widget array & add priority as needed
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
wd = ts.getWidgetById(name[indx]);
|
||||
wd = ts.getWidgetById(names[indx]);
|
||||
if (wd && wd.id) {
|
||||
// set priority to 10 if not defined
|
||||
if (!wd.priority) { wd.priority = 10; }
|
||||
@ -1782,28 +1791,47 @@
|
||||
});
|
||||
// add/update selected widgets
|
||||
len = widgets.length;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
|
||||
}
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (widgets[indx]) {
|
||||
if ( init || !( c.widgetInit[ widgets[indx].id ] ) ) {
|
||||
widget = widgets[indx];
|
||||
if (widget) {
|
||||
name = widget.id;
|
||||
applied = false;
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
|
||||
if ( init || !( c.widgetInit[ name ] ) ) {
|
||||
// set init flag first to prevent calling init more than once (e.g. pager)
|
||||
c.widgetInit[ widgets[indx].id ] = true;
|
||||
c.widgetInit[ name ] = true;
|
||||
if (table.hasInitialized) {
|
||||
// don't reapply widget options on tablesorter init
|
||||
ts.applyWidgetOptions( table, c );
|
||||
}
|
||||
if ( 'init' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].init(table, widgets[indx], c, wo);
|
||||
if (c.debug) { ts.benchmark('Initializing ' + widgets[indx].id + ' widget', time2); }
|
||||
if ( 'init' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
|
||||
}
|
||||
widget.init(table, widget, c, wo);
|
||||
}
|
||||
}
|
||||
if ( !init && 'format' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].format(table, c, wo, false);
|
||||
if (c.debug) { ts.benchmark( ( init ? 'Initializing ' : 'Applying ' ) + widgets[indx].id + ' widget', time2); }
|
||||
if ( !init && 'format' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
|
||||
}
|
||||
widget.format(table, c, wo, false);
|
||||
}
|
||||
if (c.debug) {
|
||||
if (applied) {
|
||||
console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time2 ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
// callback executed on init only
|
||||
if (!init && typeof callback === 'function') {
|
||||
callback(table);
|
||||
@ -1815,7 +1843,7 @@
|
||||
}, 0);
|
||||
if (c.debug) {
|
||||
w = c.widgets.length;
|
||||
benchmark('Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : ''), time);
|
||||
console.log( 'Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : '') + ts.benchmark(time) );
|
||||
}
|
||||
};
|
||||
|
||||
@ -1843,7 +1871,10 @@
|
||||
widget = ts.getWidgetById(name[i]);
|
||||
indx = $.inArray( name[i], c.widgets );
|
||||
if ( widget && 'remove' in widget ) {
|
||||
if (c.debug && indx >= 0) { log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if (c.debug && indx >= 0) { console.log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if ( c.debug ) {
|
||||
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[i] + '" widget' );
|
||||
}
|
||||
widget.remove(table, c, c.widgetOptions, refreshing);
|
||||
c.widgetInit[ name[i] ] = false;
|
||||
}
|
||||
@ -1891,7 +1922,11 @@
|
||||
allColumns = column === 'all',
|
||||
data = { raw : [], parsed: [], $cell: [] },
|
||||
c = table.config;
|
||||
if ( !isEmptyObject( c ) ) {
|
||||
if ( isEmptyObject( c ) ) {
|
||||
if ( c.debug ) {
|
||||
console.warn( 'No cache found - aborting getColumnText function!' );
|
||||
}
|
||||
} else {
|
||||
tbodyLen = c.$tbodies.length;
|
||||
for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
|
||||
cache = c.cache[ tbodyIndex ].normalized;
|
||||
@ -1987,6 +2022,23 @@
|
||||
tablesorter: ts.construct
|
||||
});
|
||||
|
||||
// set up debug logs
|
||||
if ( !( console && console.log ) ) {
|
||||
ts.logs = [];
|
||||
/*jshint -W020 */
|
||||
console = {};
|
||||
console.log = console.warn = console.error = console.table = function() {
|
||||
ts.logs.push( [ Date.now(), arguments ] );
|
||||
};
|
||||
}
|
||||
|
||||
ts.log = function(){
|
||||
console.log( arguments );
|
||||
};
|
||||
ts.benchmark = function( diff ) {
|
||||
return ( ' (' + ( new Date().getTime() - diff.getTime() ) + 'ms)' );
|
||||
};
|
||||
|
||||
// add default parsers
|
||||
ts.addParser({
|
||||
id: 'no-parser',
|
||||
@ -2248,7 +2300,7 @@
|
||||
window[storageType].removeItem('_tmptest');
|
||||
} catch (error) {
|
||||
if (c && c.debug) {
|
||||
ts.log( storageType + ' is not supported in this browser' );
|
||||
console.warn( storageType + ' is not supported in this browser' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2446,7 +2498,7 @@
|
||||
}
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.benchmark('Applying ' + theme + ' theme', time);
|
||||
console.log('Applying ' + theme + ' theme' + ts.benchmark(time));
|
||||
}
|
||||
},
|
||||
remove: function(table, c, wo, refreshing) {
|
||||
@ -3677,7 +3729,7 @@
|
||||
}
|
||||
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Starting filter widget search', filters );
|
||||
console.log( 'Filter: Starting filter widget search', filters );
|
||||
time = new Date();
|
||||
}
|
||||
// filtered rows count
|
||||
@ -3767,7 +3819,7 @@
|
||||
// can't search when all rows are hidden - this happens when looking for exact matches
|
||||
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Searching through ' +
|
||||
console.log( 'Filter: Searching through ' +
|
||||
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
|
||||
}
|
||||
if ( data.anyMatchFlag ) {
|
||||
@ -3853,7 +3905,7 @@
|
||||
ts.storage( table, 'tablesorter-filters', storedFilters );
|
||||
}
|
||||
if ( c.debug ) {
|
||||
ts.benchmark( 'Completed filter widget search', time );
|
||||
console.log( 'Completed filter widget search' + ts.benchmark(time) );
|
||||
}
|
||||
if ( wo.filter_initialized ) {
|
||||
c.$table.trigger( 'filterEnd', c );
|
||||
@ -4875,7 +4927,7 @@
|
||||
if (saveSort && table.hasInitialized && ts.storage) {
|
||||
ts.storage( table, 'tablesorter-savesort', sortList );
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort widget: Saving last sort: ' + c.sortList, time);
|
||||
console.log('saveSort widget: Saving last sort: ' + c.sortList + ts.benchmark(time));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -4887,7 +4939,7 @@
|
||||
stored = ts.storage( table, 'tablesorter-savesort' );
|
||||
sortList = (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort: Last sort loaded: "' + sortList + '"', time);
|
||||
console.log('saveSort: Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
|
||||
}
|
||||
$table.bind('saveSortReset', function(event) {
|
||||
event.stopPropagation();
|
||||
|
@ -154,24 +154,6 @@
|
||||
// These methods can be applied on table.config instance
|
||||
ts.instanceMethods = {};
|
||||
|
||||
/* debuging utils */
|
||||
function log() {
|
||||
var a = arguments[0],
|
||||
s = arguments.length > 1 ? Array.prototype.slice.call(arguments) : a;
|
||||
if (typeof console !== 'undefined' && typeof console.log !== 'undefined') {
|
||||
console[ /error/i.test(a) ? 'error' : /warn/i.test(a) ? 'warn' : 'log' ](s);
|
||||
} else {
|
||||
alert(s);
|
||||
}
|
||||
}
|
||||
|
||||
function benchmark(s, d) {
|
||||
log(s + ' (' + (new Date().getTime() - d.getTime()) + 'ms)');
|
||||
}
|
||||
|
||||
ts.log = log;
|
||||
ts.benchmark = benchmark;
|
||||
|
||||
// $.isEmptyObject from jQuery v1.4
|
||||
function isEmptyObject(obj) {
|
||||
/*jshint forin: false */
|
||||
@ -219,7 +201,7 @@
|
||||
nodeValue = ts.getElementText(c, node, cellIndex);
|
||||
$node = $(node);
|
||||
if (c.debug) {
|
||||
log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
console.log('Checking if value was empty on row ' + rowIndex + ', column: ' + cellIndex + ': "' + nodeValue + '"');
|
||||
}
|
||||
} else {
|
||||
keepLooking = false;
|
||||
@ -266,16 +248,16 @@
|
||||
var rows, list, l, i, h, ch, np, p, e, time, tb, len,
|
||||
table = c.table,
|
||||
j = 0,
|
||||
parsersDebug = '';
|
||||
debug = {};
|
||||
// update table bodies in case we start with an empty table
|
||||
c.$tbodies = c.$table.children('tbody:not(.' + c.cssInfoBlock + ')');
|
||||
tb = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
|
||||
len = tb.length;
|
||||
if ( len === 0) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a parser cache') : '';
|
||||
} else if (c.debug) {
|
||||
time = new Date();
|
||||
log('Detecting parsers for each column');
|
||||
console[ console.group ? 'group' : 'log' ]('Detecting parsers for each column');
|
||||
}
|
||||
list = {
|
||||
extractors: [],
|
||||
@ -308,7 +290,12 @@
|
||||
p = detectParserForColumn(c, rows, -1, i);
|
||||
}
|
||||
if (c.debug) {
|
||||
parsersDebug += 'column:' + i + '; extractor:' + e.id + '; parser:' + p.id + '; string:' + c.strings[i] + '; empty: ' + c.empties[i] + '\n';
|
||||
debug[ '(' + i + ') ' + h.text() ] = {
|
||||
parser : p.id,
|
||||
extractor : e ? e.id : 'none',
|
||||
string : c.strings[i],
|
||||
empty : c.empties[i]
|
||||
};
|
||||
}
|
||||
list.parsers[i] = p;
|
||||
list.extractors[i] = e;
|
||||
@ -317,8 +304,13 @@
|
||||
j += (list.parsers.length) ? len : 1;
|
||||
}
|
||||
if ( c.debug ) {
|
||||
log(parsersDebug ? parsersDebug : 'No parsers detected');
|
||||
benchmark('Completed detecting parsers', time);
|
||||
if ( !isEmptyObject( debug ) ) {
|
||||
console[ console.table ? 'table' : 'log' ]( debug );
|
||||
} else {
|
||||
console.warn( ' No parsers detected!' );
|
||||
}
|
||||
console.log( 'Completed detecting parsers' + ts.benchmark( time ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
c.parsers = list.parsers;
|
||||
c.extractors = list.extractors;
|
||||
@ -337,7 +329,7 @@
|
||||
c.totalRows = 0;
|
||||
// if no parsers found, return - it's an empty table.
|
||||
if (!parsers) {
|
||||
return c.debug ? log('Warning: *Empty table!* Not building a cache') : '';
|
||||
return c.debug ? console.warn('Warning: *Empty table!* Not building a cache') : '';
|
||||
}
|
||||
if (c.debug) {
|
||||
cacheTime = new Date();
|
||||
@ -390,7 +382,7 @@
|
||||
for ( j = 0; j < c.columns; ++j ) {
|
||||
if (typeof parsers[ j ] === 'undefined') {
|
||||
if ( c.debug ) {
|
||||
log( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
console.warn( 'No parser found for cell:', $row[ 0 ].cells[ j ], 'does it have a header?' );
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -416,7 +408,7 @@
|
||||
ts.isProcessing( table ); // remove processing icon
|
||||
}
|
||||
if ( c.debug ) {
|
||||
benchmark( 'Building cache for ' + totalRows + ' rows', cacheTime );
|
||||
console.log( 'Building cache for ' + totalRows + ' rows' + ts.benchmark( cacheTime ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -460,7 +452,7 @@
|
||||
c.appender(table, rows);
|
||||
}
|
||||
if (c.debug) {
|
||||
benchmark('Rebuilt table', appendTime);
|
||||
console.log( 'Rebuilt table' + ts.benchmark(appendTime) );
|
||||
}
|
||||
// apply table widgets; but not before ajax completes
|
||||
if (!init && !c.appender) { ts.applyWidget(table); }
|
||||
@ -541,8 +533,8 @@
|
||||
// enable/disable sorting
|
||||
updateHeader(table);
|
||||
if (c.debug) {
|
||||
benchmark('Built headers:', time);
|
||||
log(c.$headers);
|
||||
console.log( 'Built headers:' + ts.benchmark( time ) );
|
||||
console.log( c.$headers );
|
||||
}
|
||||
}
|
||||
|
||||
@ -865,7 +857,9 @@
|
||||
return a[c.columns].order - b[c.columns].order;
|
||||
});
|
||||
}
|
||||
if (c.debug) { benchmark('Sorting on ' + sortList.toString() + ' and dir ' + order + ' time', sortTime); }
|
||||
if (c.debug) {
|
||||
console.log( 'Sorting on ' + sortList.toString() + ' and dir ' + order + ' time' + ts.benchmark(sortTime) );
|
||||
}
|
||||
}
|
||||
|
||||
function resortComplete(c, callback){
|
||||
@ -1109,7 +1103,14 @@
|
||||
ts.setup = function(table, c) {
|
||||
// if no thead or tbody, or tablesorter is already present, quit
|
||||
if (!table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true) {
|
||||
return c.debug ? log('ERROR: stopping initialization! No table, thead, tbody or tablesorter has already been initialized') : '';
|
||||
if ( c.debug ) {
|
||||
if ( table.hasInitialized ) {
|
||||
console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
|
||||
} else {
|
||||
console.error( 'Stopping initialization! No table, thead or tbody' );
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var k = '',
|
||||
@ -1123,7 +1124,10 @@
|
||||
table.config = c;
|
||||
// save the settings where they read
|
||||
$.data(table, 'tablesorter', c);
|
||||
if (c.debug) { $.data( table, 'startoveralltimer', new Date()); }
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter' );
|
||||
$.data( table, 'startoveralltimer', new Date());
|
||||
}
|
||||
|
||||
// removing this in version 3 (only supports jQuery 1.7+)
|
||||
c.supportsDataObject = (function(version) {
|
||||
@ -1222,7 +1226,8 @@
|
||||
table.hasInitialized = true;
|
||||
table.isProcessing = false;
|
||||
if (c.debug) {
|
||||
ts.benchmark('Overall initialization time', $.data( table, 'startoveralltimer'));
|
||||
console.log( 'Overall initialization time: ' + ts.benchmark( $.data( table, 'startoveralltimer') ) );
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
$table.trigger('tablesorter-initialized', table);
|
||||
if (typeof c.initialized === 'function') { c.initialized(table); }
|
||||
@ -1465,6 +1470,7 @@
|
||||
var events,
|
||||
$t = $(table),
|
||||
c = table.config,
|
||||
debug = c.debug,
|
||||
$h = $t.find('thead:first'),
|
||||
$r = $h.find('tr.' + ts.css.headerRow).removeClass(ts.css.headerRow + ' ' + c.cssHeaderRow),
|
||||
$f = $t.find('tfoot:first > tr').children('th, td');
|
||||
@ -1496,6 +1502,9 @@
|
||||
if (typeof callback === 'function') {
|
||||
callback(table);
|
||||
}
|
||||
if (debug) {
|
||||
console.log( 'tablesorter has been removed' );
|
||||
}
|
||||
};
|
||||
|
||||
// *** sort functions ***
|
||||
@ -1719,7 +1728,7 @@
|
||||
|
||||
ts.applyWidget = function(table, init, callback) {
|
||||
table = $(table)[0]; // in case this is called externally
|
||||
var indx, len, name,
|
||||
var indx, len, names, widget, name, applied,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
tableClass = ' ' + c.table.className + ' ',
|
||||
@ -1747,11 +1756,11 @@
|
||||
c.widgets = $.grep(c.widgets, function(v, k){
|
||||
return $.inArray(v, c.widgets) === k;
|
||||
});
|
||||
name = c.widgets || [];
|
||||
len = name.length;
|
||||
names = c.widgets || [];
|
||||
len = names.length;
|
||||
// build widget array & add priority as needed
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
wd = ts.getWidgetById(name[indx]);
|
||||
wd = ts.getWidgetById(names[indx]);
|
||||
if (wd && wd.id) {
|
||||
// set priority to 10 if not defined
|
||||
if (!wd.priority) { wd.priority = 10; }
|
||||
@ -1764,28 +1773,47 @@
|
||||
});
|
||||
// add/update selected widgets
|
||||
len = widgets.length;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
|
||||
}
|
||||
for (indx = 0; indx < len; indx++) {
|
||||
if (widgets[indx]) {
|
||||
if ( init || !( c.widgetInit[ widgets[indx].id ] ) ) {
|
||||
widget = widgets[indx];
|
||||
if (widget) {
|
||||
name = widget.id;
|
||||
applied = false;
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
|
||||
if ( init || !( c.widgetInit[ name ] ) ) {
|
||||
// set init flag first to prevent calling init more than once (e.g. pager)
|
||||
c.widgetInit[ widgets[indx].id ] = true;
|
||||
c.widgetInit[ name ] = true;
|
||||
if (table.hasInitialized) {
|
||||
// don't reapply widget options on tablesorter init
|
||||
ts.applyWidgetOptions( table, c );
|
||||
}
|
||||
if ( 'init' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].init(table, widgets[indx], c, wo);
|
||||
if (c.debug) { ts.benchmark('Initializing ' + widgets[indx].id + ' widget', time2); }
|
||||
if ( 'init' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
|
||||
}
|
||||
widget.init(table, widget, c, wo);
|
||||
}
|
||||
}
|
||||
if ( !init && 'format' in widgets[indx] ) {
|
||||
if (c.debug) { time2 = new Date(); }
|
||||
widgets[indx].format(table, c, wo, false);
|
||||
if (c.debug) { ts.benchmark( ( init ? 'Initializing ' : 'Applying ' ) + widgets[indx].id + ' widget', time2); }
|
||||
if ( !init && 'format' in widget ) {
|
||||
applied = true;
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
|
||||
}
|
||||
widget.format(table, c, wo, false);
|
||||
}
|
||||
if (c.debug) {
|
||||
if (applied) {
|
||||
console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time2 ) );
|
||||
if ( console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
// callback executed on init only
|
||||
if (!init && typeof callback === 'function') {
|
||||
callback(table);
|
||||
@ -1797,7 +1825,7 @@
|
||||
}, 0);
|
||||
if (c.debug) {
|
||||
w = c.widgets.length;
|
||||
benchmark('Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : ''), time);
|
||||
console.log( 'Completed ' + (init === true ? 'initializing ' : 'applying ') + w + ' widget' + (w !== 1 ? 's' : '') + ts.benchmark(time) );
|
||||
}
|
||||
};
|
||||
|
||||
@ -1825,7 +1853,10 @@
|
||||
widget = ts.getWidgetById(name[i]);
|
||||
indx = $.inArray( name[i], c.widgets );
|
||||
if ( widget && 'remove' in widget ) {
|
||||
if (c.debug && indx >= 0) { log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if (c.debug && indx >= 0) { console.log( 'Removing "' + name[i] + '" widget' ); }
|
||||
if ( c.debug ) {
|
||||
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[i] + '" widget' );
|
||||
}
|
||||
widget.remove(table, c, c.widgetOptions, refreshing);
|
||||
c.widgetInit[ name[i] ] = false;
|
||||
}
|
||||
@ -1873,7 +1904,11 @@
|
||||
allColumns = column === 'all',
|
||||
data = { raw : [], parsed: [], $cell: [] },
|
||||
c = table.config;
|
||||
if ( !isEmptyObject( c ) ) {
|
||||
if ( isEmptyObject( c ) ) {
|
||||
if ( c.debug ) {
|
||||
console.warn( 'No cache found - aborting getColumnText function!' );
|
||||
}
|
||||
} else {
|
||||
tbodyLen = c.$tbodies.length;
|
||||
for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
|
||||
cache = c.cache[ tbodyIndex ].normalized;
|
||||
@ -1969,6 +2004,23 @@
|
||||
tablesorter: ts.construct
|
||||
});
|
||||
|
||||
// set up debug logs
|
||||
if ( !( console && console.log ) ) {
|
||||
ts.logs = [];
|
||||
/*jshint -W020 */
|
||||
console = {};
|
||||
console.log = console.warn = console.error = console.table = function() {
|
||||
ts.logs.push( [ Date.now(), arguments ] );
|
||||
};
|
||||
}
|
||||
|
||||
ts.log = function(){
|
||||
console.log( arguments );
|
||||
};
|
||||
ts.benchmark = function( diff ) {
|
||||
return ( ' (' + ( new Date().getTime() - diff.getTime() ) + 'ms)' );
|
||||
};
|
||||
|
||||
// add default parsers
|
||||
ts.addParser({
|
||||
id: 'no-parser',
|
||||
|
@ -4,7 +4,7 @@
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||
*/
|
||||
/*! tablesorter (FORK) - updated 07-23-2015 (v2.22.2)*/
|
||||
/*! tablesorter (FORK) - updated 07-24-2015 (v2.22.2)*/
|
||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||
(function(factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
@ -68,7 +68,7 @@
|
||||
window[storageType].removeItem('_tmptest');
|
||||
} catch (error) {
|
||||
if (c && c.debug) {
|
||||
ts.log( storageType + ' is not supported in this browser' );
|
||||
console.warn( storageType + ' is not supported in this browser' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -266,7 +266,7 @@
|
||||
}
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.benchmark('Applying ' + theme + ' theme', time);
|
||||
console.log('Applying ' + theme + ' theme' + ts.benchmark(time));
|
||||
}
|
||||
},
|
||||
remove: function(table, c, wo, refreshing) {
|
||||
@ -1497,7 +1497,7 @@
|
||||
}
|
||||
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Starting filter widget search', filters );
|
||||
console.log( 'Filter: Starting filter widget search', filters );
|
||||
time = new Date();
|
||||
}
|
||||
// filtered rows count
|
||||
@ -1587,7 +1587,7 @@
|
||||
// can't search when all rows are hidden - this happens when looking for exact matches
|
||||
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Searching through ' +
|
||||
console.log( 'Filter: Searching through ' +
|
||||
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
|
||||
}
|
||||
if ( data.anyMatchFlag ) {
|
||||
@ -1673,7 +1673,7 @@
|
||||
ts.storage( table, 'tablesorter-filters', storedFilters );
|
||||
}
|
||||
if ( c.debug ) {
|
||||
ts.benchmark( 'Completed filter widget search', time );
|
||||
console.log( 'Completed filter widget search' + ts.benchmark(time) );
|
||||
}
|
||||
if ( wo.filter_initialized ) {
|
||||
c.$table.trigger( 'filterEnd', c );
|
||||
@ -2695,7 +2695,7 @@
|
||||
if (saveSort && table.hasInitialized && ts.storage) {
|
||||
ts.storage( table, 'tablesorter-savesort', sortList );
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort widget: Saving last sort: ' + c.sortList, time);
|
||||
console.log('saveSort widget: Saving last sort: ' + c.sortList + ts.benchmark(time));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -2707,7 +2707,7 @@
|
||||
stored = ts.storage( table, 'tablesorter-savesort' );
|
||||
sortList = (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort: Last sort loaded: "' + sortList + '"', time);
|
||||
console.log('saveSort: Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
|
||||
}
|
||||
$table.bind('saveSortReset', function(event) {
|
||||
event.stopPropagation();
|
||||
|
@ -57,7 +57,7 @@
|
||||
|
||||
// even if wo.build_type is undefined, we can try to figure out the type
|
||||
if ( !ts.buildTable.hasOwnProperty(typ) && typ !== '' ) {
|
||||
if (c.debug) { ts.log('aborting build table widget, incorrect build type'); }
|
||||
if (c.debug) { console.error('aborting build table widget, incorrect build type'); }
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -71,7 +71,7 @@
|
||||
runType(data);
|
||||
})
|
||||
.fail(function( jqXHR, textStatus, errorThrown) {
|
||||
if (c.debug) { ts.log('aborting build table widget, failed ajax load'); }
|
||||
if (c.debug) { console.error('aborting build table widget, failed ajax load'); }
|
||||
$tbl.html('<tr><td class="error">' + jqXHR.status + ' ' + textStatus + '</td></tr>');
|
||||
});
|
||||
} else {
|
||||
@ -356,7 +356,7 @@
|
||||
r = data.hasOwnProperty(kr) && !$.isEmptyObject(data.kr) ? data.kr : data.hasOwnProperty('rows') ? data.rows : false;
|
||||
|
||||
if (!h || !r || h.length === 0 || r.length === 0) {
|
||||
if (c.debug) { ts.log('aborting build table widget, missing data for object build'); }
|
||||
if (c.debug) { console.error('aborting build table widget, missing data for object build'); }
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@
|
||||
$t = $(wo.columnSelector_layout);
|
||||
if (!$t.find('input').add( $t.filter('input') ).length) {
|
||||
if (c.debug) {
|
||||
ts.log('ColumnSelector: >> ERROR: Column Selector aborting, no input found in the layout! ***');
|
||||
console.error('ColumnSelector: >> ERROR: Column Selector aborting, no input found in the layout! ***');
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -45,7 +45,7 @@
|
||||
if (colSel.$container.length) {
|
||||
tsColSel.updateCols(c, wo);
|
||||
} else if (c.debug) {
|
||||
ts.log('ColumnSelector: >> container not found');
|
||||
console.warn('ColumnSelector: >> container not found');
|
||||
}
|
||||
|
||||
c.$table
|
||||
|
@ -1124,7 +1124,7 @@
|
||||
}
|
||||
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Starting filter widget search', filters );
|
||||
console.log( 'Filter: Starting filter widget search', filters );
|
||||
time = new Date();
|
||||
}
|
||||
// filtered rows count
|
||||
@ -1214,7 +1214,7 @@
|
||||
// can't search when all rows are hidden - this happens when looking for exact matches
|
||||
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
|
||||
if ( c.debug ) {
|
||||
ts.log( 'Filter: Searching through ' +
|
||||
console.log( 'Filter: Searching through ' +
|
||||
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
|
||||
}
|
||||
if ( data.anyMatchFlag ) {
|
||||
@ -1300,7 +1300,7 @@
|
||||
ts.storage( table, 'tablesorter-filters', storedFilters );
|
||||
}
|
||||
if ( c.debug ) {
|
||||
ts.benchmark( 'Completed filter widget search', time );
|
||||
console.log( 'Completed filter widget search' + ts.benchmark(time) );
|
||||
}
|
||||
if ( wo.filter_initialized ) {
|
||||
c.$table.trigger( 'filterEnd', c );
|
||||
|
@ -11,38 +11,56 @@
|
||||
|
||||
math = {
|
||||
|
||||
error: {
|
||||
0 : 'Infinity result: Divide by zero',
|
||||
1 : 'Need more than one element to make this calculation',
|
||||
'undef' : 'No elements found'
|
||||
},
|
||||
|
||||
// value returned when calculation is not possible, e.g. no values, dividing by zero, etc.
|
||||
invalid : function( name, errorIndex ) {
|
||||
// name = function returning invalid results
|
||||
// errorIndex = math.error index with an explanation of the error
|
||||
console.log( name, math.error[ errorIndex ] );
|
||||
return 'none'; // text for cell
|
||||
},
|
||||
|
||||
events : ( 'tablesorter-initialized update updateAll updateRows addRows updateCell ' +
|
||||
'filterReset filterEnd ' ).split(' ').join('.tsmath '),
|
||||
|
||||
processText : function( c, $cell ) {
|
||||
var txt = $cell.attr( c.textAttribute );
|
||||
if ( typeof txt === 'undefined' ) {
|
||||
txt = $cell[0].textContent || $cell.text();
|
||||
}
|
||||
txt = ts.formatFloat( txt.replace( /[^\w,. \-()]/g, '' ), c.table ) || 0;
|
||||
// isNaN('') => false
|
||||
return isNaN( txt ) ? 0 : txt;
|
||||
},
|
||||
|
||||
// get all of the row numerical values in an arry
|
||||
getRow : function(table, wo, $el, dataAttrib) {
|
||||
getRow : function( c, $el ) {
|
||||
var $t, txt,
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
arry = [],
|
||||
$row = $el.closest( 'tr' ),
|
||||
$cells = $row.children().not('[' + dataAttrib + '=ignore]');
|
||||
$cells = $row.children().not( '[' + wo.math_dataAttrib + '=ignore]' );
|
||||
if ( !$row.hasClass( wo.filter_filteredRow || 'filtered' ) ) {
|
||||
if ( wo.math_ignore.length ) {
|
||||
$cells = $cells.not( '[data-column=' + wo.math_ignore.join( '],[data-column=' ) + ']' );
|
||||
}
|
||||
arry = $cells.not( $el ).map( function() {
|
||||
$t = $(this);
|
||||
txt = $t.attr(c.textAttribute);
|
||||
if (typeof txt === 'undefined') {
|
||||
txt = this.textContent || $t.text();
|
||||
}
|
||||
txt = ts.formatFloat(txt.replace(/[^\w,. \-()]/g, ''), table) || 0;
|
||||
return isNaN(txt) ? 0 : txt;
|
||||
return math.processText( c, $( this ) );
|
||||
}).get();
|
||||
}
|
||||
return arry;
|
||||
},
|
||||
|
||||
// get all of the column numerical values in an arry
|
||||
getColumn : function(table, wo, $el, type, dataAttrib) {
|
||||
var i, txt, $t, len, mathAbove,
|
||||
getColumn : function( c, $el, type ) {
|
||||
var index, txt, $t, len, $mathRows, mathAbove,
|
||||
arry = [],
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
filtered = wo.filter_filteredRow || 'filtered',
|
||||
cIndex = parseInt( $el.attr( 'data-column' ), 10 ),
|
||||
$rows = c.$table.children( 'tbody' ).children(),
|
||||
@ -51,66 +69,62 @@
|
||||
// $rows.add( c.$table.children( 'tfoot' ).children() );
|
||||
if ( type === 'above' ) {
|
||||
len = $rows.index( $row );
|
||||
i = len;
|
||||
while (i >= 0) {
|
||||
$t = $rows.eq(i).children().filter('[data-column=' + cIndex + ']');
|
||||
mathAbove = $t.filter('[' + dataAttrib + '^=above]').length;
|
||||
index = len;
|
||||
while ( index >= 0 ) {
|
||||
$t = $rows.eq( index ).children().filter( '[data-column=' + cIndex + ']' );
|
||||
mathAbove = $t.filter( '[' + wo.math_dataAttrib + '^=above]' ).length;
|
||||
// ignore filtered rows & rows with data-math="ignore" (and starting row)
|
||||
if ( ( !$rows.eq(i).hasClass(filtered) && $rows.eq(i).not('[' + dataAttrib + '=ignore]').length && i !== len ) || mathAbove && i !== len ) {
|
||||
if ( ( !$rows.eq( index ).hasClass( filtered ) &&
|
||||
$rows.eq( index ).not( '[' + wo.math_dataAttrib + '=ignore]' ).length &&
|
||||
index !== len ) ||
|
||||
mathAbove && index !== len ) {
|
||||
// stop calculating 'above', when encountering another 'above'
|
||||
if ( mathAbove ) {
|
||||
i = 0;
|
||||
index = 0;
|
||||
} else if ( $t.length ) {
|
||||
txt = $t.attr(c.textAttribute);
|
||||
if (typeof txt === 'undefined') {
|
||||
txt = $t[0].textContent || $t.text();
|
||||
}
|
||||
txt = ts.formatFloat(txt.replace(/[^\w,. \-()]/g, ''), table) || 0;
|
||||
arry.push(isNaN(txt) ? 0 : txt);
|
||||
arry.push( math.processText( c, $t ) );
|
||||
}
|
||||
}
|
||||
i--;
|
||||
index--;
|
||||
}
|
||||
} else {
|
||||
$rows.not('[' + dataAttrib + '=ignore]').each(function(){
|
||||
$t = $(this).children().filter('[data-column=' + cIndex + ']');
|
||||
if (!$(this).hasClass(filtered) && $t.not('[' + dataAttrib + '^=above],[' + dataAttrib + '^=col]').length && !$t.is($el)) {
|
||||
txt = $t.attr(c.textAttribute);
|
||||
if (typeof txt === 'undefined') {
|
||||
txt = ($t[0] ? $t[0].textContent : '') || $t.text();
|
||||
$mathRows = $rows.not( '[' + wo.math_dataAttrib + '=ignore]' ); // .each(function(){
|
||||
len = $mathRows.length;
|
||||
for ( index = 0; index < len; index++ ) {
|
||||
$t = $mathRows.eq( index ).children().filter( '[data-column=' + cIndex + ']' );
|
||||
if ( !$mathRows.eq( index ).hasClass( filtered ) &&
|
||||
$t.not( '[' + wo.math_dataAttrib + '^=above],[' + wo.math_dataAttrib + '^=col]' ).length &&
|
||||
!$t.is( $el ) ) {
|
||||
arry.push( math.processText( c, $t ) );
|
||||
}
|
||||
// isNaN('') => false
|
||||
txt = ts.formatFloat(txt.replace(/[^\w,. \-()]/g, ''), table) || 0;
|
||||
arry.push(isNaN(txt) ? 0 : txt);
|
||||
}
|
||||
});
|
||||
}
|
||||
return arry;
|
||||
},
|
||||
|
||||
// get all of the column numerical values in an arry
|
||||
getAll : function(table, wo, dataAttrib) {
|
||||
var txt, $t, col,
|
||||
getAll : function( c ) {
|
||||
var txt, $t, col, $row, rowIndex, rowLen, $cells, cellIndex, cellLen,
|
||||
arry = [],
|
||||
c = table.config,
|
||||
wo = c.widgetOptions,
|
||||
filtered = wo.filter_filteredRow || 'filtered',
|
||||
$rows = c.$table.children('tbody').children();
|
||||
$rows.each(function(){
|
||||
if (!$(this).hasClass(filtered)) {
|
||||
$(this).children().each(function(){
|
||||
$t = $(this);
|
||||
$rows = c.$table.children( 'tbody' ).children().not( '[' + wo.math_dataAttrib + '=ignore]' );
|
||||
rowLen = $rows.length;
|
||||
for ( rowIndex = 0; rowIndex < rowLen; rowIndex++ ) {
|
||||
$row = $rows.eq( rowIndex );
|
||||
if ( !$row.hasClass( filtered ) ) {
|
||||
$cells = $row.children().not( '[' + wo.math_dataAttrib + '=ignore]' );
|
||||
cellLen = $cells.length;
|
||||
// $row.children().each(function(){
|
||||
for ( cellIndex = 0; cellIndex < cellLen; cellIndex++ ) {
|
||||
$t = $cells.eq( cellIndex );
|
||||
col = parseInt( $t.attr( 'data-column' ), 10);
|
||||
if (!$t.filter('[' + dataAttrib + ']').length && $.inArray(col, wo.math_ignore) < 0) {
|
||||
txt = $t.attr(c.textAttribute);
|
||||
if (typeof txt === 'undefined') {
|
||||
txt = ($t[0] ? $t[0].textContent : '') || $t.text();
|
||||
if ( !$t.filter( '[' + wo.math_dataAttrib + ']' ).length && $.inArray( col, wo.math_ignore ) < 0 ) {
|
||||
arry.push( math.processText( c, $t ) );
|
||||
}
|
||||
}
|
||||
txt = ts.formatFloat(txt.replace(/[^\w,. \-()]/g, ''), table) || 0;
|
||||
arry.push(isNaN(txt) ? 0 : txt);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return arry;
|
||||
},
|
||||
|
||||
@ -123,54 +137,80 @@
|
||||
}
|
||||
|
||||
// data-attribute name (defaults to data-math)
|
||||
var dataAttrib = 'data-' + (wo.math_data || 'math'),
|
||||
wo.math_dataAttrib = 'data-' + (wo.math_data || 'math');
|
||||
|
||||
// all non-info tbody cells
|
||||
$mathCells = c.$tbodies.find('[' + dataAttrib + ']');
|
||||
math.mathType( table, wo, $mathCells, wo.math_priority, dataAttrib );
|
||||
var $mathCells = c.$tbodies.find( '[' + wo.math_dataAttrib + ']' );
|
||||
math.mathType( c, $mathCells, wo.math_priority );
|
||||
|
||||
// only info tbody cells
|
||||
$mathCells = c.$table.find('.' + c.cssInfoBlock + ', tfoot').find('[' + dataAttrib + ']');
|
||||
math.mathType( table, wo, $mathCells, wo.math_priority, dataAttrib );
|
||||
$mathCells = c.$table
|
||||
.children( '.' + c.cssInfoBlock + ', tfoot' )
|
||||
.find( '[' + wo.math_dataAttrib + ']' );
|
||||
math.mathType( c, $mathCells, wo.math_priority );
|
||||
|
||||
// find the 'all' total
|
||||
math.mathType( table, wo, c.$table.find('[' + dataAttrib + '^=all]'), [ 'all' ], dataAttrib );
|
||||
$mathCells = c.$table.find( '[' + wo.math_dataAttrib + '^=all]' );
|
||||
math.mathType( c, $mathCells, [ 'all' ] );
|
||||
|
||||
wo.math_isUpdating = true;
|
||||
if ( c.debug ) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Math widget triggering an update after recalculation' );
|
||||
}
|
||||
c.$table.trigger( 'update' );
|
||||
}
|
||||
},
|
||||
|
||||
mathType : function(table, wo, $cells, priority, dataAttrib) {
|
||||
mathType : function( c, $cells, priority ) {
|
||||
if ( $cells.length ) {
|
||||
var formula, t, $t, arry, getAll,
|
||||
eq = ts.equations;
|
||||
var formula, result, $el, arry, getAll, $targetCells, index, len,
|
||||
wo = c.widgetOptions,
|
||||
equations = ts.equations;
|
||||
if ( priority[0] === 'all' ) {
|
||||
// no need to get all cells more than once
|
||||
getAll = math.getAll(table, wo, dataAttrib);
|
||||
getAll = math.getAll( c );
|
||||
}
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( 'Tablesorter Math widget recalculation' );
|
||||
}
|
||||
// $.each is okay here... only 3 priorities
|
||||
$.each( priority, function( i, type ) {
|
||||
$cells.filter('[' + dataAttrib + '^=' + type + ']').each(function(){
|
||||
$t = $(this);
|
||||
formula = ($t.attr(dataAttrib) || '').replace(type + '-', '');
|
||||
arry = (type === 'row') ? math.getRow(table, wo, $t, dataAttrib) :
|
||||
(type === 'all') ? getAll : math.getColumn(table, wo, $t, type, dataAttrib);
|
||||
if (eq[formula]) {
|
||||
t = eq[formula](arry);
|
||||
if (table.config.debug && console && console.log) {
|
||||
console.log($t.attr(dataAttrib), arry, '=', t);
|
||||
$targetCells = $cells.filter( '[' + wo.math_dataAttrib + '^=' + type + ']' );
|
||||
len = $targetCells.length;
|
||||
if ( len ) {
|
||||
if (c.debug) {
|
||||
console[ console.group ? 'group' : 'log' ]( type );
|
||||
}
|
||||
math.output( $t, wo, t, arry );
|
||||
for ( index = 0; index < len; index++ ) {
|
||||
$el = $targetCells.eq( index );
|
||||
formula = ( $el.attr( wo.math_dataAttrib ) || '' ).replace( type + '-', '' );
|
||||
arry = ( type === 'row' ) ? math.getRow( c, $el ) :
|
||||
( type === 'all' ) ? getAll : math.getColumn( c, $el, type );
|
||||
if ( equations[ formula ] ) {
|
||||
if ( arry.length ) {
|
||||
result = equations[ formula ]( arry );
|
||||
if ( c.debug ) {
|
||||
console.log( $el.attr( wo.math_dataAttrib ), arry, '=', result );
|
||||
}
|
||||
} else {
|
||||
// mean will return a divide by zero error, everything else shows an undefined error
|
||||
result = math.invalid( formula, formula === 'mean' ? 0 : 'undef' );
|
||||
}
|
||||
math.output( $el, wo, result, arry );
|
||||
}
|
||||
}
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
});
|
||||
});
|
||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
}
|
||||
},
|
||||
|
||||
output : function( $cell, wo, value, arry ) {
|
||||
// get mask from cell data-attribute: data-math-mask="#,##0.00"
|
||||
var result = ts.formatMask( $cell.attr('data-' + wo.math_data + '-mask') || wo.math_mask, value, wo.math_wrapPrefix, wo.math_wrapSuffix );
|
||||
if ($.isFunction(wo.math_complete)) {
|
||||
var mask = $cell.attr( 'data-' + wo.math_data + '-mask' ) || wo.math_mask,
|
||||
result = ts.formatMask( mask, value, wo.math_wrapPrefix, wo.math_wrapSuffix );
|
||||
if ( typeof wo.math_complete === 'function' ) {
|
||||
result = wo.math_complete( $cell, wo, result, value, arry );
|
||||
}
|
||||
if ( result !== false ) {
|
||||
@ -188,21 +228,21 @@
|
||||
* (c)2011 ecava
|
||||
* Dual licensed under the MIT or GPL Version 2 licenses.
|
||||
*/
|
||||
ts.formatMask = function(m, v, tmpPrefix, tmpSuffix) {
|
||||
if ( !m || isNaN(+v) ) {
|
||||
return v; // return as it is.
|
||||
ts.formatMask = function( mask, val, tmpPrefix, tmpSuffix ) {
|
||||
if ( !mask || isNaN( +val ) ) {
|
||||
return val; // return as it is.
|
||||
}
|
||||
|
||||
var isNegative, result, decimal, group, posLeadZero, posTrailZero, posSeparator, part, szSep,
|
||||
integer, str, offset, i, l, len, start, tmp, end, inv,
|
||||
prefix = '',
|
||||
suffix = '';
|
||||
integer, str, offset, index, end, inv,
|
||||
suffix = '',
|
||||
|
||||
// find prefix/suffix
|
||||
len = m.length;
|
||||
start = m.search( /[0-9\-\+#]/ );
|
||||
tmp = start > 0 ? m.substring(0, start) : '';
|
||||
len = mask.length,
|
||||
start = mask.search( /[0-9\-\+#]/ ),
|
||||
tmp = start > 0 ? mask.substring( 0, start ) : '',
|
||||
prefix = tmp;
|
||||
|
||||
if ( start > 0 && tmpPrefix ) {
|
||||
if ( /\{content\}/.test( tmpPrefix || '' ) ) {
|
||||
prefix = ( tmpPrefix || '' ).replace( /\{content\}/g, tmp || '' );
|
||||
@ -211,11 +251,11 @@
|
||||
}
|
||||
}
|
||||
// reverse string: not an ideal method if there are surrogate pairs
|
||||
inv = m.split('').reverse().join('');
|
||||
inv = mask.split( '' ).reverse().join( '' );
|
||||
end = inv.search( /[0-9\-\+#]/ );
|
||||
i = len - end;
|
||||
i += (m.substring( i, i + 1 ) === '.') ? 1 : 0;
|
||||
tmp = end > 0 ? m.substring( i, len) : '';
|
||||
index = len - end;
|
||||
index += ( mask.substring( index, index + 1 ) === '.' ) ? 1 : 0;
|
||||
tmp = end > 0 ? mask.substring( index, len ) : '';
|
||||
suffix = tmp;
|
||||
if ( tmp !== '' && tmpSuffix ) {
|
||||
if ( /\{content\}/.test( tmpSuffix || '' ) ) {
|
||||
@ -224,67 +264,67 @@
|
||||
suffix = tmp + ( tmpSuffix || '' );
|
||||
}
|
||||
}
|
||||
m = m.substring(start, i);
|
||||
mask = mask.substring( start, index );
|
||||
|
||||
// convert any string to number according to formation sign.
|
||||
v = m.charAt(0) == '-' ? -v : +v;
|
||||
isNegative = v < 0 ? v = -v : 0; // process only abs(), and turn on flag.
|
||||
val = mask.charAt( 0 ) == '-' ? -val : +val;
|
||||
isNegative = val < 0 ? val = -val : 0; // process only abs(), and turn on flag.
|
||||
|
||||
// search for separator for grp & decimal, anything not digit, not +/- sign, not #.
|
||||
result = m.match( /[^\d\-\+#]/g );
|
||||
result = mask.match( /[^\d\-\+#]/g );
|
||||
decimal = ( result && result[ result.length - 1 ] ) || '.'; // treat the right most symbol as decimal
|
||||
group = ( result && result[ 1 ] && result[ 0 ] ) || ','; // treat the left most symbol as group separator
|
||||
|
||||
// split the decimal for the format string if any.
|
||||
m = m.split( decimal );
|
||||
mask = mask.split( decimal );
|
||||
// Fix the decimal first, toFixed will auto fill trailing zero.
|
||||
v = v.toFixed( m[1] && m[1].length );
|
||||
v = +(v) + ''; // convert number to string to trim off *all* trailing decimal zero(es)
|
||||
val = val.toFixed( mask[ 1 ] && mask[ 1 ].length );
|
||||
val = +( val ) + ''; // convert number to string to trim off *all* trailing decimal zero(es)
|
||||
|
||||
// fill back any trailing zero according to format
|
||||
posTrailZero = m[1] && m[1].lastIndexOf('0'); // look for last zero in format
|
||||
part = v.split('.');
|
||||
posTrailZero = mask[ 1 ] && mask[ 1 ].lastIndexOf( '0' ); // look for last zero in format
|
||||
part = val.split( '.' );
|
||||
// integer will get !part[1]
|
||||
if ( !part[ 1 ] || ( part[ 1 ] && part[ 1 ].length <= posTrailZero ) ) {
|
||||
v = (+v).toFixed( posTrailZero + 1 );
|
||||
val = ( +val ).toFixed( posTrailZero + 1 );
|
||||
}
|
||||
szSep = m[0].split( group ); // look for separator
|
||||
m[0] = szSep.join(''); // join back without separator for counting the pos of any leading 0.
|
||||
szSep = mask[ 0 ].split( group ); // look for separator
|
||||
mask[ 0 ] = szSep.join( '' ); // join back without separator for counting the pos of any leading 0.
|
||||
|
||||
posLeadZero = m[0] && m[0].indexOf('0');
|
||||
posLeadZero = mask[ 0 ] && mask[ 0 ].indexOf( '0' );
|
||||
if ( posLeadZero > -1 ) {
|
||||
while ( part[0].length < ( m[0].length - posLeadZero ) ) {
|
||||
while ( part[ 0 ].length < ( mask[ 0 ].length - posLeadZero ) ) {
|
||||
part[ 0 ] = '0' + part[ 0 ];
|
||||
}
|
||||
} else if ( +part[ 0 ] === 0 ) {
|
||||
part[ 0 ] = '';
|
||||
}
|
||||
|
||||
v = v.split('.');
|
||||
v[0] = part[0];
|
||||
val = val.split( '.' );
|
||||
val[ 0 ] = part[ 0 ];
|
||||
|
||||
// process the first group separator from decimal (.) only, the rest ignore.
|
||||
// get the length of the last slice of split result.
|
||||
posSeparator = ( szSep[ 1 ] && szSep[ szSep.length - 1 ].length );
|
||||
if ( posSeparator ) {
|
||||
integer = v[0];
|
||||
integer = val[ 0 ];
|
||||
str = '';
|
||||
offset = integer.length % posSeparator;
|
||||
l = integer.length;
|
||||
for ( i = 0; i < l; i++ ) {
|
||||
str += integer.charAt(i); // ie6 only support charAt for sz.
|
||||
len = integer.length;
|
||||
for ( index = 0; index < len; index++ ) {
|
||||
str += integer.charAt( index ); // ie6 only support charAt for sz.
|
||||
// -posSeparator so that won't trail separator on full length
|
||||
/*jshint -W018 */
|
||||
if ( !( ( i - offset + 1 ) % posSeparator ) && i < l - posSeparator ) {
|
||||
if ( !( ( index - offset + 1 ) % posSeparator ) && index < l - posSeparator ) {
|
||||
str += group;
|
||||
}
|
||||
}
|
||||
v[0] = str;
|
||||
val[ 0 ] = str;
|
||||
}
|
||||
|
||||
v[1] = ( m[1] && v[1] ) ? decimal + v[1] : '';
|
||||
val[ 1 ] = ( mask[ 1 ] && val[ 1 ] ) ? decimal + val[ 1 ] : '';
|
||||
// put back any negation, combine integer and fraction, and add back prefix & suffix
|
||||
return prefix + ( ( isNegative ? '-' : '' ) + v[0] + v[1] ) + suffix;
|
||||
return prefix + ( ( isNegative ? '-' : '' ) + val[ 0 ] + val[ 1 ] ) + suffix;
|
||||
};
|
||||
|
||||
ts.equations = {
|
||||
@ -292,10 +332,12 @@
|
||||
return arry.length;
|
||||
},
|
||||
sum : function( arry ) {
|
||||
var total = 0;
|
||||
$.each( arry, function(i) {
|
||||
total += arry[i];
|
||||
});
|
||||
var index,
|
||||
len = arry.length,
|
||||
total = 0;
|
||||
for ( index = 0; index < len; index++ ) {
|
||||
total += arry[ index ];
|
||||
}
|
||||
return total;
|
||||
},
|
||||
mean : function( arry ) {
|
||||
@ -303,27 +345,32 @@
|
||||
return total / arry.length;
|
||||
},
|
||||
median : function( arry ) {
|
||||
var half,
|
||||
len = arry.length;
|
||||
if ( len > 1 ) {
|
||||
// https://gist.github.com/caseyjustus/1166258
|
||||
arry.sort( function( a, b ){ return a - b; } );
|
||||
var half = Math.floor( arry.length / 2 );
|
||||
return (arry.length % 2) ? arry[half] : ( arry[half - 1] + arry[half] ) / 2.0;
|
||||
half = Math.floor( len / 2 );
|
||||
return ( len % 2 ) ? arry[ half ] : ( arry[ half - 1 ] + arry[ half ] ) / 2;
|
||||
}
|
||||
return math.invalid( 'median', 1 );
|
||||
},
|
||||
mode : function( arry ) {
|
||||
// http://stackoverflow.com/a/3451640/145346
|
||||
if ( arry.length === 0 ) { return 'none'; }
|
||||
var i, el,
|
||||
var index, el, m,
|
||||
modeMap = {},
|
||||
maxCount = 1,
|
||||
modes = [ arry[ 0 ] ];
|
||||
for (i = 0; i < arry.length; i++) {
|
||||
el = arry[i];
|
||||
for ( index = 0; index < arry.length; index++ ) {
|
||||
el = arry[ index ];
|
||||
modeMap[ el ] = modeMap[ el ] ? modeMap[ el ] + 1 : 1;
|
||||
if ( modeMap[el] > maxCount ) {
|
||||
m = modeMap[ el ];
|
||||
if ( m > maxCount ) {
|
||||
modes = [ el ];
|
||||
maxCount = modeMap[el];
|
||||
} else if (modeMap[el] === maxCount) {
|
||||
maxCount = m;
|
||||
} else if ( m === maxCount ) {
|
||||
modes.push( el );
|
||||
maxCount = modeMap[el];
|
||||
maxCount = m;
|
||||
}
|
||||
}
|
||||
// returns arry of modes if there is a tie
|
||||
@ -342,13 +389,18 @@
|
||||
// common variance equation
|
||||
// (not accessible via data-attribute setting)
|
||||
variance: function( arry, population ) {
|
||||
var avg = ts.equations.mean( arry ),
|
||||
var divisor,
|
||||
avg = ts.equations.mean( arry ),
|
||||
v = 0,
|
||||
i = arry.length;
|
||||
while ( i-- ) {
|
||||
v += Math.pow( ( arry[ i ] - avg ), 2 );
|
||||
}
|
||||
v /= ( arry.length - (population ? 0 : 1) );
|
||||
divisor = ( arry.length - ( population ? 0 : 1 ) );
|
||||
if ( divisor === 0 ) {
|
||||
return math.invalid( 'variance', 0 );
|
||||
}
|
||||
v /= divisor;
|
||||
return v;
|
||||
},
|
||||
// variance (population)
|
||||
@ -393,6 +445,8 @@
|
||||
math_event : 'recalculate'
|
||||
},
|
||||
init : function( table, thisWidget, c, wo ) {
|
||||
// filterEnd fires after updateComplete
|
||||
var update = ts.hasWidget( table, 'filter' ) ? 'filterEnd' : 'updateComplete';
|
||||
c.$table
|
||||
.off( ( math.events + ' updateComplete.tsmath ' + wo.math_event ).replace( /\s+/g, ' ' ) )
|
||||
.on( math.events + ' ' + wo.math_event, function( e ) {
|
||||
@ -405,10 +459,11 @@
|
||||
math.recalculate( table, c, wo, init );
|
||||
}
|
||||
})
|
||||
.on('updateComplete.tsmath', function(){
|
||||
.on( update + '.tsmath', function() {
|
||||
setTimeout( function(){
|
||||
if ( wo.math_isUpdating && c.debug && console.groupEnd ) { console.groupEnd(); }
|
||||
wo.math_isUpdating = false;
|
||||
}, 20);
|
||||
}, 40 );
|
||||
});
|
||||
wo.math_isUpdating = false;
|
||||
},
|
||||
@ -416,7 +471,7 @@
|
||||
// this function only applies to tablesorter v2.4+
|
||||
remove: function( table, c, wo, refreshing ) {
|
||||
if ( refreshing ) { return; }
|
||||
$(table)
|
||||
c.$table
|
||||
.off( ( math.events + ' updateComplete.tsmath ' + wo.math_event ).replace( /\s+/g, ' ' ) )
|
||||
.find( '[data-' + wo.math_data + ']' ).empty();
|
||||
}
|
||||
|
@ -154,7 +154,7 @@
|
||||
|
||||
p.isInitializing = true;
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Initializing');
|
||||
console.log('Pager: Initializing');
|
||||
}
|
||||
|
||||
p.size = $.data(table, 'pagerLastSize') || wo.pager_size;
|
||||
@ -218,7 +218,7 @@
|
||||
p.initializing = false;
|
||||
p.isInitializing = false;
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerInitialized');
|
||||
console.log('Pager: Triggering pagerInitialized');
|
||||
}
|
||||
c.$table.trigger('pagerInitialized', c);
|
||||
// filter widget not initialized; it will update the output display & fire off the pagerComplete event
|
||||
@ -322,7 +322,7 @@
|
||||
ctrls = [ s.first, s.prev, s.next, s.last ];
|
||||
fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
|
||||
if (c.debug && !p.$container.length) {
|
||||
ts.log('Pager: >> Container not found');
|
||||
console.warn('Pager: >> Container not found');
|
||||
}
|
||||
p.$container.find(ctrls.join(','))
|
||||
.attr('tabindex', 0)
|
||||
@ -351,7 +351,7 @@
|
||||
tsp.updatePageDisplay(table, c, false);
|
||||
});
|
||||
} else if (c.debug) {
|
||||
ts.log('Pager: >> Goto selector not found');
|
||||
console.warn('Pager: >> Goto selector not found');
|
||||
}
|
||||
|
||||
if ( p.$size.length ) {
|
||||
@ -368,7 +368,7 @@
|
||||
return false;
|
||||
});
|
||||
} else if (c.debug) {
|
||||
ts.log('Pager: >> Size selector not found');
|
||||
console.warn('Pager: >> Size selector not found');
|
||||
}
|
||||
|
||||
},
|
||||
@ -475,7 +475,7 @@
|
||||
tsp.fixHeight(table, c);
|
||||
if (p.initialized && completed !== false) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerComplete');
|
||||
console.log('Pager: Triggering pagerComplete');
|
||||
}
|
||||
c.$table.trigger('pagerComplete', c);
|
||||
// save pager info to storage
|
||||
@ -659,7 +659,7 @@
|
||||
|
||||
if ( exception ) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: >> Ajax Error', xhr, exception);
|
||||
console.error('Pager: >> Ajax Error', xhr, exception);
|
||||
}
|
||||
ts.showError(table, exception.message + ' (' + xhr.status + ')');
|
||||
c.$tbodies.eq(0).children('tr').detach();
|
||||
@ -753,7 +753,7 @@
|
||||
// multiple applyWidget blocking code from blocking this trigger
|
||||
setTimeout(function(){
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerChange');
|
||||
console.log('Pager: Triggering pagerChange');
|
||||
}
|
||||
$table
|
||||
.trigger('applyWidgets')
|
||||
@ -797,7 +797,7 @@
|
||||
}
|
||||
};
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Ajax initialized', p.ajaxObject);
|
||||
console.log('Pager: Ajax initialized', p.ajaxObject);
|
||||
}
|
||||
$.ajax(p.ajaxObject);
|
||||
}
|
||||
@ -842,7 +842,7 @@
|
||||
url = wo.pager_customAjaxUrl(table, url);
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Ajax url = ' + url);
|
||||
console.log('Pager: Ajax url = ' + url);
|
||||
}
|
||||
return url;
|
||||
},
|
||||
@ -858,7 +858,7 @@
|
||||
e = p.size;
|
||||
if ( l < 1 ) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: >> No rows for pager to render');
|
||||
console.warn('Pager: >> No rows for pager to render');
|
||||
}
|
||||
// empty table, abort!
|
||||
return;
|
||||
@ -871,7 +871,7 @@
|
||||
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
||||
if (p.initialized) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pagerChange');
|
||||
console.log('Pager: Triggering pagerChange');
|
||||
}
|
||||
c.$table.trigger('pagerChange', c);
|
||||
}
|
||||
@ -904,7 +904,7 @@
|
||||
wo.pager_size = p.size;
|
||||
if (table.isUpdating) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering updateComplete');
|
||||
console.log('Pager: Triggering updateComplete');
|
||||
}
|
||||
c.$table.trigger('updateComplete', [ table, true ]);
|
||||
}
|
||||
@ -931,7 +931,7 @@
|
||||
tsp.renderTable(table, c.rowsCopy);
|
||||
c.$table.trigger('applyWidgets');
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Disabled');
|
||||
console.log('Pager: Disabled');
|
||||
}
|
||||
}
|
||||
// disable size selector
|
||||
@ -1000,7 +1000,7 @@
|
||||
return;
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Changing to page ' + p.page);
|
||||
console.log('Pager: Changing to page ' + p.page);
|
||||
}
|
||||
p.last = {
|
||||
page : p.page,
|
||||
@ -1020,14 +1020,14 @@
|
||||
$.data(table, 'pagerLastPage', p.page);
|
||||
if (p.initialized && pageMoved !== false) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering pageMoved');
|
||||
console.log('Pager: Triggering pageMoved');
|
||||
}
|
||||
c.$table
|
||||
.trigger('pageMoved', c)
|
||||
.trigger('applyWidgets');
|
||||
if (!p.ajax && table.isUpdating) {
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Triggering updateComplete');
|
||||
console.log('Pager: Triggering updateComplete');
|
||||
}
|
||||
c.$table.trigger('updateComplete', [ table, true ]);
|
||||
}
|
||||
@ -1106,7 +1106,7 @@
|
||||
tsp.setPageSize(table, p.size, c);
|
||||
tsp.hideRowsSetup(table, c);
|
||||
if (c.debug) {
|
||||
ts.log('Pager: Enabled');
|
||||
console.log('Pager: Enabled');
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -29,7 +29,7 @@
|
||||
if (saveSort && table.hasInitialized && ts.storage) {
|
||||
ts.storage( table, 'tablesorter-savesort', sortList );
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort widget: Saving last sort: ' + c.sortList, time);
|
||||
console.log('saveSort widget: Saving last sort: ' + c.sortList + ts.benchmark(time));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@ -41,7 +41,7 @@
|
||||
stored = ts.storage( table, 'tablesorter-savesort' );
|
||||
sortList = (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
|
||||
if (c.debug) {
|
||||
ts.benchmark('saveSort: Last sort loaded: "' + sortList + '"', time);
|
||||
console.log('saveSort: Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
|
||||
}
|
||||
$table.bind('saveSortReset', function(event) {
|
||||
event.stopPropagation();
|
||||
|
@ -50,7 +50,7 @@
|
||||
window[storageType].removeItem('_tmptest');
|
||||
} catch (error) {
|
||||
if (c && c.debug) {
|
||||
ts.log( storageType + ' is not supported in this browser' );
|
||||
console.warn( storageType + ' is not supported in this browser' );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@
|
||||
}
|
||||
}
|
||||
if (c.debug) {
|
||||
ts.benchmark('Applying ' + theme + ' theme', time);
|
||||
console.log('Applying ' + theme + ' theme' + ts.benchmark(time));
|
||||
}
|
||||
},
|
||||
remove: function(table, c, wo, refreshing) {
|
||||
|
Loading…
Reference in New Issue
Block a user