Core: Debug components separately

This commit is contained in:
Rob Garrison 2018-03-18 00:43:37 -05:00
parent 6f9edd76aa
commit 7b15ec99c5
11 changed files with 266 additions and 208 deletions

View File

@ -246,8 +246,8 @@
pagerArrows( table, p );
fixHeight(table, p);
if (p.initialized && completed !== false) {
if (c.debug) {
console.log('Pager: Triggering pagerComplete');
if (ts.debug(c, 'pager')) {
console.log('Pager >> Triggering pagerComplete');
}
c.$table.triggerHandler('pagerComplete', p);
// save pager info to storage
@ -429,8 +429,8 @@
ts.showError( table );
if ( exception ) {
if (c.debug) {
console.error('Pager: >> Ajax Error', xhr, settings, exception);
if (ts.debug(c, 'pager')) {
console.error('Pager >> Ajax Error', xhr, settings, exception);
}
ts.showError( table, xhr, settings, exception );
c.$tbodies.eq(0).children('tr').detach();
@ -527,8 +527,8 @@
// apply widgets after table has rendered & after a delay to prevent
// multiple applyWidget blocking code from blocking this trigger
setTimeout(function() {
if (c.debug) {
console.log('Pager: Triggering pagerChange');
if (ts.debug(c, 'pager')) {
console.log('Pager >> Triggering pagerChange');
}
$table.triggerHandler( 'pagerChange', p );
ts.applyWidget( table );
@ -573,8 +573,8 @@
p.oldAjaxSuccess(data);
}
};
if (c.debug) {
console.log('Pager: Ajax initialized', p.ajaxObject);
if (ts.debug(c, 'pager')) {
console.log('Pager >> Ajax initialized', p.ajaxObject);
}
$.ajax(p.ajaxObject);
}
@ -618,8 +618,8 @@
if ( typeof p.customAjaxUrl === 'function' ) {
url = p.customAjaxUrl(table, url);
}
if (c.debug) {
console.log('Pager: Ajax url = ' + url);
if (ts.debug(c, 'pager')) {
console.log('Pager >> Ajax url = ' + url);
}
return url;
},
@ -628,13 +628,14 @@
var $tb, index, count, added,
$t = $(table),
c = table.config,
debug = ts.debug(c, 'pager'),
f = c.$table.hasClass('hasFilters'),
l = rows && rows.length || 0, // rows may be undefined
e = p.size === 'all' ? p.totalRows : p.size,
s = ( p.page * e );
if ( l < 1 ) {
if (c.debug) {
console.warn('Pager: >> No rows for pager to render');
if (debug) {
console.warn('Pager >> No rows for pager to render');
}
// empty table, abort!
return;
@ -646,8 +647,8 @@
p.cacheIndex = [];
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
if (p.initialized) {
if (c.debug) {
console.log('Pager: Triggering pagerChange');
if (debug) {
console.log('Pager >> Triggering pagerChange');
}
$t.triggerHandler( 'pagerChange', p );
}
@ -676,8 +677,8 @@
}
updatePageDisplay(table, p);
if (table.isUpdating) {
if (c.debug) {
console.log('Pager: Triggering updateComplete');
if (debug) {
console.log('Pager >> Triggering updateComplete');
}
$t.triggerHandler('updateComplete', [ table, true ]);
}
@ -700,8 +701,8 @@
renderTable(table, table.config.rowsCopy, p);
p.isDisabled = true;
ts.applyWidget( table );
if (table.config.debug) {
console.log('Pager: Disabled');
if (ts.debug(table.config, 'pager')) {
console.log('Pager >> Disabled');
}
}
// disable size selector
@ -734,9 +735,10 @@
moveToPage = function(table, p, pageMoved) {
if ( p.isDisabled ) { return; }
var tmp,
c = table.config,
$t = $(table),
l = p.last;
c = table.config,
debug = ts.debug(c, 'pager'),
$t = $(table),
l = p.last;
if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) {
return updateCache(table);
}
@ -756,8 +758,8 @@
// & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
(l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
l.sortList === (c.sortList || []).join(',') ) { return; }
if (c.debug) {
console.log('Pager: Changing to page ' + p.page);
if (debug) {
console.log('Pager >> Changing to page ' + p.page);
}
p.last = {
page : p.page,
@ -774,9 +776,9 @@
p.processAjaxOnInit = true;
tmp = p.initialRows;
p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
( c.debug ? console.error('Pager: no initial total page set!') || 0 : 0 );
( debug ? console.error('Pager >> No initial total page set!') || 0 : 0 );
p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered :
( c.debug ? console.error('Pager: no initial filtered page set!') || 0 : 0 );
( debug ? console.error('Pager >> No initial filtered page set!') || 0 : 0 );
pagerInitialized( table, p );
} else {
getAjax(table, p);
@ -786,14 +788,14 @@
}
$.data(table, 'pagerLastPage', p.page);
if (p.initialized && pageMoved !== false) {
if (c.debug) {
console.log('Pager: Triggering pageMoved');
if (debug) {
console.log('Pager >> Triggering pageMoved');
}
$t.triggerHandler('pageMoved', p);
ts.applyWidget( table );
if (table.isUpdating) {
if (c.debug) {
console.log('Pager: Triggering updateComplete');
if (debug) {
console.log('Pager >> Triggering updateComplete');
}
$t.triggerHandler('updateComplete', [ table, true ]);
}
@ -866,8 +868,8 @@
pagerInitialized = function(table, p) {
p.initialized = true;
p.initializing = false;
if (table.config.debug) {
console.log('Pager: Triggering pagerInitialized');
if (ts.debug(table.config, 'pager')) {
console.log('Pager >> Triggering pagerInitialized');
}
$(table).triggerHandler( 'pagerInitialized', p );
ts.applyWidget( table );
@ -934,8 +936,8 @@
setPageSize(table, p.size, p);
moveToPage(table, p);
hideRowsSetup(table, p);
if (c.debug) {
console.log('Pager: Enabled');
if (ts.debug(c, 'pager')) {
console.log('Pager >> Enabled');
}
}
},
@ -944,6 +946,7 @@
var t, ctrls, fxn, $el,
c = table.config,
wo = c.widgetOptions,
debug = ts.debug(c, 'pager'),
p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ),
$t = c.$table,
namespace = c.namespace + 'pager',
@ -951,8 +954,8 @@
pager = p.$container = $(p.container).addClass('tablesorter-pager').show();
// save a copy of the original settings
p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
if (c.debug) {
console.log('Pager: Initializing');
if (debug) {
console.log('Pager >> Initializing');
}
p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
c.appender = $this.appender;
@ -1066,8 +1069,8 @@
// clicked controls
ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
if (c.debug && !pager.length) {
console.warn('Pager: >> Container not found');
if (debug && !pager.length) {
console.warn('Pager >> "container" not found');
}
pager.find(ctrls.join(','))
.attr('tabindex', 0)
@ -1095,8 +1098,8 @@
moveToPage(table, p, true);
updatePageDisplay(table, p, false);
});
} else if (c.debug) {
console.warn('Pager: >> Goto selector not found');
} else if (debug) {
console.warn('Pager >> "goto" selector not found');
}
// page size selector
$el = pager.find(p.cssPageSize);
@ -1113,8 +1116,8 @@
}
return false;
});
} else if (c.debug) {
console.warn('Pager: >> Size selector not found');
} else if (debug) {
console.warn('Pager >> "size" selector not found');
}
// clear initialized flag
@ -1145,8 +1148,8 @@
// update page size on init
setPageSize(table, p.size, p);
moveToPage(table, p);
if (c.debug) {
console.log('Pager: Triggering pagerInitialized');
if (debug) {
console.log('Pager >> Triggering pagerInitialized');
}
c.$table.triggerHandler( 'pagerInitialized', p );
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {

View File

@ -16,14 +16,18 @@
<!-- Tablesorter: required -->
<link rel="stylesheet" href="../css/theme.blue.css">
<script src="../js/jquery.tablesorter.js"></script>
<script src="../js/widgets/widget-filter.js"></script>
<script id="js">$(function() {
// call the tablesorter plugin
$("table").tablesorter({
theme : 'blue',
// enable debug mode
debug: true
// enable debug mode;
// debug: true => all debugging
// debug: "filter" => filter widget debugging only
debug: "core filter", // => core and filter widget debugging
widgets: ["filter"]
});
});</script>
@ -39,7 +43,7 @@
<div id="main">
<p class="tip">
<em>NOTE!</em> If firebug is installed the debuging information will be displayed in the firebug console.
<em>NOTE!</em> Debugging information will be displayed in the development console (Press <kbd>F12</kbd> and select the console tab).
</p>
<h1>Demo</h1>

View File

@ -928,11 +928,24 @@
</tr>
<tr id="debug">
<td><span class="permalink">debug</span></td>
<td>Boolean</td>
<td><a href="#" class="permalink">debug</a></td>
<td>Boolean or String</td>
<td>false</td>
<td>
Boolean flag indicating if tablesorter should display debuging information useful for development.
Set this option to provide useful for development debugging information in the console <span class="version updated">v2.30.0</span>.
<div class="collapsible">
In <span class="version updated">v2.30.0</span>, set this option as a string containing either "core" and/or a specific widget name; or, a boolean value.
<p>When a boolean flag is set, <em>all</em> debugging information is shown in the console.</p>
To display debugging information specific to a widget, or widgets include the widget name:
<pre class="prettyprint lang-js">$(function() {
$("table").tablesorter({
// Show debugging info only for the filter and columnSelector widgets
// include "core" to only show the core debugging info
debug : "filter columnSelector"
});
});</pre>
The option only tests if the string contains the widget name, so <code>"corefilter"</code> would show debugging for both the core and filter widget.
</div>
</td>
<td><a href="example-option-debug.html">Example</a></td>
</tr>

View File

@ -216,7 +216,7 @@
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 ) {
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
if ( table.hasInitialized ) {
console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
} else {
@ -237,7 +237,7 @@
table.config = c;
// save the settings where they read
$.data( table, 'tablesorter', c );
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter v' + ts.version );
$.data( table, 'startoveralltimer', new Date() );
}
@ -343,9 +343,9 @@
// initialized
table.hasInitialized = true;
table.isProcessing = false;
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) );
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
if ( ts.debug(c, 'core') && console.groupEnd ) { console.groupEnd(); }
}
$table.triggerHandler( 'tablesorter-initialized', table );
if ( typeof c.initialized === 'function' ) {
@ -542,7 +542,7 @@
c.headerList = [];
c.headerContent = [];
c.sortVars = [];
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
timer = new Date();
}
// children tr in tfoot - see issue #196 & #547
@ -637,7 +637,7 @@
});
// enable/disable sorting
ts.updateHeader( c );
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.log( 'Built headers:' + ts.benchmark( timer ) );
console.log( c.$headers );
}
@ -660,14 +660,15 @@
noParser, parser, extractor, time, tbody, len,
table = c.table,
tbodyIndex = 0,
debug = {};
debug = ts.debug(c, 'core'),
debugOutput = {};
// update table bodies in case we start with an empty table
c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
len = tbody.length;
if ( len === 0 ) {
return c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : '';
} else if ( c.debug ) {
return debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : '';
} else if ( debug ) {
time = new Date();
console[ console.group ? 'group' : 'log' ]( 'Detecting parsers for each column' );
}
@ -709,8 +710,8 @@
if ( !parser ) {
parser = ts.detectParserForColumn( c, rows, -1, colIndex );
}
if ( c.debug ) {
debug[ '(' + colIndex + ') ' + header.text() ] = {
if ( debug ) {
debugOutput[ '(' + colIndex + ') ' + header.text() ] = {
parser : parser.id,
extractor : extractor ? extractor.id : 'none',
string : c.strings[ colIndex ],
@ -736,9 +737,9 @@
}
tbodyIndex += ( list.parsers.length ) ? len : 1;
}
if ( c.debug ) {
if ( !ts.isEmptyObject( debug ) ) {
console[ console.table ? 'table' : 'log' ]( debug );
if ( debug ) {
if ( !ts.isEmptyObject( debugOutput ) ) {
console[ console.table ? 'table' : 'log' ]( debugOutput );
} else {
console.warn( ' No parsers detected!' );
}
@ -781,6 +782,7 @@
indx = ts.parsers.length,
node = false,
nodeValue = '',
debug = ts.debug(c, 'core'),
keepLooking = true;
while ( nodeValue === '' && keepLooking ) {
rowIndex++;
@ -791,7 +793,7 @@
node = rows[ rowIndex ].cells[ cellIndex ];
nodeValue = ts.getElementText( c, node, cellIndex );
$node = $( node );
if ( c.debug ) {
if ( debug ) {
console.log( 'Checking if value was empty on row ' + rowIndex + ', column: ' +
cellIndex + ': "' + nodeValue + '"' );
}
@ -873,7 +875,8 @@
cols, $cells, cell, cacheTime, totalRows, rowData, prevRowData,
colMax, span, cacheIndex, hasParser, max, len, index,
table = c.table,
parsers = c.parsers;
parsers = c.parsers,
debug = ts.debug(c, 'core');
// update tbody variable
c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
$tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies,
@ -881,9 +884,9 @@
c.totalRows = 0;
// if no parsers found, return - it's an empty table.
if ( !parsers ) {
return c.debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : '';
return debug ? console.warn( 'Warning: *Empty table!* Not building a cache' ) : '';
}
if ( c.debug ) {
if ( debug ) {
cacheTime = new Date();
}
// processing icon
@ -952,7 +955,7 @@
cell = $row[ 0 ].cells[ colIndex ];
if ( cell && cacheIndex < c.columns ) {
hasParser = typeof parsers[ cacheIndex ] !== 'undefined';
if ( !hasParser && c.debug ) {
if ( !hasParser && debug ) {
console.warn( 'No parser found for row: ' + rowIndex + ', column: ' + colIndex +
'; cell containing: "' + $(cell).text() + '"; does it have a header?' );
}
@ -1000,7 +1003,7 @@
if ( c.showProcessing ) {
ts.isProcessing( table ); // remove processing icon
}
if ( c.debug ) {
if ( debug ) {
len = Math.min( 5, c.cache[ 0 ].normalized.length );
console[ console.group ? 'group' : 'log' ]( 'Building cache for ' + c.totalRows +
' rows (showing ' + len + ' rows in log) and ' + c.columns + ' columns' +
@ -1031,7 +1034,7 @@
data = { raw : [], parsed: [], $cell: [] },
c = table.config;
if ( ts.isEmptyObject( c ) ) {
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.warn( 'No cache found - aborting getColumnText function!' );
}
} else {
@ -1375,7 +1378,7 @@
ts.resortComplete( c, callback );
}
} else {
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.error( 'updateCell aborted, tbody missing or not within the indicated table' );
}
c.table.isUpdating = false;
@ -1398,7 +1401,7 @@
// row contained in the table?
( ts.getClosest( $row, 'table' )[ 0 ] !== c.table )
) {
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.error( 'addRows method requires (1) a jQuery selector reference to rows that have already ' +
'been added to the table, or (2) row HTML string to be added to a table with only one tbody' );
}
@ -1480,7 +1483,7 @@
return c.appender ? c.appender( table, rows ) :
table.isUpdating ? c.$table.triggerHandler( 'updateComplete', table ) : ''; // Fixes #532
}
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
appendTime = new Date();
}
for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
@ -1504,7 +1507,7 @@
if ( c.appender ) {
c.appender( table, rows );
}
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.log( 'Rebuilt table' + ts.benchmark( appendTime ) );
}
// apply table widgets; but not before ajax completes
@ -1686,7 +1689,7 @@
// empty table - fixes #206/#346
return;
}
if ( c.debug ) { sortTime = new Date(); }
if ( ts.debug(c, 'core') ) { sortTime = new Date(); }
// cache textSorter to optimize speed
if ( typeof textSorter === 'object' ) {
colMax = c.columns;
@ -1748,7 +1751,7 @@
return a[ c.columns ].order - b[ c.columns ].order;
});
}
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.log( 'Applying sort ' + sortList.toString() + ts.benchmark( sortTime ) );
}
},
@ -2001,6 +2004,7 @@
var applied, time, name,
c = table.config,
wo = c.widgetOptions,
debug = ts.debug(c, 'core'),
widget = ts.getWidgetById( id );
if ( widget ) {
name = widget.id;
@ -2009,7 +2013,7 @@
if ( $.inArray( name, c.widgets ) < 0 ) {
c.widgets[ c.widgets.length ] = name;
}
if ( c.debug ) { time = new Date(); }
if ( debug ) { time = new Date(); }
if ( init || !( c.widgetInit[ name ] ) ) {
// set init flag first to prevent calling init more than once (e.g. pager)
@ -2020,7 +2024,7 @@
}
if ( typeof widget.init === 'function' ) {
applied = true;
if ( c.debug ) {
if ( debug ) {
console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
}
widget.init( table, widget, c, wo );
@ -2028,12 +2032,12 @@
}
if ( !init && typeof widget.format === 'function' ) {
applied = true;
if ( c.debug ) {
if ( debug ) {
console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
}
widget.format( table, c, wo, false );
}
if ( c.debug ) {
if ( debug ) {
if ( applied ) {
console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time ) );
if ( console.groupEnd ) { console.groupEnd(); }
@ -2046,12 +2050,13 @@
table = $( table )[ 0 ]; // in case this is called externally
var indx, len, names, widget, time,
c = table.config,
debug = ts.debug(c, 'core'),
widgets = [];
// prevent numerous consecutive widget applications
if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) {
return;
}
if ( c.debug ) { time = new Date(); }
if ( debug ) { time = new Date(); }
ts.addWidgetFromClass( table );
// prevent "tablesorter-ready" from firing multiple times in a row
clearTimeout( c.timerReady );
@ -2070,7 +2075,7 @@
// set priority to 10 if not defined
if ( !widget.priority ) { widget.priority = 10; }
widgets[ indx ] = widget;
} else if ( c.debug ) {
} else if ( debug ) {
console.warn( '"' + names[ indx ] + '" was enabled, but the widget code has not been loaded!' );
}
}
@ -2080,7 +2085,7 @@
});
// add/update selected widgets
len = widgets.length;
if ( c.debug ) {
if ( debug ) {
console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
}
for ( indx = 0; indx < len; indx++ ) {
@ -2089,7 +2094,7 @@
ts.applyWidgetId( table, widget.id, init );
}
}
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
if ( debug && console.groupEnd ) { console.groupEnd(); }
}
c.timerReady = setTimeout( function() {
table.isApplyingWidgets = false;
@ -2099,7 +2104,7 @@
if ( !init && typeof callback === 'function' ) {
callback( table );
}
if ( c.debug ) {
if ( debug ) {
widget = c.widgets.length;
console.log( 'Completed ' +
( init === true ? 'initializing ' : 'applying ' ) + widget +
@ -2136,7 +2141,7 @@
c.widgets.splice( indx, 1 );
}
if ( widget && widget.remove ) {
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' );
}
widget.remove( table, c, c.widgetOptions, refreshing );
@ -2190,6 +2195,12 @@
log : function() {
console.log( arguments );
},
debug : function(c, name) {
return c && (
c.debug === true ||
typeof c.debug === 'string' && c.debug.indexOf(name) > -1
);
},
// $.isEmptyObject from jQuery v1.4
isEmptyObject : function( obj ) {
@ -2495,7 +2506,7 @@
ignore = 'headers sortForce sortList sortAppend widgets'.split( ' ' ),
orig = c.originalSettings;
if ( orig ) {
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
timer = new Date();
}
for ( setting in orig ) {
@ -2511,7 +2522,7 @@
}
}
}
if ( c.debug ) {
if ( ts.debug(c, 'core') ) {
console.log( 'validate options time:' + ts.benchmark( timer ) );
}
}
@ -2542,7 +2553,6 @@
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' );
@ -2580,7 +2590,7 @@
if ( typeof callback === 'function' ) {
callback( table );
}
if ( debug ) {
if ( ts.debug(c, 'core') ) {
console.log( 'tablesorter has been removed' );
}
}

View File

@ -4,14 +4,14 @@
*/
/*jshint browser:true, jquery:true, unused:false */
/*global jQuery: false */
;(function($){
;(function($) {
'use strict';
var ts = $.tablesorter = $.tablesorter || {},
// build a table from data (requires existing <table> tag)
// data.header contains an array of header titles
// data.rows contains an array of rows which contains an array of cells
bt = ts.buildTable = function(tar, c){
bt = ts.buildTable = function(tar, c) {
// add build options to defaults to prevent warnings
$.extend(true, ts.defaults.widgetOptions, bt.defaults);
// add table if one doesn't exist
@ -21,9 +21,10 @@
p = wo.build_processing,
typ = wo.build_type,
d = wo.build_source || c.data,
debug = ts.debug(c, 'build'),
// determine type: html, json, array, csv, object
runType = function(d){
runType = function(d) {
var t = $.type(d),
jq = d instanceof jQuery;
// run any processing if set
@ -59,7 +60,9 @@
// even if wo.build_type is undefined, we can try to figure out the type
if ( !ts.buildTable.hasOwnProperty(typ) && typ !== '' ) {
if (c.debug) { console.error('aborting build table widget, incorrect build type'); }
if (debug) {
console.error('Build >> ERROR: Aborting build table widget, incorrect build type');
}
return false;
}
@ -72,8 +75,10 @@
.done(function(data) {
runType(data);
})
.fail(function( jqXHR, textStatus, errorThrown) {
if (c.debug) { console.error('aborting build table widget, failed ajax load'); }
.fail(function( jqXHR, textStatus) {
if (debug) {
console.error('Build >> ERROR: Aborting build table widget, failed ajax load');
}
$tbl.html('<tr><td class="error">' + jqXHR.status + ' ' + textStatus + '</td></tr>');
});
} else {
@ -125,7 +130,7 @@
// add colgroup if widths set
if (widths && widths.length) {
t += '<colgroup>';
$.each(widths, function(i, w){
$.each(widths, function(i, w) {
t += '<col' + ( w ? ' style="width:' + w + '"' : '' ) + '>';
});
t += '</colgroup>';
@ -133,7 +138,7 @@
return t;
},
// d = cell data; typ = 'th' or 'td'; first = save widths from first header row only
cell : function(d, wo, typ, col, first){
cell : function(d, wo, typ, col, first) {
var j, $td,
$col = first ? $('<col>') : '',
cls = wo.build_headers.classes,
@ -150,7 +155,7 @@
// assume we have an object
$td = $('<' + typ + '>');
for (j in d) {
if (d.hasOwnProperty(j)){
if (d.hasOwnProperty(j)) {
if (j === 'text' || j === 'html') {
$td[j]( d[j] );
} else if (first && j === 'width') {
@ -165,7 +170,7 @@
return [ $td, $col ];
},
// h1 = header text from data
header : function(h1, wo){
header : function(h1, wo) {
var h2 = wo.build_headers.text,
cls = wo.build_headers.classes,
t = '<tr>' + (wo.build_numbers.addColumn ? '<th' + (wo.build_numbers.sortable ? '' :
@ -180,7 +185,7 @@
});
return t + '</tr>';
},
rows : function(items, txt, c, wo, num, ftr){
rows : function(items, txt, c, wo, num, ftr) {
var h = (ftr ? 'th' : 'td'),
t = '<tr>' + (wo.build_numbers.addColumn ? '<' + h + '>' + (ftr ? '' : num) + '</' + h + '>' : '');
$.each(items, function(i, item) {
@ -196,8 +201,11 @@
}
};
bt.buildComplete = function(table, wo){
bt.buildComplete = function(table, wo) {
$(table).triggerHandler(wo.build_complete);
if (table.config && ts.debug(table.config, 'build')) {
console.log('Build >> Table build complete');
}
ts.setup(table, table.config);
};
@ -361,7 +369,9 @@
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) { console.error('aborting build table widget, missing data for object build'); }
if (ts.debug(c, 'build')) {
console.error('Build >> ERROR: Aborting build table widget, missing data for object build');
}
return false;
}
@ -371,7 +381,7 @@
// Build thead
// h = [ ['headerRow1Cell1', 'headerRow1Cell2', ... 'headerRow1CellN' ], ['headerRow2Cell1', ... ] ]
// or h = [ [ { text: 'firstCell', class: 'fc', width: '20%' }, ..., { text: 'last Cell' } ], [ /* second row */ ] ]
$.each(h, function(i, d){
$.each(h, function(i, d) {
$tr = $('<tr>').appendTo( $t.find('thead') );
l = d.length; // header row
for ( j = 0; j < l; j++ ) {
@ -388,14 +398,14 @@
$tb = $('<tbody>');
// Build tbody
$.each(r, function(i, d){
$.each(r, function(i, d) {
var j;
t = $.type(d) === 'object';
// add new tbody
if (t && d.newTbody) {
$tb = $('<tbody>').appendTo( $t );
for (j in d) {
if (d.hasOwnProperty(j) && j !== 'newTbody'){
if (d.hasOwnProperty(j) && j !== 'newTbody') {
$tb.attr(j, d[j]);
}
}
@ -409,7 +419,7 @@
if (t) {
// row defined by object
for (j in d) {
if (d.hasOwnProperty(j) && j !== wo.build_objectCellKey){
if (d.hasOwnProperty(j) && j !== wo.build_objectCellKey) {
$tr.attr(j, d[j]);
}
}

View File

@ -1,10 +1,10 @@
/* Widget: columnSelector (responsive table widget) - updated 9/27/2017 (v2.29.0) *//*
/* Widget: columnSelector (responsive table widget) - updated 2018-03-17 (v2.30.0) *//*
* Requires tablesorter v2.8+ and jQuery 1.7+
* by Justin Hallett & Rob Garrison
*/
/*jshint browser:true, jquery:true, unused:false */
/*global jQuery: false */
;(function($){
;(function($) {
'use strict';
var ts = $.tablesorter,
@ -15,13 +15,14 @@
queryBreak : '@media all and (min-width: [size]) { [columns] { display: table-cell; } } ',
init: function(table, c, wo) {
var $t, colSel;
var $t, colSel,
debug = ts.debug(c, 'columnSelector');
// abort if no input is contained within the layout
$t = $(wo.columnSelector_layout);
if (!$t.find('input').add( $t.filter('input') ).length) {
if (c.debug) {
console.error('ColumnSelector: >> ERROR: Column Selector aborting, no input found in the layout! ***');
if (debug) {
console.error('ColumnSelector >> ERROR: Column Selector aborting, no input found in the layout! ***');
}
return;
}
@ -45,8 +46,8 @@
colSel.isInitializing = false;
if (colSel.$container.length) {
tsColSel.updateCols(c, wo);
} else if (c.debug) {
console.warn('ColumnSelector: >> container not found');
} else if (debug) {
console.warn('ColumnSelector >> container not found');
}
c.$table
@ -59,11 +60,14 @@
[ 'auto', [2,3,4] ] = set visible columns; turn on "auto" mode.
true = turn on "auto" mode.
*/
.on('refreshColumnSelector' + namespace, function( e, optName, optState ){
.on('refreshColumnSelector' + namespace, function( e, optName, optState ) {
// make sure we're using current config settings
tsColSel.refreshColumns( this.config, optName, optState );
});
if (debug) {
console.log('ColumnSelector >> Widget initialized');
}
},
refreshColumns: function( c, optName, optState ) {
@ -87,7 +91,7 @@
if (isArry) {
arry = optState || optName;
// make sure array contains numbers
$.each(arry, function(i, v){
$.each(arry, function(i, v) {
arry[i] = parseInt(v, 10);
});
for (i = 0; i < c.columns; i++) {
@ -229,7 +233,7 @@
.attr('data-column', 'auto')
.prop('checked', colSel.auto)
.toggleClass( wo.columnSelector_cssChecked, colSel.auto )
.on('change', function(){
.on('change', function() {
tsColSel.updateAuto(c, wo, $(this));
}).change();
}
@ -243,7 +247,7 @@
updateAuto: function(c, wo, $el) {
var colSel = c.selector;
colSel.auto = $el.prop('checked') || false;
$.each( colSel.$checkbox, function(i, $cb){
$.each( colSel.$checkbox, function(i, $cb) {
if ($cb) {
$cb[0].disabled = colSel.auto;
colSel.$wrapper[i].toggleClass('disabled', colSel.auto);
@ -257,7 +261,7 @@
if (c.selector.$popup) {
c.selector.$popup.find('.tablesorter-column-selector')
.html( colSel.$container.html() )
.find('input').each(function(){
.find('input').each(function() {
var indx = $(this).attr('data-column');
$(this).prop( 'checked', indx === 'auto' ? colSel.auto : colSel.states[indx] );
});
@ -306,10 +310,10 @@
}
}
// only 6 breakpoints (same as jQuery Mobile)
for (priority = 0; priority < wo.columnSelector_maxPriorities; priority++){
for (priority = 0; priority < wo.columnSelector_maxPriorities; priority++) {
/*jshint loopfunc:true */
breaks = [];
c.$headers.filter('[' + wo.columnSelector_priority + '=' + (priority + 1) + ']').each(function(){
c.$headers.filter('[' + wo.columnSelector_priority + '=' + (priority + 1) + ']').each(function() {
column = parseInt($(this).attr('data-column'), 10) + 1;
// don't reveal columnSelector false columns
if ( !isHidden[ column ] ) {
@ -340,14 +344,14 @@
colSel = c.selector,
styles = [],
prefix = c.namespace + 'columnselector';
colSel.$container.find('input[data-column]').filter('[data-column!="auto"]').each(function(){
colSel.$container.find('input[data-column]').filter('[data-column!="auto"]').each(function() {
if (!this.checked) {
column = parseInt( $(this).attr('data-column'), 10 ) + 1;
styles = styles.concat( tsColSel.addSelectors( wo, prefix, column ) );
}
$(this).toggleClass( wo.columnSelector_cssChecked, this.checked );
});
if (wo.columnSelector_mediaquery){
if (wo.columnSelector_mediaquery) {
colSel.$breakpoints.prop('disabled', true);
}
if (colSel.$style) {
@ -451,7 +455,7 @@
wo = c.widgetOptions;
$popup.find('.tablesorter-column-selector')
.html( colSel.$container.html() )
.find('input').each(function(){
.find('input').each(function() {
var indx = $(this).attr('data-column'),
isChecked = indx === 'auto' ? colSel.auto : colSel.states[indx];
$(this)
@ -503,7 +507,7 @@
// container layout
columnSelector_layout : '<label><input type="checkbox">{name}</label>',
// layout customizer callback called for each column
// function($cell, name, column){ return name || $cell.html(); }
// function($cell, name, column) { return name || $cell.html(); }
columnSelector_layoutCustomizer : null,
// data attribute containing column name to use in the selector container
columnSelector_name : 'data-selector-name',

View File

@ -627,6 +627,9 @@
c.lastSearch = c.$table.data( 'lastSearch' );
c.$table.triggerHandler( 'filterInit', c );
tsf.findRows( c.table, c.lastSearch || [] );
if (ts.debug(c, 'filter')) {
console.log('Filter >> Widget initialized');
}
};
if ( $.isEmptyObject( wo.filter_formatter ) ) {
completed();
@ -1327,6 +1330,7 @@
storedFilters = $.extend( [], filters ),
c = table.config,
wo = c.widgetOptions,
debug = ts.debug(c, 'filter'),
// data object passed to filters; anyMatch is a flag for the filters
data = {
anyMatch: false,
@ -1343,7 +1347,6 @@
defaultColFilter : [],
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
};
// parse columns after formatter, in case the class is added at that point
data.parsed = [];
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
@ -1365,8 +1368,8 @@
( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split( /\s+/ );
}
if ( c.debug ) {
console.log( 'Filter: Starting filter widget search', filters );
if ( debug ) {
console.log( 'Filter >> Starting filter widget search', filters );
time = new Date();
}
// filtered rows count
@ -1464,8 +1467,8 @@
notFiltered = $rows.not( '.' + wo.filter_filteredRow ).length;
// can't search when all rows are hidden - this happens when looking for exact matches
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
if ( c.debug ) {
console.log( 'Filter: Searching through ' +
if ( debug ) {
console.log( 'Filter >> Searching through ' +
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
}
if ( data.anyMatchFlag ) {
@ -1568,8 +1571,8 @@
if ( wo.filter_saveFilters && ts.storage ) {
ts.storage( table, 'tablesorter-filters', tsf.processFilters( storedFilters, true ) );
}
if ( c.debug ) {
console.log( 'Completed filter widget search' + ts.benchmark(time) );
if ( debug ) {
console.log( 'Filter >> Completed search' + ts.benchmark(time) );
}
if ( wo.filter_initialized ) {
c.$table.triggerHandler( 'filterBeforeEnd', c );

View File

@ -1,9 +1,9 @@
/*! Widget: Pager - updated 5/24/2017 (v2.28.11) */
/*! Widget: Pager - updated 2018-03-17 (v2.30.0) */
/* Requires tablesorter v2.8+ and jQuery 1.7+
* by Rob Garrison
*/
/*jshint browser:true, jquery:true, unused:false */
;(function($){
;(function($) {
'use strict';
var tsp,
ts = $.tablesorter;
@ -66,7 +66,7 @@
pager_customAjaxUrl: function( table, url ) { return url; },
// ajax error callback from $.tablesorter.showError function
// pager_ajaxError: function( config, xhr, settings, exception ){ return exception; };
// pager_ajaxError: function( config, xhr, settings, exception ) { return exception; };
// returning false will abort the error message
pager_ajaxError: null,
@ -91,7 +91,7 @@
// ],
// [ "header1", "header2", ... "headerN" ] // optional
// ]
pager_ajaxProcessing: function( ajax ){ return [ 0, [], null ]; },
pager_ajaxProcessing: function( /* ajax */ ) { return [ 0, [], null ]; },
// css class names of pager arrows
pager_css: {
@ -162,8 +162,8 @@
if ( p.isInitializing ) { return; }
p.isInitializing = true;
if ( c.debug ) {
console.log( 'Pager: Initializing' );
if ( ts.debug(c, 'pager') ) {
console.log( 'Pager >> Initializing' );
}
p.size = $.data( table, 'pagerLastSize' ) || wo.pager_size;
@ -227,8 +227,8 @@
p.initializing = false;
p.isInitializing = false;
tsp.setPageSize( c, p.size ); // page size 0 is ignored
if ( c.debug ) {
console.log( 'Pager: Triggering pagerInitialized' );
if ( ts.debug(c, 'pager') ) {
console.log( 'Pager >> Triggering pagerInitialized' );
}
c.$table.triggerHandler( 'pagerInitialized', c );
// filter widget not initialized; it will update the output display & fire off the pagerComplete event
@ -243,7 +243,8 @@
p = c.pager,
wo = c.widgetOptions,
namespace = c.namespace + 'pager',
s = wo.pager_selectors;
s = wo.pager_selectors,
debug = ts.debug(c, 'pager');
c.$table
.off( namespace )
.on( 'filterInit filterStart '.split( ' ' ).join( namespace + ' ' ), function( e, filters ) {
@ -284,7 +285,7 @@
e.stopPropagation();
tsp.enablePager( c, true );
})
.on( 'destroyPager' + namespace, function( e, refreshing ) {
.on( 'destroyPager' + namespace, function( e ) {
e.stopPropagation();
// call removeWidget to make sure internal flags are modified.
ts.removeWidget( c.table, 'pager', false );
@ -343,8 +344,8 @@
// clicked controls
ctrls = [ s.first, s.prev, s.next, s.last ];
fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
if ( c.debug && !p.$container.length ) {
console.warn( 'Pager: >> Container not found' );
if ( debug && !p.$container.length ) {
console.warn( 'Pager >> "container" not found' );
}
p.$container.find( ctrls.join( ',' ) )
.attr( 'tabindex', 0 )
@ -373,8 +374,8 @@
tsp.moveToPage( c, p, true );
tsp.updatePageDisplay( c, false );
});
} else if ( c.debug ) {
console.warn( 'Pager: >> Goto selector not found' );
} else if ( debug ) {
console.warn( 'Pager >> "goto" selector not found' );
}
tmp = p.$container.find( wo.pager_selectors.pageSize );
@ -394,8 +395,8 @@
}
return false;
});
} else if ( c.debug ) {
console.warn('Pager: >> Size selector not found');
} else if ( debug ) {
console.warn('Pager >> "size" selector not found');
}
},
@ -532,8 +533,8 @@
tsp.pagerArrows( c );
tsp.fixHeight( c );
if ( p.initialized && completed !== false ) {
if ( c.debug ) {
console.log( 'Pager: Triggering pagerComplete' );
if ( ts.debug(c, 'pager') ) {
console.log( 'Pager >> Triggering pagerComplete' );
}
c.$table.triggerHandler( 'pagerComplete', c );
// save pager info to storage
@ -655,7 +656,6 @@
hideRows: function( c ) {
if ( !c.widgetOptions.pager_ajaxUrl ) {
var tbodyIndex, rowIndex, $rows, len, lastIndex,
table = c.table,
p = c.pager,
wo = c.widgetOptions,
tbodyLen = c.$tbodies.length,
@ -721,7 +721,8 @@
renderAjax: function( data, c, xhr, settings, exception ) {
var table = c.table,
p = c.pager,
wo = c.widgetOptions;
wo = c.widgetOptions,
debug = ts.debug(c, 'pager');
// process data
if ( $.isFunction( wo.pager_ajaxProcessing ) ) {
@ -734,15 +735,14 @@
var i, j, t, hsh, $f, $sh, $headers, $h, icon, th, d, l, rr_count, len, sz,
$table = c.$table,
tds = '',
result = wo.pager_ajaxProcessing( data, table, xhr ) || [ 0, [] ],
hl = $table.find( 'thead th' ).length;
result = wo.pager_ajaxProcessing( data, table, xhr ) || [ 0, [] ];
// Clean up any previous error.
ts.showError( table );
if ( exception ) {
if ( c.debug ) {
console.error( 'Pager: >> Ajax Error', xhr, settings, exception );
if ( debug ) {
console.error( 'Pager >> Ajax Error', xhr, settings, exception );
}
ts.showError( table, xhr, settings, exception );
c.$tbodies.eq( 0 ).children( 'tr' ).detach();
@ -846,8 +846,8 @@
// apply widgets after table has rendered & after a delay to prevent
// multiple applyWidget blocking code from blocking this trigger
setTimeout( function() {
if ( c.debug ) {
console.log( 'Pager: Triggering pagerChange' );
if ( debug ) {
console.log( 'Pager >> Triggering pagerChange' );
}
$table.triggerHandler( 'pagerChange', p );
ts.applyWidget( table );
@ -889,8 +889,8 @@
p.oldAjaxSuccess( data );
}
};
if ( c.debug ) {
console.log( 'Pager: Ajax initialized', p.ajaxObject );
if ( ts.debug(c, 'pager') ) {
console.log( 'Pager >> Ajax initialized', p.ajaxObject );
}
$.ajax( p.ajaxObject );
}
@ -935,8 +935,8 @@
if ( $.isFunction( wo.pager_customAjaxUrl ) ) {
url = wo.pager_customAjaxUrl( c.table, url );
}
if ( c.debug ) {
console.log( 'Pager: Ajax url = ' + url );
if ( ts.debug(c, 'pager') ) {
console.log( 'Pager >> Ajax url = ' + url );
}
return url;
},
@ -946,13 +946,14 @@
table = c.table,
p = c.pager,
wo = c.widgetOptions,
debug = ts.debug(c, 'pager'),
f = c.$table.hasClass('hasFilters'),
l = rows && rows.length || 0, // rows may be undefined
e = p.size === 'all' ? p.totalRows : p.size,
s = ( p.page * e );
if ( l < 1 ) {
if ( c.debug ) {
console.warn( 'Pager: >> No rows for pager to render' );
if ( debug ) {
console.warn( 'Pager >> No rows for pager to render' );
}
// empty table, abort!
return;
@ -964,8 +965,8 @@
p.cacheIndex = [];
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
if ( p.initialized ) {
if ( c.debug ) {
console.log( 'Pager: Triggering pagerChange' );
if ( debug ) {
console.log( 'Pager >> Triggering pagerChange' );
}
c.$table.triggerHandler( 'pagerChange', c );
}
@ -997,8 +998,8 @@
wo.pager_startPage = p.page;
wo.pager_size = p.size;
if ( table.isUpdating ) {
if ( c.debug ) {
console.log( 'Pager: Triggering updateComplete' );
if ( debug ) {
console.log( 'Pager >> Triggering updateComplete' );
}
c.$table.triggerHandler( 'updateComplete', [ table, true ] );
}
@ -1026,8 +1027,8 @@
tsp.renderTable( c, c.rowsCopy );
p.isDisabled = true;
ts.applyWidget( table );
if ( c.debug ) {
console.log( 'Pager: Disabled' );
if ( ts.debug(c, 'pager') ) {
console.log( 'Pager >> Disabled' );
}
}
// disable size selector
@ -1074,14 +1075,14 @@
var tmp,
table = c.table,
wo = c.widgetOptions,
l = p.last;
l = p.last,
debug = ts.debug(c, 'pager');
// abort page move if the table has filters and has not been initialized
if ( p.ajax && !wo.filter_initialized && ts.hasWidget( table, 'filter' ) ) { return; }
tsp.parsePageNumber( c, p );
tsp.calcFilters( c );
// fixes issue where one current filter is [] and the other is [ '', '', '' ],
// making the next if comparison think the filters as different. Fixes #202.
l.currentFilters = ( l.currentFilters || [] ).join( '' ) === '' ? [] : l.currentFilters;
@ -1096,8 +1097,8 @@
l.sortList === ( c.sortList || [] ).join( ',' ) ) {
return;
}
if ( c.debug ) {
console.log( 'Pager: Changing to page ' + p.page );
if ( debug ) {
console.log( 'Pager >> Changing to page ' + p.page );
}
p.last = {
page: p.page,
@ -1114,9 +1115,9 @@
wo.pager_processAjaxOnInit = true;
tmp = wo.pager_initialRows;
p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
( c.debug ? console.error('Pager: no initial total page set!') || 0 : 0 );
( debug ? console.error('Pager >> No initial total page set!') || 0 : 0 );
p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered :
( c.debug ? console.error('Pager: no initial filtered page set!') || 0 : 0 );
( debug ? console.error('Pager >> No initial filtered page set!') || 0 : 0 );
tsp.updatePageDisplay( c, false );
} else {
tsp.getAjax( c );
@ -1126,14 +1127,14 @@
}
$.data( table, 'pagerLastPage', p.page );
if ( p.initialized && pageMoved !== false ) {
if ( c.debug ) {
console.log( 'Pager: Triggering pageMoved' );
if ( debug ) {
console.log( 'Pager >> Triggering pageMoved' );
}
c.$table.triggerHandler( 'pageMoved', c );
ts.applyWidget( table );
if ( !p.ajax && table.isUpdating ) {
if ( c.debug ) {
console.log( 'Pager: Triggering updateComplete' );
if ( debug ) {
console.log( 'Pager >> Triggering updateComplete' );
}
c.$table.triggerHandler( 'updateComplete', [ table, true ] );
}
@ -1269,8 +1270,8 @@
tsp.setPageSize( c, p.size );
tsp.moveToPage( c, p, true );
tsp.hideRowsSetup( c );
if ( c.debug ) {
console.log( 'Pager: Enabled' );
if ( ts.debug(c, 'pager') ) {
console.log( 'Pager >> Enabled' );
}
}
},
@ -1296,8 +1297,7 @@
// see #486
ts.showError = function( table, xhr, settings, exception ) {
var $row,
$table = $( table ),
var $table = $( table ),
c = $table[ 0 ].config,
wo = c && c.widgetOptions,
errorRow = c.pager && c.pager.cssErrorRow ||

View File

@ -1,4 +1,4 @@
/*! Widget: saveSort - updated 10/31/2015 (v2.24.0) *//*
/*! Widget: saveSort - updated 2018-03-17 (v2.30.0) *//*
* Requires tablesorter v2.16+
* by Rob Garrison
*/
@ -6,6 +6,15 @@
'use strict';
var ts = $.tablesorter || {};
function getStoredSortList(c) {
var stored = ts.storage( c.table, 'tablesorter-savesort' );
return (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
}
function sortListChanged(c, sortList) {
return (sortList || getStoredSortList(c)).join(',') !== c.sortList.join(',');
}
// this widget saves the last sort only if the
// saveSort widget option is true AND the
// $.tablesorter.storage function is included
@ -21,18 +30,19 @@
thisWidget.format(table, c, wo, true);
},
format: function(table, c, wo, init) {
var stored, time,
var time,
$table = c.$table,
saveSort = wo.saveSort !== false, // make saveSort active/inactive; default to true
sortList = { 'sortList' : c.sortList };
if (c.debug) {
sortList = { 'sortList' : c.sortList },
debug = ts.debug(c, 'saveSort');
if (debug) {
time = new Date();
}
if ($table.hasClass('hasSaveSort')) {
if (saveSort && table.hasInitialized && ts.storage) {
if (saveSort && table.hasInitialized && ts.storage && sortListChanged(c)) {
ts.storage( table, 'tablesorter-savesort', sortList );
if (c.debug) {
console.log('saveSort widget: Saving last sort: ' + c.sortList + ts.benchmark(time));
if (debug) {
console.log('saveSort >> Saving last sort: ' + c.sortList + ts.benchmark(time));
}
}
} else {
@ -41,10 +51,9 @@
sortList = '';
// get data
if (ts.storage) {
stored = ts.storage( table, 'tablesorter-savesort' );
sortList = (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
if (c.debug) {
console.log('saveSort: Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
sortList = getStoredSortList(c);
if (debug) {
console.log('saveSort >> Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
}
$table.bind('saveSortReset', function(event) {
event.stopPropagation();
@ -57,7 +66,9 @@
c.sortList = sortList;
} else if (table.hasInitialized && sortList && sortList.length > 0) {
// update sort change
ts.sortOn( c, sortList );
if (sortListChanged(c, sortList)) {
ts.sortOn(c, sortList);
}
}
}
},

View File

@ -1,4 +1,4 @@
/*! Widget: storage - updated 4/18/2017 (v2.28.8) */
/*! Widget: storage - updated 2018-03-17 (v2.30.0) */
/*global JSON:false */
;(function ($, window, document) {
'use strict';
@ -44,6 +44,7 @@
values = {},
c = table.config,
wo = c && c.widgetOptions,
debug = ts.debug(c, 'storage'),
storageType = (
( options && options.storageType ) || ( wo && wo.storage_storageType )
).toString().charAt(0).toLowerCase(),
@ -72,14 +73,12 @@
hasStorage = true;
window[storageType].removeItem('_tmptest');
} catch (error) {
if (c && c.debug) {
console.warn( storageType + ' is not supported in this browser' );
}
console.warn( storageType + ' is not supported in this browser' );
}
}
}
if (c.debug) {
console.log('Storage widget using', hasStorage ? storageType : 'cookies');
if (debug) {
console.log('Storage >> Using', hasStorage ? storageType : 'cookies');
}
// *** get value ***
if ($.parseJSON) {

View File

@ -1,4 +1,4 @@
/*! Widget: uitheme - updated 9/27/2017 (v2.29.0) */
/*! Widget: uitheme - updated 2018-03-17 (v2.30.0) */
;(function ($) {
'use strict';
var ts = $.tablesorter || {};
@ -63,8 +63,9 @@
theme = c.theme || 'jui',
themes = themesAll[theme] || {},
remove = $.trim( [ themes.sortNone, themes.sortDesc, themes.sortAsc, themes.active ].join( ' ' ) ),
iconRmv = $.trim( [ themes.iconSortNone, themes.iconSortDesc, themes.iconSortAsc ].join( ' ' ) );
if (c.debug) { time = new Date(); }
iconRmv = $.trim( [ themes.iconSortNone, themes.iconSortDesc, themes.iconSortAsc ].join( ' ' ) ),
debug = ts.debug(c, 'uitheme');
if (debug) { time = new Date(); }
// initialization code - run once
if (!$table.hasClass('tablesorter-' + theme) || c.theme !== c.appliedTheme || !wo.uitheme_applied) {
wo.uitheme_applied = true;
@ -109,7 +110,7 @@
$(this)[ event.type === 'mouseenter' ? 'addClass' : 'removeClass' ](themes.hover || '');
});
$headers.each(function(){
$headers.each(function() {
var $this = $(this);
if (!$this.find('.' + ts.css.wrapper).length) {
// Firefox needs this inner div to position the icon & resizer correctly
@ -167,8 +168,8 @@
}
}
}
if (c.debug) {
console.log('Applying ' + theme + ' theme' + ts.benchmark(time));
if (debug) {
console.log('uitheme >> Applied ' + theme + ' theme' + ts.benchmark(time));
}
},
remove: function(table, c, wo, refreshing) {