mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Core: Debug components separately
This commit is contained in:
parent
6f9edd76aa
commit
7b15ec99c5
@ -246,8 +246,8 @@
|
|||||||
pagerArrows( table, p );
|
pagerArrows( table, p );
|
||||||
fixHeight(table, p);
|
fixHeight(table, p);
|
||||||
if (p.initialized && completed !== false) {
|
if (p.initialized && completed !== false) {
|
||||||
if (c.debug) {
|
if (ts.debug(c, 'pager')) {
|
||||||
console.log('Pager: Triggering pagerComplete');
|
console.log('Pager >> Triggering pagerComplete');
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler('pagerComplete', p);
|
c.$table.triggerHandler('pagerComplete', p);
|
||||||
// save pager info to storage
|
// save pager info to storage
|
||||||
@ -429,8 +429,8 @@
|
|||||||
ts.showError( table );
|
ts.showError( table );
|
||||||
|
|
||||||
if ( exception ) {
|
if ( exception ) {
|
||||||
if (c.debug) {
|
if (ts.debug(c, 'pager')) {
|
||||||
console.error('Pager: >> Ajax Error', xhr, settings, exception);
|
console.error('Pager >> Ajax Error', xhr, settings, exception);
|
||||||
}
|
}
|
||||||
ts.showError( table, xhr, settings, exception );
|
ts.showError( table, xhr, settings, exception );
|
||||||
c.$tbodies.eq(0).children('tr').detach();
|
c.$tbodies.eq(0).children('tr').detach();
|
||||||
@ -527,8 +527,8 @@
|
|||||||
// apply widgets after table has rendered & after a delay to prevent
|
// apply widgets after table has rendered & after a delay to prevent
|
||||||
// multiple applyWidget blocking code from blocking this trigger
|
// multiple applyWidget blocking code from blocking this trigger
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
if (c.debug) {
|
if (ts.debug(c, 'pager')) {
|
||||||
console.log('Pager: Triggering pagerChange');
|
console.log('Pager >> Triggering pagerChange');
|
||||||
}
|
}
|
||||||
$table.triggerHandler( 'pagerChange', p );
|
$table.triggerHandler( 'pagerChange', p );
|
||||||
ts.applyWidget( table );
|
ts.applyWidget( table );
|
||||||
@ -573,8 +573,8 @@
|
|||||||
p.oldAjaxSuccess(data);
|
p.oldAjaxSuccess(data);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (c.debug) {
|
if (ts.debug(c, 'pager')) {
|
||||||
console.log('Pager: Ajax initialized', p.ajaxObject);
|
console.log('Pager >> Ajax initialized', p.ajaxObject);
|
||||||
}
|
}
|
||||||
$.ajax(p.ajaxObject);
|
$.ajax(p.ajaxObject);
|
||||||
}
|
}
|
||||||
@ -618,8 +618,8 @@
|
|||||||
if ( typeof p.customAjaxUrl === 'function' ) {
|
if ( typeof p.customAjaxUrl === 'function' ) {
|
||||||
url = p.customAjaxUrl(table, url);
|
url = p.customAjaxUrl(table, url);
|
||||||
}
|
}
|
||||||
if (c.debug) {
|
if (ts.debug(c, 'pager')) {
|
||||||
console.log('Pager: Ajax url = ' + url);
|
console.log('Pager >> Ajax url = ' + url);
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
@ -628,13 +628,14 @@
|
|||||||
var $tb, index, count, added,
|
var $tb, index, count, added,
|
||||||
$t = $(table),
|
$t = $(table),
|
||||||
c = table.config,
|
c = table.config,
|
||||||
|
debug = ts.debug(c, 'pager'),
|
||||||
f = c.$table.hasClass('hasFilters'),
|
f = c.$table.hasClass('hasFilters'),
|
||||||
l = rows && rows.length || 0, // rows may be undefined
|
l = rows && rows.length || 0, // rows may be undefined
|
||||||
e = p.size === 'all' ? p.totalRows : p.size,
|
e = p.size === 'all' ? p.totalRows : p.size,
|
||||||
s = ( p.page * e );
|
s = ( p.page * e );
|
||||||
if ( l < 1 ) {
|
if ( l < 1 ) {
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.warn('Pager: >> No rows for pager to render');
|
console.warn('Pager >> No rows for pager to render');
|
||||||
}
|
}
|
||||||
// empty table, abort!
|
// empty table, abort!
|
||||||
return;
|
return;
|
||||||
@ -646,8 +647,8 @@
|
|||||||
p.cacheIndex = [];
|
p.cacheIndex = [];
|
||||||
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
||||||
if (p.initialized) {
|
if (p.initialized) {
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Pager: Triggering pagerChange');
|
console.log('Pager >> Triggering pagerChange');
|
||||||
}
|
}
|
||||||
$t.triggerHandler( 'pagerChange', p );
|
$t.triggerHandler( 'pagerChange', p );
|
||||||
}
|
}
|
||||||
@ -676,8 +677,8 @@
|
|||||||
}
|
}
|
||||||
updatePageDisplay(table, p);
|
updatePageDisplay(table, p);
|
||||||
if (table.isUpdating) {
|
if (table.isUpdating) {
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Pager: Triggering updateComplete');
|
console.log('Pager >> Triggering updateComplete');
|
||||||
}
|
}
|
||||||
$t.triggerHandler('updateComplete', [ table, true ]);
|
$t.triggerHandler('updateComplete', [ table, true ]);
|
||||||
}
|
}
|
||||||
@ -700,8 +701,8 @@
|
|||||||
renderTable(table, table.config.rowsCopy, p);
|
renderTable(table, table.config.rowsCopy, p);
|
||||||
p.isDisabled = true;
|
p.isDisabled = true;
|
||||||
ts.applyWidget( table );
|
ts.applyWidget( table );
|
||||||
if (table.config.debug) {
|
if (ts.debug(table.config, 'pager')) {
|
||||||
console.log('Pager: Disabled');
|
console.log('Pager >> Disabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// disable size selector
|
// disable size selector
|
||||||
@ -734,9 +735,10 @@
|
|||||||
moveToPage = function(table, p, pageMoved) {
|
moveToPage = function(table, p, pageMoved) {
|
||||||
if ( p.isDisabled ) { return; }
|
if ( p.isDisabled ) { return; }
|
||||||
var tmp,
|
var tmp,
|
||||||
c = table.config,
|
c = table.config,
|
||||||
$t = $(table),
|
debug = ts.debug(c, 'pager'),
|
||||||
l = p.last;
|
$t = $(table),
|
||||||
|
l = p.last;
|
||||||
if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) {
|
if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) {
|
||||||
return updateCache(table);
|
return updateCache(table);
|
||||||
}
|
}
|
||||||
@ -756,8 +758,8 @@
|
|||||||
// & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
|
// & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
|
||||||
(l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
|
(l.optAjaxUrl || '') === (p.ajaxUrl || '') &&
|
||||||
l.sortList === (c.sortList || []).join(',') ) { return; }
|
l.sortList === (c.sortList || []).join(',') ) { return; }
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Pager: Changing to page ' + p.page);
|
console.log('Pager >> Changing to page ' + p.page);
|
||||||
}
|
}
|
||||||
p.last = {
|
p.last = {
|
||||||
page : p.page,
|
page : p.page,
|
||||||
@ -774,9 +776,9 @@
|
|||||||
p.processAjaxOnInit = true;
|
p.processAjaxOnInit = true;
|
||||||
tmp = p.initialRows;
|
tmp = p.initialRows;
|
||||||
p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
|
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 :
|
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 );
|
pagerInitialized( table, p );
|
||||||
} else {
|
} else {
|
||||||
getAjax(table, p);
|
getAjax(table, p);
|
||||||
@ -786,14 +788,14 @@
|
|||||||
}
|
}
|
||||||
$.data(table, 'pagerLastPage', p.page);
|
$.data(table, 'pagerLastPage', p.page);
|
||||||
if (p.initialized && pageMoved !== false) {
|
if (p.initialized && pageMoved !== false) {
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Pager: Triggering pageMoved');
|
console.log('Pager >> Triggering pageMoved');
|
||||||
}
|
}
|
||||||
$t.triggerHandler('pageMoved', p);
|
$t.triggerHandler('pageMoved', p);
|
||||||
ts.applyWidget( table );
|
ts.applyWidget( table );
|
||||||
if (table.isUpdating) {
|
if (table.isUpdating) {
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Pager: Triggering updateComplete');
|
console.log('Pager >> Triggering updateComplete');
|
||||||
}
|
}
|
||||||
$t.triggerHandler('updateComplete', [ table, true ]);
|
$t.triggerHandler('updateComplete', [ table, true ]);
|
||||||
}
|
}
|
||||||
@ -866,8 +868,8 @@
|
|||||||
pagerInitialized = function(table, p) {
|
pagerInitialized = function(table, p) {
|
||||||
p.initialized = true;
|
p.initialized = true;
|
||||||
p.initializing = false;
|
p.initializing = false;
|
||||||
if (table.config.debug) {
|
if (ts.debug(table.config, 'pager')) {
|
||||||
console.log('Pager: Triggering pagerInitialized');
|
console.log('Pager >> Triggering pagerInitialized');
|
||||||
}
|
}
|
||||||
$(table).triggerHandler( 'pagerInitialized', p );
|
$(table).triggerHandler( 'pagerInitialized', p );
|
||||||
ts.applyWidget( table );
|
ts.applyWidget( table );
|
||||||
@ -934,8 +936,8 @@
|
|||||||
setPageSize(table, p.size, p);
|
setPageSize(table, p.size, p);
|
||||||
moveToPage(table, p);
|
moveToPage(table, p);
|
||||||
hideRowsSetup(table, p);
|
hideRowsSetup(table, p);
|
||||||
if (c.debug) {
|
if (ts.debug(c, 'pager')) {
|
||||||
console.log('Pager: Enabled');
|
console.log('Pager >> Enabled');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -944,6 +946,7 @@
|
|||||||
var t, ctrls, fxn, $el,
|
var t, ctrls, fxn, $el,
|
||||||
c = table.config,
|
c = table.config,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
|
debug = ts.debug(c, 'pager'),
|
||||||
p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ),
|
p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ),
|
||||||
$t = c.$table,
|
$t = c.$table,
|
||||||
namespace = c.namespace + 'pager',
|
namespace = c.namespace + 'pager',
|
||||||
@ -951,8 +954,8 @@
|
|||||||
pager = p.$container = $(p.container).addClass('tablesorter-pager').show();
|
pager = p.$container = $(p.container).addClass('tablesorter-pager').show();
|
||||||
// save a copy of the original settings
|
// save a copy of the original settings
|
||||||
p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
|
p.settings = $.extend( true, {}, $.tablesorterPager.defaults, settings );
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Pager: Initializing');
|
console.log('Pager >> Initializing');
|
||||||
}
|
}
|
||||||
p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
|
p.oldAjaxSuccess = p.oldAjaxSuccess || p.ajaxObject.success;
|
||||||
c.appender = $this.appender;
|
c.appender = $this.appender;
|
||||||
@ -1066,8 +1069,8 @@
|
|||||||
// clicked controls
|
// clicked controls
|
||||||
ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
|
ctrls = [ p.cssFirst, p.cssPrev, p.cssNext, p.cssLast ];
|
||||||
fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
|
fxn = [ moveToFirstPage, moveToPrevPage, moveToNextPage, moveToLastPage ];
|
||||||
if (c.debug && !pager.length) {
|
if (debug && !pager.length) {
|
||||||
console.warn('Pager: >> Container not found');
|
console.warn('Pager >> "container" not found');
|
||||||
}
|
}
|
||||||
pager.find(ctrls.join(','))
|
pager.find(ctrls.join(','))
|
||||||
.attr('tabindex', 0)
|
.attr('tabindex', 0)
|
||||||
@ -1095,8 +1098,8 @@
|
|||||||
moveToPage(table, p, true);
|
moveToPage(table, p, true);
|
||||||
updatePageDisplay(table, p, false);
|
updatePageDisplay(table, p, false);
|
||||||
});
|
});
|
||||||
} else if (c.debug) {
|
} else if (debug) {
|
||||||
console.warn('Pager: >> Goto selector not found');
|
console.warn('Pager >> "goto" selector not found');
|
||||||
}
|
}
|
||||||
// page size selector
|
// page size selector
|
||||||
$el = pager.find(p.cssPageSize);
|
$el = pager.find(p.cssPageSize);
|
||||||
@ -1113,8 +1116,8 @@
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
} else if (c.debug) {
|
} else if (debug) {
|
||||||
console.warn('Pager: >> Size selector not found');
|
console.warn('Pager >> "size" selector not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear initialized flag
|
// clear initialized flag
|
||||||
@ -1145,8 +1148,8 @@
|
|||||||
// update page size on init
|
// update page size on init
|
||||||
setPageSize(table, p.size, p);
|
setPageSize(table, p.size, p);
|
||||||
moveToPage(table, p);
|
moveToPage(table, p);
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Pager: Triggering pagerInitialized');
|
console.log('Pager >> Triggering pagerInitialized');
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler( 'pagerInitialized', p );
|
c.$table.triggerHandler( 'pagerInitialized', p );
|
||||||
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
|
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
|
||||||
|
@ -16,14 +16,18 @@
|
|||||||
<!-- Tablesorter: required -->
|
<!-- Tablesorter: required -->
|
||||||
<link rel="stylesheet" href="../css/theme.blue.css">
|
<link rel="stylesheet" href="../css/theme.blue.css">
|
||||||
<script src="../js/jquery.tablesorter.js"></script>
|
<script src="../js/jquery.tablesorter.js"></script>
|
||||||
|
<script src="../js/widgets/widget-filter.js"></script>
|
||||||
|
|
||||||
<script id="js">$(function() {
|
<script id="js">$(function() {
|
||||||
|
|
||||||
// call the tablesorter plugin
|
// call the tablesorter plugin
|
||||||
$("table").tablesorter({
|
$("table").tablesorter({
|
||||||
theme : 'blue',
|
theme : 'blue',
|
||||||
// enable debug mode
|
// enable debug mode;
|
||||||
debug: true
|
// debug: true => all debugging
|
||||||
|
// debug: "filter" => filter widget debugging only
|
||||||
|
debug: "core filter", // => core and filter widget debugging
|
||||||
|
widgets: ["filter"]
|
||||||
});
|
});
|
||||||
|
|
||||||
});</script>
|
});</script>
|
||||||
@ -39,7 +43,7 @@
|
|||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<p class="tip">
|
<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>
|
</p>
|
||||||
|
|
||||||
<h1>Demo</h1>
|
<h1>Demo</h1>
|
||||||
|
@ -928,11 +928,24 @@
|
|||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr id="debug">
|
<tr id="debug">
|
||||||
<td><span class="permalink">debug</span></td>
|
<td><a href="#" class="permalink">debug</a></td>
|
||||||
<td>Boolean</td>
|
<td>Boolean or String</td>
|
||||||
<td>false</td>
|
<td>false</td>
|
||||||
<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>
|
||||||
<td><a href="example-option-debug.html">Example</a></td>
|
<td><a href="example-option-debug.html">Example</a></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -216,7 +216,7 @@
|
|||||||
setup : function( table, c ) {
|
setup : function( table, c ) {
|
||||||
// if no thead or tbody, or tablesorter is already present, quit
|
// if no thead or tbody, or tablesorter is already present, quit
|
||||||
if ( !table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true ) {
|
if ( !table || !table.tHead || table.tBodies.length === 0 || table.hasInitialized === true ) {
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
if ( table.hasInitialized ) {
|
if ( table.hasInitialized ) {
|
||||||
console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
|
console.warn( 'Stopping initialization. Tablesorter has already been initialized' );
|
||||||
} else {
|
} else {
|
||||||
@ -237,7 +237,7 @@
|
|||||||
table.config = c;
|
table.config = c;
|
||||||
// save the settings where they read
|
// save the settings where they read
|
||||||
$.data( table, 'tablesorter', c );
|
$.data( table, 'tablesorter', c );
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter v' + ts.version );
|
console[ console.group ? 'group' : 'log' ]( 'Initializing tablesorter v' + ts.version );
|
||||||
$.data( table, 'startoveralltimer', new Date() );
|
$.data( table, 'startoveralltimer', new Date() );
|
||||||
}
|
}
|
||||||
@ -343,9 +343,9 @@
|
|||||||
// initialized
|
// initialized
|
||||||
table.hasInitialized = true;
|
table.hasInitialized = true;
|
||||||
table.isProcessing = false;
|
table.isProcessing = false;
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.log( 'Overall initialization time:' + ts.benchmark( $.data( table, 'startoveralltimer' ) ) );
|
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 );
|
$table.triggerHandler( 'tablesorter-initialized', table );
|
||||||
if ( typeof c.initialized === 'function' ) {
|
if ( typeof c.initialized === 'function' ) {
|
||||||
@ -542,7 +542,7 @@
|
|||||||
c.headerList = [];
|
c.headerList = [];
|
||||||
c.headerContent = [];
|
c.headerContent = [];
|
||||||
c.sortVars = [];
|
c.sortVars = [];
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
timer = new Date();
|
timer = new Date();
|
||||||
}
|
}
|
||||||
// children tr in tfoot - see issue #196 & #547
|
// children tr in tfoot - see issue #196 & #547
|
||||||
@ -637,7 +637,7 @@
|
|||||||
});
|
});
|
||||||
// enable/disable sorting
|
// enable/disable sorting
|
||||||
ts.updateHeader( c );
|
ts.updateHeader( c );
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.log( 'Built headers:' + ts.benchmark( timer ) );
|
console.log( 'Built headers:' + ts.benchmark( timer ) );
|
||||||
console.log( c.$headers );
|
console.log( c.$headers );
|
||||||
}
|
}
|
||||||
@ -660,14 +660,15 @@
|
|||||||
noParser, parser, extractor, time, tbody, len,
|
noParser, parser, extractor, time, tbody, len,
|
||||||
table = c.table,
|
table = c.table,
|
||||||
tbodyIndex = 0,
|
tbodyIndex = 0,
|
||||||
debug = {};
|
debug = ts.debug(c, 'core'),
|
||||||
|
debugOutput = {};
|
||||||
// update table bodies in case we start with an empty table
|
// update table bodies in case we start with an empty table
|
||||||
c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
|
c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
|
||||||
tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
|
tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies;
|
||||||
len = tbody.length;
|
len = tbody.length;
|
||||||
if ( len === 0 ) {
|
if ( len === 0 ) {
|
||||||
return c.debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : '';
|
return debug ? console.warn( 'Warning: *Empty table!* Not building a parser cache' ) : '';
|
||||||
} else if ( c.debug ) {
|
} else if ( debug ) {
|
||||||
time = new Date();
|
time = new Date();
|
||||||
console[ console.group ? 'group' : 'log' ]( 'Detecting parsers for each column' );
|
console[ console.group ? 'group' : 'log' ]( 'Detecting parsers for each column' );
|
||||||
}
|
}
|
||||||
@ -709,8 +710,8 @@
|
|||||||
if ( !parser ) {
|
if ( !parser ) {
|
||||||
parser = ts.detectParserForColumn( c, rows, -1, colIndex );
|
parser = ts.detectParserForColumn( c, rows, -1, colIndex );
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
debug[ '(' + colIndex + ') ' + header.text() ] = {
|
debugOutput[ '(' + colIndex + ') ' + header.text() ] = {
|
||||||
parser : parser.id,
|
parser : parser.id,
|
||||||
extractor : extractor ? extractor.id : 'none',
|
extractor : extractor ? extractor.id : 'none',
|
||||||
string : c.strings[ colIndex ],
|
string : c.strings[ colIndex ],
|
||||||
@ -736,9 +737,9 @@
|
|||||||
}
|
}
|
||||||
tbodyIndex += ( list.parsers.length ) ? len : 1;
|
tbodyIndex += ( list.parsers.length ) ? len : 1;
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
if ( !ts.isEmptyObject( debug ) ) {
|
if ( !ts.isEmptyObject( debugOutput ) ) {
|
||||||
console[ console.table ? 'table' : 'log' ]( debug );
|
console[ console.table ? 'table' : 'log' ]( debugOutput );
|
||||||
} else {
|
} else {
|
||||||
console.warn( ' No parsers detected!' );
|
console.warn( ' No parsers detected!' );
|
||||||
}
|
}
|
||||||
@ -781,6 +782,7 @@
|
|||||||
indx = ts.parsers.length,
|
indx = ts.parsers.length,
|
||||||
node = false,
|
node = false,
|
||||||
nodeValue = '',
|
nodeValue = '',
|
||||||
|
debug = ts.debug(c, 'core'),
|
||||||
keepLooking = true;
|
keepLooking = true;
|
||||||
while ( nodeValue === '' && keepLooking ) {
|
while ( nodeValue === '' && keepLooking ) {
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
@ -791,7 +793,7 @@
|
|||||||
node = rows[ rowIndex ].cells[ cellIndex ];
|
node = rows[ rowIndex ].cells[ cellIndex ];
|
||||||
nodeValue = ts.getElementText( c, node, cellIndex );
|
nodeValue = ts.getElementText( c, node, cellIndex );
|
||||||
$node = $( node );
|
$node = $( node );
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Checking if value was empty on row ' + rowIndex + ', column: ' +
|
console.log( 'Checking if value was empty on row ' + rowIndex + ', column: ' +
|
||||||
cellIndex + ': "' + nodeValue + '"' );
|
cellIndex + ': "' + nodeValue + '"' );
|
||||||
}
|
}
|
||||||
@ -873,7 +875,8 @@
|
|||||||
cols, $cells, cell, cacheTime, totalRows, rowData, prevRowData,
|
cols, $cells, cell, cacheTime, totalRows, rowData, prevRowData,
|
||||||
colMax, span, cacheIndex, hasParser, max, len, index,
|
colMax, span, cacheIndex, hasParser, max, len, index,
|
||||||
table = c.table,
|
table = c.table,
|
||||||
parsers = c.parsers;
|
parsers = c.parsers,
|
||||||
|
debug = ts.debug(c, 'core');
|
||||||
// update tbody variable
|
// update tbody variable
|
||||||
c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
|
c.$tbodies = c.$table.children( 'tbody:not(.' + c.cssInfoBlock + ')' );
|
||||||
$tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies,
|
$tbody = typeof $tbodies === 'undefined' ? c.$tbodies : $tbodies,
|
||||||
@ -881,9 +884,9 @@
|
|||||||
c.totalRows = 0;
|
c.totalRows = 0;
|
||||||
// if no parsers found, return - it's an empty table.
|
// if no parsers found, return - it's an empty table.
|
||||||
if ( !parsers ) {
|
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();
|
cacheTime = new Date();
|
||||||
}
|
}
|
||||||
// processing icon
|
// processing icon
|
||||||
@ -952,7 +955,7 @@
|
|||||||
cell = $row[ 0 ].cells[ colIndex ];
|
cell = $row[ 0 ].cells[ colIndex ];
|
||||||
if ( cell && cacheIndex < c.columns ) {
|
if ( cell && cacheIndex < c.columns ) {
|
||||||
hasParser = typeof parsers[ cacheIndex ] !== 'undefined';
|
hasParser = typeof parsers[ cacheIndex ] !== 'undefined';
|
||||||
if ( !hasParser && c.debug ) {
|
if ( !hasParser && debug ) {
|
||||||
console.warn( 'No parser found for row: ' + rowIndex + ', column: ' + colIndex +
|
console.warn( 'No parser found for row: ' + rowIndex + ', column: ' + colIndex +
|
||||||
'; cell containing: "' + $(cell).text() + '"; does it have a header?' );
|
'; cell containing: "' + $(cell).text() + '"; does it have a header?' );
|
||||||
}
|
}
|
||||||
@ -1000,7 +1003,7 @@
|
|||||||
if ( c.showProcessing ) {
|
if ( c.showProcessing ) {
|
||||||
ts.isProcessing( table ); // remove processing icon
|
ts.isProcessing( table ); // remove processing icon
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
len = Math.min( 5, c.cache[ 0 ].normalized.length );
|
len = Math.min( 5, c.cache[ 0 ].normalized.length );
|
||||||
console[ console.group ? 'group' : 'log' ]( 'Building cache for ' + c.totalRows +
|
console[ console.group ? 'group' : 'log' ]( 'Building cache for ' + c.totalRows +
|
||||||
' rows (showing ' + len + ' rows in log) and ' + c.columns + ' columns' +
|
' rows (showing ' + len + ' rows in log) and ' + c.columns + ' columns' +
|
||||||
@ -1031,7 +1034,7 @@
|
|||||||
data = { raw : [], parsed: [], $cell: [] },
|
data = { raw : [], parsed: [], $cell: [] },
|
||||||
c = table.config;
|
c = table.config;
|
||||||
if ( ts.isEmptyObject( c ) ) {
|
if ( ts.isEmptyObject( c ) ) {
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.warn( 'No cache found - aborting getColumnText function!' );
|
console.warn( 'No cache found - aborting getColumnText function!' );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1375,7 +1378,7 @@
|
|||||||
ts.resortComplete( c, callback );
|
ts.resortComplete( c, callback );
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.error( 'updateCell aborted, tbody missing or not within the indicated table' );
|
console.error( 'updateCell aborted, tbody missing or not within the indicated table' );
|
||||||
}
|
}
|
||||||
c.table.isUpdating = false;
|
c.table.isUpdating = false;
|
||||||
@ -1398,7 +1401,7 @@
|
|||||||
// row contained in the table?
|
// row contained in the table?
|
||||||
( ts.getClosest( $row, 'table' )[ 0 ] !== c.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 ' +
|
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' );
|
'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 ) :
|
return c.appender ? c.appender( table, rows ) :
|
||||||
table.isUpdating ? c.$table.triggerHandler( 'updateComplete', table ) : ''; // Fixes #532
|
table.isUpdating ? c.$table.triggerHandler( 'updateComplete', table ) : ''; // Fixes #532
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
appendTime = new Date();
|
appendTime = new Date();
|
||||||
}
|
}
|
||||||
for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
for ( tbodyIndex = 0; tbodyIndex < $tbodies.length; tbodyIndex++ ) {
|
||||||
@ -1504,7 +1507,7 @@
|
|||||||
if ( c.appender ) {
|
if ( c.appender ) {
|
||||||
c.appender( table, rows );
|
c.appender( table, rows );
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.log( 'Rebuilt table' + ts.benchmark( appendTime ) );
|
console.log( 'Rebuilt table' + ts.benchmark( appendTime ) );
|
||||||
}
|
}
|
||||||
// apply table widgets; but not before ajax completes
|
// apply table widgets; but not before ajax completes
|
||||||
@ -1686,7 +1689,7 @@
|
|||||||
// empty table - fixes #206/#346
|
// empty table - fixes #206/#346
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( c.debug ) { sortTime = new Date(); }
|
if ( ts.debug(c, 'core') ) { sortTime = new Date(); }
|
||||||
// cache textSorter to optimize speed
|
// cache textSorter to optimize speed
|
||||||
if ( typeof textSorter === 'object' ) {
|
if ( typeof textSorter === 'object' ) {
|
||||||
colMax = c.columns;
|
colMax = c.columns;
|
||||||
@ -1748,7 +1751,7 @@
|
|||||||
return a[ c.columns ].order - b[ c.columns ].order;
|
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 ) );
|
console.log( 'Applying sort ' + sortList.toString() + ts.benchmark( sortTime ) );
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -2001,6 +2004,7 @@
|
|||||||
var applied, time, name,
|
var applied, time, name,
|
||||||
c = table.config,
|
c = table.config,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
|
debug = ts.debug(c, 'core'),
|
||||||
widget = ts.getWidgetById( id );
|
widget = ts.getWidgetById( id );
|
||||||
if ( widget ) {
|
if ( widget ) {
|
||||||
name = widget.id;
|
name = widget.id;
|
||||||
@ -2009,7 +2013,7 @@
|
|||||||
if ( $.inArray( name, c.widgets ) < 0 ) {
|
if ( $.inArray( name, c.widgets ) < 0 ) {
|
||||||
c.widgets[ c.widgets.length ] = name;
|
c.widgets[ c.widgets.length ] = name;
|
||||||
}
|
}
|
||||||
if ( c.debug ) { time = new Date(); }
|
if ( debug ) { time = new Date(); }
|
||||||
|
|
||||||
if ( init || !( c.widgetInit[ name ] ) ) {
|
if ( init || !( c.widgetInit[ name ] ) ) {
|
||||||
// set init flag first to prevent calling init more than once (e.g. pager)
|
// set init flag first to prevent calling init more than once (e.g. pager)
|
||||||
@ -2020,7 +2024,7 @@
|
|||||||
}
|
}
|
||||||
if ( typeof widget.init === 'function' ) {
|
if ( typeof widget.init === 'function' ) {
|
||||||
applied = true;
|
applied = true;
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
|
console[ console.group ? 'group' : 'log' ]( 'Initializing ' + name + ' widget' );
|
||||||
}
|
}
|
||||||
widget.init( table, widget, c, wo );
|
widget.init( table, widget, c, wo );
|
||||||
@ -2028,12 +2032,12 @@
|
|||||||
}
|
}
|
||||||
if ( !init && typeof widget.format === 'function' ) {
|
if ( !init && typeof widget.format === 'function' ) {
|
||||||
applied = true;
|
applied = true;
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
|
console[ console.group ? 'group' : 'log' ]( 'Updating ' + name + ' widget' );
|
||||||
}
|
}
|
||||||
widget.format( table, c, wo, false );
|
widget.format( table, c, wo, false );
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
if ( applied ) {
|
if ( applied ) {
|
||||||
console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time ) );
|
console.log( 'Completed ' + ( init ? 'initializing ' : 'applying ' ) + name + ' widget' + ts.benchmark( time ) );
|
||||||
if ( console.groupEnd ) { console.groupEnd(); }
|
if ( console.groupEnd ) { console.groupEnd(); }
|
||||||
@ -2046,12 +2050,13 @@
|
|||||||
table = $( table )[ 0 ]; // in case this is called externally
|
table = $( table )[ 0 ]; // in case this is called externally
|
||||||
var indx, len, names, widget, time,
|
var indx, len, names, widget, time,
|
||||||
c = table.config,
|
c = table.config,
|
||||||
|
debug = ts.debug(c, 'core'),
|
||||||
widgets = [];
|
widgets = [];
|
||||||
// prevent numerous consecutive widget applications
|
// prevent numerous consecutive widget applications
|
||||||
if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) {
|
if ( init !== false && table.hasInitialized && ( table.isApplyingWidgets || table.isUpdating ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( c.debug ) { time = new Date(); }
|
if ( debug ) { time = new Date(); }
|
||||||
ts.addWidgetFromClass( table );
|
ts.addWidgetFromClass( table );
|
||||||
// prevent "tablesorter-ready" from firing multiple times in a row
|
// prevent "tablesorter-ready" from firing multiple times in a row
|
||||||
clearTimeout( c.timerReady );
|
clearTimeout( c.timerReady );
|
||||||
@ -2070,7 +2075,7 @@
|
|||||||
// set priority to 10 if not defined
|
// set priority to 10 if not defined
|
||||||
if ( !widget.priority ) { widget.priority = 10; }
|
if ( !widget.priority ) { widget.priority = 10; }
|
||||||
widgets[ indx ] = widget;
|
widgets[ indx ] = widget;
|
||||||
} else if ( c.debug ) {
|
} else if ( debug ) {
|
||||||
console.warn( '"' + names[ indx ] + '" was enabled, but the widget code has not been loaded!' );
|
console.warn( '"' + names[ indx ] + '" was enabled, but the widget code has not been loaded!' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2080,7 +2085,7 @@
|
|||||||
});
|
});
|
||||||
// add/update selected widgets
|
// add/update selected widgets
|
||||||
len = widgets.length;
|
len = widgets.length;
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
|
console[ console.group ? 'group' : 'log' ]( 'Start ' + ( init ? 'initializing' : 'applying' ) + ' widgets' );
|
||||||
}
|
}
|
||||||
for ( indx = 0; indx < len; indx++ ) {
|
for ( indx = 0; indx < len; indx++ ) {
|
||||||
@ -2089,7 +2094,7 @@
|
|||||||
ts.applyWidgetId( table, widget.id, init );
|
ts.applyWidgetId( table, widget.id, init );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( c.debug && console.groupEnd ) { console.groupEnd(); }
|
if ( debug && console.groupEnd ) { console.groupEnd(); }
|
||||||
}
|
}
|
||||||
c.timerReady = setTimeout( function() {
|
c.timerReady = setTimeout( function() {
|
||||||
table.isApplyingWidgets = false;
|
table.isApplyingWidgets = false;
|
||||||
@ -2099,7 +2104,7 @@
|
|||||||
if ( !init && typeof callback === 'function' ) {
|
if ( !init && typeof callback === 'function' ) {
|
||||||
callback( table );
|
callback( table );
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
widget = c.widgets.length;
|
widget = c.widgets.length;
|
||||||
console.log( 'Completed ' +
|
console.log( 'Completed ' +
|
||||||
( init === true ? 'initializing ' : 'applying ' ) + widget +
|
( init === true ? 'initializing ' : 'applying ' ) + widget +
|
||||||
@ -2136,7 +2141,7 @@
|
|||||||
c.widgets.splice( indx, 1 );
|
c.widgets.splice( indx, 1 );
|
||||||
}
|
}
|
||||||
if ( widget && widget.remove ) {
|
if ( widget && widget.remove ) {
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' );
|
console.log( ( refreshing ? 'Refreshing' : 'Removing' ) + ' "' + name[ index ] + '" widget' );
|
||||||
}
|
}
|
||||||
widget.remove( table, c, c.widgetOptions, refreshing );
|
widget.remove( table, c, c.widgetOptions, refreshing );
|
||||||
@ -2190,6 +2195,12 @@
|
|||||||
log : function() {
|
log : function() {
|
||||||
console.log( arguments );
|
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 from jQuery v1.4
|
||||||
isEmptyObject : function( obj ) {
|
isEmptyObject : function( obj ) {
|
||||||
@ -2495,7 +2506,7 @@
|
|||||||
ignore = 'headers sortForce sortList sortAppend widgets'.split( ' ' ),
|
ignore = 'headers sortForce sortList sortAppend widgets'.split( ' ' ),
|
||||||
orig = c.originalSettings;
|
orig = c.originalSettings;
|
||||||
if ( orig ) {
|
if ( orig ) {
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
timer = new Date();
|
timer = new Date();
|
||||||
}
|
}
|
||||||
for ( setting in orig ) {
|
for ( setting in orig ) {
|
||||||
@ -2511,7 +2522,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.log( 'validate options time:' + ts.benchmark( timer ) );
|
console.log( 'validate options time:' + ts.benchmark( timer ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2542,7 +2553,6 @@
|
|||||||
var events,
|
var events,
|
||||||
$t = $( table ),
|
$t = $( table ),
|
||||||
c = table.config,
|
c = table.config,
|
||||||
debug = c.debug,
|
|
||||||
$h = $t.find( 'thead:first' ),
|
$h = $t.find( 'thead:first' ),
|
||||||
$r = $h.find( 'tr.' + ts.css.headerRow ).removeClass( ts.css.headerRow + ' ' + c.cssHeaderRow ),
|
$r = $h.find( 'tr.' + ts.css.headerRow ).removeClass( ts.css.headerRow + ' ' + c.cssHeaderRow ),
|
||||||
$f = $t.find( 'tfoot:first > tr' ).children( 'th, td' );
|
$f = $t.find( 'tfoot:first > tr' ).children( 'th, td' );
|
||||||
@ -2580,7 +2590,7 @@
|
|||||||
if ( typeof callback === 'function' ) {
|
if ( typeof callback === 'function' ) {
|
||||||
callback( table );
|
callback( table );
|
||||||
}
|
}
|
||||||
if ( debug ) {
|
if ( ts.debug(c, 'core') ) {
|
||||||
console.log( 'tablesorter has been removed' );
|
console.log( 'tablesorter has been removed' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,14 +4,14 @@
|
|||||||
*/
|
*/
|
||||||
/*jshint browser:true, jquery:true, unused:false */
|
/*jshint browser:true, jquery:true, unused:false */
|
||||||
/*global jQuery: false */
|
/*global jQuery: false */
|
||||||
;(function($){
|
;(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var ts = $.tablesorter = $.tablesorter || {},
|
var ts = $.tablesorter = $.tablesorter || {},
|
||||||
|
|
||||||
// build a table from data (requires existing <table> tag)
|
// build a table from data (requires existing <table> tag)
|
||||||
// data.header contains an array of header titles
|
// data.header contains an array of header titles
|
||||||
// data.rows contains an array of rows which contains an array of cells
|
// 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
|
// add build options to defaults to prevent warnings
|
||||||
$.extend(true, ts.defaults.widgetOptions, bt.defaults);
|
$.extend(true, ts.defaults.widgetOptions, bt.defaults);
|
||||||
// add table if one doesn't exist
|
// add table if one doesn't exist
|
||||||
@ -21,9 +21,10 @@
|
|||||||
p = wo.build_processing,
|
p = wo.build_processing,
|
||||||
typ = wo.build_type,
|
typ = wo.build_type,
|
||||||
d = wo.build_source || c.data,
|
d = wo.build_source || c.data,
|
||||||
|
debug = ts.debug(c, 'build'),
|
||||||
|
|
||||||
// determine type: html, json, array, csv, object
|
// determine type: html, json, array, csv, object
|
||||||
runType = function(d){
|
runType = function(d) {
|
||||||
var t = $.type(d),
|
var t = $.type(d),
|
||||||
jq = d instanceof jQuery;
|
jq = d instanceof jQuery;
|
||||||
// run any processing if set
|
// run any processing if set
|
||||||
@ -59,7 +60,9 @@
|
|||||||
|
|
||||||
// even if wo.build_type is undefined, we can try to figure out the type
|
// even if wo.build_type is undefined, we can try to figure out the type
|
||||||
if ( !ts.buildTable.hasOwnProperty(typ) && typ !== '' ) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,8 +75,10 @@
|
|||||||
.done(function(data) {
|
.done(function(data) {
|
||||||
runType(data);
|
runType(data);
|
||||||
})
|
})
|
||||||
.fail(function( jqXHR, textStatus, errorThrown) {
|
.fail(function( jqXHR, textStatus) {
|
||||||
if (c.debug) { console.error('aborting build table widget, failed ajax load'); }
|
if (debug) {
|
||||||
|
console.error('Build >> ERROR: Aborting build table widget, failed ajax load');
|
||||||
|
}
|
||||||
$tbl.html('<tr><td class="error">' + jqXHR.status + ' ' + textStatus + '</td></tr>');
|
$tbl.html('<tr><td class="error">' + jqXHR.status + ' ' + textStatus + '</td></tr>');
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
@ -125,7 +130,7 @@
|
|||||||
// add colgroup if widths set
|
// add colgroup if widths set
|
||||||
if (widths && widths.length) {
|
if (widths && widths.length) {
|
||||||
t += '<colgroup>';
|
t += '<colgroup>';
|
||||||
$.each(widths, function(i, w){
|
$.each(widths, function(i, w) {
|
||||||
t += '<col' + ( w ? ' style="width:' + w + '"' : '' ) + '>';
|
t += '<col' + ( w ? ' style="width:' + w + '"' : '' ) + '>';
|
||||||
});
|
});
|
||||||
t += '</colgroup>';
|
t += '</colgroup>';
|
||||||
@ -133,7 +138,7 @@
|
|||||||
return t;
|
return t;
|
||||||
},
|
},
|
||||||
// d = cell data; typ = 'th' or 'td'; first = save widths from first header row only
|
// 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,
|
var j, $td,
|
||||||
$col = first ? $('<col>') : '',
|
$col = first ? $('<col>') : '',
|
||||||
cls = wo.build_headers.classes,
|
cls = wo.build_headers.classes,
|
||||||
@ -150,7 +155,7 @@
|
|||||||
// assume we have an object
|
// assume we have an object
|
||||||
$td = $('<' + typ + '>');
|
$td = $('<' + typ + '>');
|
||||||
for (j in d) {
|
for (j in d) {
|
||||||
if (d.hasOwnProperty(j)){
|
if (d.hasOwnProperty(j)) {
|
||||||
if (j === 'text' || j === 'html') {
|
if (j === 'text' || j === 'html') {
|
||||||
$td[j]( d[j] );
|
$td[j]( d[j] );
|
||||||
} else if (first && j === 'width') {
|
} else if (first && j === 'width') {
|
||||||
@ -165,7 +170,7 @@
|
|||||||
return [ $td, $col ];
|
return [ $td, $col ];
|
||||||
},
|
},
|
||||||
// h1 = header text from data
|
// h1 = header text from data
|
||||||
header : function(h1, wo){
|
header : function(h1, wo) {
|
||||||
var h2 = wo.build_headers.text,
|
var h2 = wo.build_headers.text,
|
||||||
cls = wo.build_headers.classes,
|
cls = wo.build_headers.classes,
|
||||||
t = '<tr>' + (wo.build_numbers.addColumn ? '<th' + (wo.build_numbers.sortable ? '' :
|
t = '<tr>' + (wo.build_numbers.addColumn ? '<th' + (wo.build_numbers.sortable ? '' :
|
||||||
@ -180,7 +185,7 @@
|
|||||||
});
|
});
|
||||||
return t + '</tr>';
|
return t + '</tr>';
|
||||||
},
|
},
|
||||||
rows : function(items, txt, c, wo, num, ftr){
|
rows : function(items, txt, c, wo, num, ftr) {
|
||||||
var h = (ftr ? 'th' : 'td'),
|
var h = (ftr ? 'th' : 'td'),
|
||||||
t = '<tr>' + (wo.build_numbers.addColumn ? '<' + h + '>' + (ftr ? '' : num) + '</' + h + '>' : '');
|
t = '<tr>' + (wo.build_numbers.addColumn ? '<' + h + '>' + (ftr ? '' : num) + '</' + h + '>' : '');
|
||||||
$.each(items, function(i, item) {
|
$.each(items, function(i, item) {
|
||||||
@ -196,8 +201,11 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bt.buildComplete = function(table, wo){
|
bt.buildComplete = function(table, wo) {
|
||||||
$(table).triggerHandler(wo.build_complete);
|
$(table).triggerHandler(wo.build_complete);
|
||||||
|
if (table.config && ts.debug(table.config, 'build')) {
|
||||||
|
console.log('Build >> Table build complete');
|
||||||
|
}
|
||||||
ts.setup(table, table.config);
|
ts.setup(table, table.config);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -361,7 +369,9 @@
|
|||||||
r = data.hasOwnProperty(kr) && !$.isEmptyObject(data.kr) ? data.kr : data.hasOwnProperty('rows') ? data.rows : false;
|
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 (!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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,7 +381,7 @@
|
|||||||
// Build thead
|
// Build thead
|
||||||
// h = [ ['headerRow1Cell1', 'headerRow1Cell2', ... 'headerRow1CellN' ], ['headerRow2Cell1', ... ] ]
|
// h = [ ['headerRow1Cell1', 'headerRow1Cell2', ... 'headerRow1CellN' ], ['headerRow2Cell1', ... ] ]
|
||||||
// or h = [ [ { text: 'firstCell', class: 'fc', width: '20%' }, ..., { text: 'last Cell' } ], [ /* second row */ ] ]
|
// 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') );
|
$tr = $('<tr>').appendTo( $t.find('thead') );
|
||||||
l = d.length; // header row
|
l = d.length; // header row
|
||||||
for ( j = 0; j < l; j++ ) {
|
for ( j = 0; j < l; j++ ) {
|
||||||
@ -388,14 +398,14 @@
|
|||||||
|
|
||||||
$tb = $('<tbody>');
|
$tb = $('<tbody>');
|
||||||
// Build tbody
|
// Build tbody
|
||||||
$.each(r, function(i, d){
|
$.each(r, function(i, d) {
|
||||||
var j;
|
var j;
|
||||||
t = $.type(d) === 'object';
|
t = $.type(d) === 'object';
|
||||||
// add new tbody
|
// add new tbody
|
||||||
if (t && d.newTbody) {
|
if (t && d.newTbody) {
|
||||||
$tb = $('<tbody>').appendTo( $t );
|
$tb = $('<tbody>').appendTo( $t );
|
||||||
for (j in d) {
|
for (j in d) {
|
||||||
if (d.hasOwnProperty(j) && j !== 'newTbody'){
|
if (d.hasOwnProperty(j) && j !== 'newTbody') {
|
||||||
$tb.attr(j, d[j]);
|
$tb.attr(j, d[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,7 +419,7 @@
|
|||||||
if (t) {
|
if (t) {
|
||||||
// row defined by object
|
// row defined by object
|
||||||
for (j in d) {
|
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]);
|
$tr.attr(j, d[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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+
|
* Requires tablesorter v2.8+ and jQuery 1.7+
|
||||||
* by Justin Hallett & Rob Garrison
|
* by Justin Hallett & Rob Garrison
|
||||||
*/
|
*/
|
||||||
/*jshint browser:true, jquery:true, unused:false */
|
/*jshint browser:true, jquery:true, unused:false */
|
||||||
/*global jQuery: false */
|
/*global jQuery: false */
|
||||||
;(function($){
|
;(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var ts = $.tablesorter,
|
var ts = $.tablesorter,
|
||||||
@ -15,13 +15,14 @@
|
|||||||
queryBreak : '@media all and (min-width: [size]) { [columns] { display: table-cell; } } ',
|
queryBreak : '@media all and (min-width: [size]) { [columns] { display: table-cell; } } ',
|
||||||
|
|
||||||
init: function(table, c, wo) {
|
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
|
// abort if no input is contained within the layout
|
||||||
$t = $(wo.columnSelector_layout);
|
$t = $(wo.columnSelector_layout);
|
||||||
if (!$t.find('input').add( $t.filter('input') ).length) {
|
if (!$t.find('input').add( $t.filter('input') ).length) {
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.error('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;
|
return;
|
||||||
}
|
}
|
||||||
@ -45,8 +46,8 @@
|
|||||||
colSel.isInitializing = false;
|
colSel.isInitializing = false;
|
||||||
if (colSel.$container.length) {
|
if (colSel.$container.length) {
|
||||||
tsColSel.updateCols(c, wo);
|
tsColSel.updateCols(c, wo);
|
||||||
} else if (c.debug) {
|
} else if (debug) {
|
||||||
console.warn('ColumnSelector: >> container not found');
|
console.warn('ColumnSelector >> container not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
c.$table
|
c.$table
|
||||||
@ -59,11 +60,14 @@
|
|||||||
[ 'auto', [2,3,4] ] = set visible columns; turn on "auto" mode.
|
[ 'auto', [2,3,4] ] = set visible columns; turn on "auto" mode.
|
||||||
true = 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
|
// make sure we're using current config settings
|
||||||
tsColSel.refreshColumns( this.config, optName, optState );
|
tsColSel.refreshColumns( this.config, optName, optState );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
console.log('ColumnSelector >> Widget initialized');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshColumns: function( c, optName, optState ) {
|
refreshColumns: function( c, optName, optState ) {
|
||||||
@ -87,7 +91,7 @@
|
|||||||
if (isArry) {
|
if (isArry) {
|
||||||
arry = optState || optName;
|
arry = optState || optName;
|
||||||
// make sure array contains numbers
|
// make sure array contains numbers
|
||||||
$.each(arry, function(i, v){
|
$.each(arry, function(i, v) {
|
||||||
arry[i] = parseInt(v, 10);
|
arry[i] = parseInt(v, 10);
|
||||||
});
|
});
|
||||||
for (i = 0; i < c.columns; i++) {
|
for (i = 0; i < c.columns; i++) {
|
||||||
@ -229,7 +233,7 @@
|
|||||||
.attr('data-column', 'auto')
|
.attr('data-column', 'auto')
|
||||||
.prop('checked', colSel.auto)
|
.prop('checked', colSel.auto)
|
||||||
.toggleClass( wo.columnSelector_cssChecked, colSel.auto )
|
.toggleClass( wo.columnSelector_cssChecked, colSel.auto )
|
||||||
.on('change', function(){
|
.on('change', function() {
|
||||||
tsColSel.updateAuto(c, wo, $(this));
|
tsColSel.updateAuto(c, wo, $(this));
|
||||||
}).change();
|
}).change();
|
||||||
}
|
}
|
||||||
@ -243,7 +247,7 @@
|
|||||||
updateAuto: function(c, wo, $el) {
|
updateAuto: function(c, wo, $el) {
|
||||||
var colSel = c.selector;
|
var colSel = c.selector;
|
||||||
colSel.auto = $el.prop('checked') || false;
|
colSel.auto = $el.prop('checked') || false;
|
||||||
$.each( colSel.$checkbox, function(i, $cb){
|
$.each( colSel.$checkbox, function(i, $cb) {
|
||||||
if ($cb) {
|
if ($cb) {
|
||||||
$cb[0].disabled = colSel.auto;
|
$cb[0].disabled = colSel.auto;
|
||||||
colSel.$wrapper[i].toggleClass('disabled', colSel.auto);
|
colSel.$wrapper[i].toggleClass('disabled', colSel.auto);
|
||||||
@ -257,7 +261,7 @@
|
|||||||
if (c.selector.$popup) {
|
if (c.selector.$popup) {
|
||||||
c.selector.$popup.find('.tablesorter-column-selector')
|
c.selector.$popup.find('.tablesorter-column-selector')
|
||||||
.html( colSel.$container.html() )
|
.html( colSel.$container.html() )
|
||||||
.find('input').each(function(){
|
.find('input').each(function() {
|
||||||
var indx = $(this).attr('data-column');
|
var indx = $(this).attr('data-column');
|
||||||
$(this).prop( 'checked', indx === 'auto' ? colSel.auto : colSel.states[indx] );
|
$(this).prop( 'checked', indx === 'auto' ? colSel.auto : colSel.states[indx] );
|
||||||
});
|
});
|
||||||
@ -306,10 +310,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// only 6 breakpoints (same as jQuery Mobile)
|
// 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 */
|
/*jshint loopfunc:true */
|
||||||
breaks = [];
|
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;
|
column = parseInt($(this).attr('data-column'), 10) + 1;
|
||||||
// don't reveal columnSelector false columns
|
// don't reveal columnSelector false columns
|
||||||
if ( !isHidden[ column ] ) {
|
if ( !isHidden[ column ] ) {
|
||||||
@ -340,14 +344,14 @@
|
|||||||
colSel = c.selector,
|
colSel = c.selector,
|
||||||
styles = [],
|
styles = [],
|
||||||
prefix = c.namespace + 'columnselector';
|
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) {
|
if (!this.checked) {
|
||||||
column = parseInt( $(this).attr('data-column'), 10 ) + 1;
|
column = parseInt( $(this).attr('data-column'), 10 ) + 1;
|
||||||
styles = styles.concat( tsColSel.addSelectors( wo, prefix, column ) );
|
styles = styles.concat( tsColSel.addSelectors( wo, prefix, column ) );
|
||||||
}
|
}
|
||||||
$(this).toggleClass( wo.columnSelector_cssChecked, this.checked );
|
$(this).toggleClass( wo.columnSelector_cssChecked, this.checked );
|
||||||
});
|
});
|
||||||
if (wo.columnSelector_mediaquery){
|
if (wo.columnSelector_mediaquery) {
|
||||||
colSel.$breakpoints.prop('disabled', true);
|
colSel.$breakpoints.prop('disabled', true);
|
||||||
}
|
}
|
||||||
if (colSel.$style) {
|
if (colSel.$style) {
|
||||||
@ -451,7 +455,7 @@
|
|||||||
wo = c.widgetOptions;
|
wo = c.widgetOptions;
|
||||||
$popup.find('.tablesorter-column-selector')
|
$popup.find('.tablesorter-column-selector')
|
||||||
.html( colSel.$container.html() )
|
.html( colSel.$container.html() )
|
||||||
.find('input').each(function(){
|
.find('input').each(function() {
|
||||||
var indx = $(this).attr('data-column'),
|
var indx = $(this).attr('data-column'),
|
||||||
isChecked = indx === 'auto' ? colSel.auto : colSel.states[indx];
|
isChecked = indx === 'auto' ? colSel.auto : colSel.states[indx];
|
||||||
$(this)
|
$(this)
|
||||||
@ -503,7 +507,7 @@
|
|||||||
// container layout
|
// container layout
|
||||||
columnSelector_layout : '<label><input type="checkbox">{name}</label>',
|
columnSelector_layout : '<label><input type="checkbox">{name}</label>',
|
||||||
// layout customizer callback called for each column
|
// 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,
|
columnSelector_layoutCustomizer : null,
|
||||||
// data attribute containing column name to use in the selector container
|
// data attribute containing column name to use in the selector container
|
||||||
columnSelector_name : 'data-selector-name',
|
columnSelector_name : 'data-selector-name',
|
||||||
|
@ -627,6 +627,9 @@
|
|||||||
c.lastSearch = c.$table.data( 'lastSearch' );
|
c.lastSearch = c.$table.data( 'lastSearch' );
|
||||||
c.$table.triggerHandler( 'filterInit', c );
|
c.$table.triggerHandler( 'filterInit', c );
|
||||||
tsf.findRows( c.table, c.lastSearch || [] );
|
tsf.findRows( c.table, c.lastSearch || [] );
|
||||||
|
if (ts.debug(c, 'filter')) {
|
||||||
|
console.log('Filter >> Widget initialized');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
if ( $.isEmptyObject( wo.filter_formatter ) ) {
|
if ( $.isEmptyObject( wo.filter_formatter ) ) {
|
||||||
completed();
|
completed();
|
||||||
@ -1327,6 +1330,7 @@
|
|||||||
storedFilters = $.extend( [], filters ),
|
storedFilters = $.extend( [], filters ),
|
||||||
c = table.config,
|
c = table.config,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
|
debug = ts.debug(c, 'filter'),
|
||||||
// data object passed to filters; anyMatch is a flag for the filters
|
// data object passed to filters; anyMatch is a flag for the filters
|
||||||
data = {
|
data = {
|
||||||
anyMatch: false,
|
anyMatch: false,
|
||||||
@ -1343,7 +1347,6 @@
|
|||||||
defaultColFilter : [],
|
defaultColFilter : [],
|
||||||
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
|
defaultAnyFilter : ts.getColumnData( table, wo.filter_defaultFilter, c.columns, true ) || ''
|
||||||
};
|
};
|
||||||
|
|
||||||
// parse columns after formatter, in case the class is added at that point
|
// parse columns after formatter, in case the class is added at that point
|
||||||
data.parsed = [];
|
data.parsed = [];
|
||||||
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
|
for ( columnIndex = 0; columnIndex < c.columns; columnIndex++ ) {
|
||||||
@ -1365,8 +1368,8 @@
|
|||||||
( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split( /\s+/ );
|
( ts.getColumnData( table, wo.filter_excludeFilter, columnIndex, true ) || '' ).split( /\s+/ );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Filter: Starting filter widget search', filters );
|
console.log( 'Filter >> Starting filter widget search', filters );
|
||||||
time = new Date();
|
time = new Date();
|
||||||
}
|
}
|
||||||
// filtered rows count
|
// filtered rows count
|
||||||
@ -1464,8 +1467,8 @@
|
|||||||
notFiltered = $rows.not( '.' + wo.filter_filteredRow ).length;
|
notFiltered = $rows.not( '.' + wo.filter_filteredRow ).length;
|
||||||
// can't search when all rows are hidden - this happens when looking for exact matches
|
// can't search when all rows are hidden - this happens when looking for exact matches
|
||||||
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
|
if ( searchFiltered && notFiltered === 0 ) { searchFiltered = false; }
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Filter: Searching through ' +
|
console.log( 'Filter >> Searching through ' +
|
||||||
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
|
( searchFiltered && notFiltered < len ? notFiltered : 'all' ) + ' rows' );
|
||||||
}
|
}
|
||||||
if ( data.anyMatchFlag ) {
|
if ( data.anyMatchFlag ) {
|
||||||
@ -1568,8 +1571,8 @@
|
|||||||
if ( wo.filter_saveFilters && ts.storage ) {
|
if ( wo.filter_saveFilters && ts.storage ) {
|
||||||
ts.storage( table, 'tablesorter-filters', tsf.processFilters( storedFilters, true ) );
|
ts.storage( table, 'tablesorter-filters', tsf.processFilters( storedFilters, true ) );
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Completed filter widget search' + ts.benchmark(time) );
|
console.log( 'Filter >> Completed search' + ts.benchmark(time) );
|
||||||
}
|
}
|
||||||
if ( wo.filter_initialized ) {
|
if ( wo.filter_initialized ) {
|
||||||
c.$table.triggerHandler( 'filterBeforeEnd', c );
|
c.$table.triggerHandler( 'filterBeforeEnd', c );
|
||||||
|
@ -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+
|
/* Requires tablesorter v2.8+ and jQuery 1.7+
|
||||||
* by Rob Garrison
|
* by Rob Garrison
|
||||||
*/
|
*/
|
||||||
/*jshint browser:true, jquery:true, unused:false */
|
/*jshint browser:true, jquery:true, unused:false */
|
||||||
;(function($){
|
;(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var tsp,
|
var tsp,
|
||||||
ts = $.tablesorter;
|
ts = $.tablesorter;
|
||||||
@ -66,7 +66,7 @@
|
|||||||
pager_customAjaxUrl: function( table, url ) { return url; },
|
pager_customAjaxUrl: function( table, url ) { return url; },
|
||||||
|
|
||||||
// ajax error callback from $.tablesorter.showError function
|
// 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
|
// returning false will abort the error message
|
||||||
pager_ajaxError: null,
|
pager_ajaxError: null,
|
||||||
|
|
||||||
@ -91,7 +91,7 @@
|
|||||||
// ],
|
// ],
|
||||||
// [ "header1", "header2", ... "headerN" ] // optional
|
// [ "header1", "header2", ... "headerN" ] // optional
|
||||||
// ]
|
// ]
|
||||||
pager_ajaxProcessing: function( ajax ){ return [ 0, [], null ]; },
|
pager_ajaxProcessing: function( /* ajax */ ) { return [ 0, [], null ]; },
|
||||||
|
|
||||||
// css class names of pager arrows
|
// css class names of pager arrows
|
||||||
pager_css: {
|
pager_css: {
|
||||||
@ -162,8 +162,8 @@
|
|||||||
if ( p.isInitializing ) { return; }
|
if ( p.isInitializing ) { return; }
|
||||||
|
|
||||||
p.isInitializing = true;
|
p.isInitializing = true;
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'pager') ) {
|
||||||
console.log( 'Pager: Initializing' );
|
console.log( 'Pager >> Initializing' );
|
||||||
}
|
}
|
||||||
|
|
||||||
p.size = $.data( table, 'pagerLastSize' ) || wo.pager_size;
|
p.size = $.data( table, 'pagerLastSize' ) || wo.pager_size;
|
||||||
@ -227,8 +227,8 @@
|
|||||||
p.initializing = false;
|
p.initializing = false;
|
||||||
p.isInitializing = false;
|
p.isInitializing = false;
|
||||||
tsp.setPageSize( c, p.size ); // page size 0 is ignored
|
tsp.setPageSize( c, p.size ); // page size 0 is ignored
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'pager') ) {
|
||||||
console.log( 'Pager: Triggering pagerInitialized' );
|
console.log( 'Pager >> Triggering pagerInitialized' );
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler( 'pagerInitialized', c );
|
c.$table.triggerHandler( 'pagerInitialized', c );
|
||||||
// filter widget not initialized; it will update the output display & fire off the pagerComplete event
|
// filter widget not initialized; it will update the output display & fire off the pagerComplete event
|
||||||
@ -243,7 +243,8 @@
|
|||||||
p = c.pager,
|
p = c.pager,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
namespace = c.namespace + 'pager',
|
namespace = c.namespace + 'pager',
|
||||||
s = wo.pager_selectors;
|
s = wo.pager_selectors,
|
||||||
|
debug = ts.debug(c, 'pager');
|
||||||
c.$table
|
c.$table
|
||||||
.off( namespace )
|
.off( namespace )
|
||||||
.on( 'filterInit filterStart '.split( ' ' ).join( namespace + ' ' ), function( e, filters ) {
|
.on( 'filterInit filterStart '.split( ' ' ).join( namespace + ' ' ), function( e, filters ) {
|
||||||
@ -284,7 +285,7 @@
|
|||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
tsp.enablePager( c, true );
|
tsp.enablePager( c, true );
|
||||||
})
|
})
|
||||||
.on( 'destroyPager' + namespace, function( e, refreshing ) {
|
.on( 'destroyPager' + namespace, function( e ) {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// call removeWidget to make sure internal flags are modified.
|
// call removeWidget to make sure internal flags are modified.
|
||||||
ts.removeWidget( c.table, 'pager', false );
|
ts.removeWidget( c.table, 'pager', false );
|
||||||
@ -343,8 +344,8 @@
|
|||||||
// clicked controls
|
// clicked controls
|
||||||
ctrls = [ s.first, s.prev, s.next, s.last ];
|
ctrls = [ s.first, s.prev, s.next, s.last ];
|
||||||
fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
|
fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
|
||||||
if ( c.debug && !p.$container.length ) {
|
if ( debug && !p.$container.length ) {
|
||||||
console.warn( 'Pager: >> Container not found' );
|
console.warn( 'Pager >> "container" not found' );
|
||||||
}
|
}
|
||||||
p.$container.find( ctrls.join( ',' ) )
|
p.$container.find( ctrls.join( ',' ) )
|
||||||
.attr( 'tabindex', 0 )
|
.attr( 'tabindex', 0 )
|
||||||
@ -373,8 +374,8 @@
|
|||||||
tsp.moveToPage( c, p, true );
|
tsp.moveToPage( c, p, true );
|
||||||
tsp.updatePageDisplay( c, false );
|
tsp.updatePageDisplay( c, false );
|
||||||
});
|
});
|
||||||
} else if ( c.debug ) {
|
} else if ( debug ) {
|
||||||
console.warn( 'Pager: >> Goto selector not found' );
|
console.warn( 'Pager >> "goto" selector not found' );
|
||||||
}
|
}
|
||||||
|
|
||||||
tmp = p.$container.find( wo.pager_selectors.pageSize );
|
tmp = p.$container.find( wo.pager_selectors.pageSize );
|
||||||
@ -394,8 +395,8 @@
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
} else if ( c.debug ) {
|
} else if ( debug ) {
|
||||||
console.warn('Pager: >> Size selector not found');
|
console.warn('Pager >> "size" selector not found');
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
@ -532,8 +533,8 @@
|
|||||||
tsp.pagerArrows( c );
|
tsp.pagerArrows( c );
|
||||||
tsp.fixHeight( c );
|
tsp.fixHeight( c );
|
||||||
if ( p.initialized && completed !== false ) {
|
if ( p.initialized && completed !== false ) {
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'pager') ) {
|
||||||
console.log( 'Pager: Triggering pagerComplete' );
|
console.log( 'Pager >> Triggering pagerComplete' );
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler( 'pagerComplete', c );
|
c.$table.triggerHandler( 'pagerComplete', c );
|
||||||
// save pager info to storage
|
// save pager info to storage
|
||||||
@ -655,7 +656,6 @@
|
|||||||
hideRows: function( c ) {
|
hideRows: function( c ) {
|
||||||
if ( !c.widgetOptions.pager_ajaxUrl ) {
|
if ( !c.widgetOptions.pager_ajaxUrl ) {
|
||||||
var tbodyIndex, rowIndex, $rows, len, lastIndex,
|
var tbodyIndex, rowIndex, $rows, len, lastIndex,
|
||||||
table = c.table,
|
|
||||||
p = c.pager,
|
p = c.pager,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
tbodyLen = c.$tbodies.length,
|
tbodyLen = c.$tbodies.length,
|
||||||
@ -721,7 +721,8 @@
|
|||||||
renderAjax: function( data, c, xhr, settings, exception ) {
|
renderAjax: function( data, c, xhr, settings, exception ) {
|
||||||
var table = c.table,
|
var table = c.table,
|
||||||
p = c.pager,
|
p = c.pager,
|
||||||
wo = c.widgetOptions;
|
wo = c.widgetOptions,
|
||||||
|
debug = ts.debug(c, 'pager');
|
||||||
// process data
|
// process data
|
||||||
if ( $.isFunction( wo.pager_ajaxProcessing ) ) {
|
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,
|
var i, j, t, hsh, $f, $sh, $headers, $h, icon, th, d, l, rr_count, len, sz,
|
||||||
$table = c.$table,
|
$table = c.$table,
|
||||||
tds = '',
|
tds = '',
|
||||||
result = wo.pager_ajaxProcessing( data, table, xhr ) || [ 0, [] ],
|
result = wo.pager_ajaxProcessing( data, table, xhr ) || [ 0, [] ];
|
||||||
hl = $table.find( 'thead th' ).length;
|
|
||||||
|
|
||||||
// Clean up any previous error.
|
// Clean up any previous error.
|
||||||
ts.showError( table );
|
ts.showError( table );
|
||||||
|
|
||||||
if ( exception ) {
|
if ( exception ) {
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.error( 'Pager: >> Ajax Error', xhr, settings, exception );
|
console.error( 'Pager >> Ajax Error', xhr, settings, exception );
|
||||||
}
|
}
|
||||||
ts.showError( table, xhr, settings, exception );
|
ts.showError( table, xhr, settings, exception );
|
||||||
c.$tbodies.eq( 0 ).children( 'tr' ).detach();
|
c.$tbodies.eq( 0 ).children( 'tr' ).detach();
|
||||||
@ -846,8 +846,8 @@
|
|||||||
// apply widgets after table has rendered & after a delay to prevent
|
// apply widgets after table has rendered & after a delay to prevent
|
||||||
// multiple applyWidget blocking code from blocking this trigger
|
// multiple applyWidget blocking code from blocking this trigger
|
||||||
setTimeout( function() {
|
setTimeout( function() {
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Pager: Triggering pagerChange' );
|
console.log( 'Pager >> Triggering pagerChange' );
|
||||||
}
|
}
|
||||||
$table.triggerHandler( 'pagerChange', p );
|
$table.triggerHandler( 'pagerChange', p );
|
||||||
ts.applyWidget( table );
|
ts.applyWidget( table );
|
||||||
@ -889,8 +889,8 @@
|
|||||||
p.oldAjaxSuccess( data );
|
p.oldAjaxSuccess( data );
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'pager') ) {
|
||||||
console.log( 'Pager: Ajax initialized', p.ajaxObject );
|
console.log( 'Pager >> Ajax initialized', p.ajaxObject );
|
||||||
}
|
}
|
||||||
$.ajax( p.ajaxObject );
|
$.ajax( p.ajaxObject );
|
||||||
}
|
}
|
||||||
@ -935,8 +935,8 @@
|
|||||||
if ( $.isFunction( wo.pager_customAjaxUrl ) ) {
|
if ( $.isFunction( wo.pager_customAjaxUrl ) ) {
|
||||||
url = wo.pager_customAjaxUrl( c.table, url );
|
url = wo.pager_customAjaxUrl( c.table, url );
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'pager') ) {
|
||||||
console.log( 'Pager: Ajax url = ' + url );
|
console.log( 'Pager >> Ajax url = ' + url );
|
||||||
}
|
}
|
||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
@ -946,13 +946,14 @@
|
|||||||
table = c.table,
|
table = c.table,
|
||||||
p = c.pager,
|
p = c.pager,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
|
debug = ts.debug(c, 'pager'),
|
||||||
f = c.$table.hasClass('hasFilters'),
|
f = c.$table.hasClass('hasFilters'),
|
||||||
l = rows && rows.length || 0, // rows may be undefined
|
l = rows && rows.length || 0, // rows may be undefined
|
||||||
e = p.size === 'all' ? p.totalRows : p.size,
|
e = p.size === 'all' ? p.totalRows : p.size,
|
||||||
s = ( p.page * e );
|
s = ( p.page * e );
|
||||||
if ( l < 1 ) {
|
if ( l < 1 ) {
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.warn( 'Pager: >> No rows for pager to render' );
|
console.warn( 'Pager >> No rows for pager to render' );
|
||||||
}
|
}
|
||||||
// empty table, abort!
|
// empty table, abort!
|
||||||
return;
|
return;
|
||||||
@ -964,8 +965,8 @@
|
|||||||
p.cacheIndex = [];
|
p.cacheIndex = [];
|
||||||
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
||||||
if ( p.initialized ) {
|
if ( p.initialized ) {
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Pager: Triggering pagerChange' );
|
console.log( 'Pager >> Triggering pagerChange' );
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler( 'pagerChange', c );
|
c.$table.triggerHandler( 'pagerChange', c );
|
||||||
}
|
}
|
||||||
@ -997,8 +998,8 @@
|
|||||||
wo.pager_startPage = p.page;
|
wo.pager_startPage = p.page;
|
||||||
wo.pager_size = p.size;
|
wo.pager_size = p.size;
|
||||||
if ( table.isUpdating ) {
|
if ( table.isUpdating ) {
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Pager: Triggering updateComplete' );
|
console.log( 'Pager >> Triggering updateComplete' );
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler( 'updateComplete', [ table, true ] );
|
c.$table.triggerHandler( 'updateComplete', [ table, true ] );
|
||||||
}
|
}
|
||||||
@ -1026,8 +1027,8 @@
|
|||||||
tsp.renderTable( c, c.rowsCopy );
|
tsp.renderTable( c, c.rowsCopy );
|
||||||
p.isDisabled = true;
|
p.isDisabled = true;
|
||||||
ts.applyWidget( table );
|
ts.applyWidget( table );
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'pager') ) {
|
||||||
console.log( 'Pager: Disabled' );
|
console.log( 'Pager >> Disabled' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// disable size selector
|
// disable size selector
|
||||||
@ -1074,14 +1075,14 @@
|
|||||||
var tmp,
|
var tmp,
|
||||||
table = c.table,
|
table = c.table,
|
||||||
wo = c.widgetOptions,
|
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
|
// abort page move if the table has filters and has not been initialized
|
||||||
if ( p.ajax && !wo.filter_initialized && ts.hasWidget( table, 'filter' ) ) { return; }
|
if ( p.ajax && !wo.filter_initialized && ts.hasWidget( table, 'filter' ) ) { return; }
|
||||||
|
|
||||||
tsp.parsePageNumber( c, p );
|
tsp.parsePageNumber( c, p );
|
||||||
tsp.calcFilters( c );
|
tsp.calcFilters( c );
|
||||||
|
|
||||||
// fixes issue where one current filter is [] and the other is [ '', '', '' ],
|
// fixes issue where one current filter is [] and the other is [ '', '', '' ],
|
||||||
// making the next if comparison think the filters as different. Fixes #202.
|
// making the next if comparison think the filters as different. Fixes #202.
|
||||||
l.currentFilters = ( l.currentFilters || [] ).join( '' ) === '' ? [] : l.currentFilters;
|
l.currentFilters = ( l.currentFilters || [] ).join( '' ) === '' ? [] : l.currentFilters;
|
||||||
@ -1096,8 +1097,8 @@
|
|||||||
l.sortList === ( c.sortList || [] ).join( ',' ) ) {
|
l.sortList === ( c.sortList || [] ).join( ',' ) ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Pager: Changing to page ' + p.page );
|
console.log( 'Pager >> Changing to page ' + p.page );
|
||||||
}
|
}
|
||||||
p.last = {
|
p.last = {
|
||||||
page: p.page,
|
page: p.page,
|
||||||
@ -1114,9 +1115,9 @@
|
|||||||
wo.pager_processAjaxOnInit = true;
|
wo.pager_processAjaxOnInit = true;
|
||||||
tmp = wo.pager_initialRows;
|
tmp = wo.pager_initialRows;
|
||||||
p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total :
|
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 :
|
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 );
|
tsp.updatePageDisplay( c, false );
|
||||||
} else {
|
} else {
|
||||||
tsp.getAjax( c );
|
tsp.getAjax( c );
|
||||||
@ -1126,14 +1127,14 @@
|
|||||||
}
|
}
|
||||||
$.data( table, 'pagerLastPage', p.page );
|
$.data( table, 'pagerLastPage', p.page );
|
||||||
if ( p.initialized && pageMoved !== false ) {
|
if ( p.initialized && pageMoved !== false ) {
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Pager: Triggering pageMoved' );
|
console.log( 'Pager >> Triggering pageMoved' );
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler( 'pageMoved', c );
|
c.$table.triggerHandler( 'pageMoved', c );
|
||||||
ts.applyWidget( table );
|
ts.applyWidget( table );
|
||||||
if ( !p.ajax && table.isUpdating ) {
|
if ( !p.ajax && table.isUpdating ) {
|
||||||
if ( c.debug ) {
|
if ( debug ) {
|
||||||
console.log( 'Pager: Triggering updateComplete' );
|
console.log( 'Pager >> Triggering updateComplete' );
|
||||||
}
|
}
|
||||||
c.$table.triggerHandler( 'updateComplete', [ table, true ] );
|
c.$table.triggerHandler( 'updateComplete', [ table, true ] );
|
||||||
}
|
}
|
||||||
@ -1269,8 +1270,8 @@
|
|||||||
tsp.setPageSize( c, p.size );
|
tsp.setPageSize( c, p.size );
|
||||||
tsp.moveToPage( c, p, true );
|
tsp.moveToPage( c, p, true );
|
||||||
tsp.hideRowsSetup( c );
|
tsp.hideRowsSetup( c );
|
||||||
if ( c.debug ) {
|
if ( ts.debug(c, 'pager') ) {
|
||||||
console.log( 'Pager: Enabled' );
|
console.log( 'Pager >> Enabled' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -1296,8 +1297,7 @@
|
|||||||
|
|
||||||
// see #486
|
// see #486
|
||||||
ts.showError = function( table, xhr, settings, exception ) {
|
ts.showError = function( table, xhr, settings, exception ) {
|
||||||
var $row,
|
var $table = $( table ),
|
||||||
$table = $( table ),
|
|
||||||
c = $table[ 0 ].config,
|
c = $table[ 0 ].config,
|
||||||
wo = c && c.widgetOptions,
|
wo = c && c.widgetOptions,
|
||||||
errorRow = c.pager && c.pager.cssErrorRow ||
|
errorRow = c.pager && c.pager.cssErrorRow ||
|
||||||
|
@ -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+
|
* Requires tablesorter v2.16+
|
||||||
* by Rob Garrison
|
* by Rob Garrison
|
||||||
*/
|
*/
|
||||||
@ -6,6 +6,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var ts = $.tablesorter || {};
|
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
|
// this widget saves the last sort only if the
|
||||||
// saveSort widget option is true AND the
|
// saveSort widget option is true AND the
|
||||||
// $.tablesorter.storage function is included
|
// $.tablesorter.storage function is included
|
||||||
@ -21,18 +30,19 @@
|
|||||||
thisWidget.format(table, c, wo, true);
|
thisWidget.format(table, c, wo, true);
|
||||||
},
|
},
|
||||||
format: function(table, c, wo, init) {
|
format: function(table, c, wo, init) {
|
||||||
var stored, time,
|
var time,
|
||||||
$table = c.$table,
|
$table = c.$table,
|
||||||
saveSort = wo.saveSort !== false, // make saveSort active/inactive; default to true
|
saveSort = wo.saveSort !== false, // make saveSort active/inactive; default to true
|
||||||
sortList = { 'sortList' : c.sortList };
|
sortList = { 'sortList' : c.sortList },
|
||||||
if (c.debug) {
|
debug = ts.debug(c, 'saveSort');
|
||||||
|
if (debug) {
|
||||||
time = new Date();
|
time = new Date();
|
||||||
}
|
}
|
||||||
if ($table.hasClass('hasSaveSort')) {
|
if ($table.hasClass('hasSaveSort')) {
|
||||||
if (saveSort && table.hasInitialized && ts.storage) {
|
if (saveSort && table.hasInitialized && ts.storage && sortListChanged(c)) {
|
||||||
ts.storage( table, 'tablesorter-savesort', sortList );
|
ts.storage( table, 'tablesorter-savesort', sortList );
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('saveSort widget: Saving last sort: ' + c.sortList + ts.benchmark(time));
|
console.log('saveSort >> Saving last sort: ' + c.sortList + ts.benchmark(time));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -41,10 +51,9 @@
|
|||||||
sortList = '';
|
sortList = '';
|
||||||
// get data
|
// get data
|
||||||
if (ts.storage) {
|
if (ts.storage) {
|
||||||
stored = ts.storage( table, 'tablesorter-savesort' );
|
sortList = getStoredSortList(c);
|
||||||
sortList = (stored && stored.hasOwnProperty('sortList') && $.isArray(stored.sortList)) ? stored.sortList : '';
|
if (debug) {
|
||||||
if (c.debug) {
|
console.log('saveSort >> Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
|
||||||
console.log('saveSort: Last sort loaded: "' + sortList + '"' + ts.benchmark(time));
|
|
||||||
}
|
}
|
||||||
$table.bind('saveSortReset', function(event) {
|
$table.bind('saveSortReset', function(event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
@ -57,7 +66,9 @@
|
|||||||
c.sortList = sortList;
|
c.sortList = sortList;
|
||||||
} else if (table.hasInitialized && sortList && sortList.length > 0) {
|
} else if (table.hasInitialized && sortList && sortList.length > 0) {
|
||||||
// update sort change
|
// update sort change
|
||||||
ts.sortOn( c, sortList );
|
if (sortListChanged(c, sortList)) {
|
||||||
|
ts.sortOn(c, sortList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -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 */
|
/*global JSON:false */
|
||||||
;(function ($, window, document) {
|
;(function ($, window, document) {
|
||||||
'use strict';
|
'use strict';
|
||||||
@ -44,6 +44,7 @@
|
|||||||
values = {},
|
values = {},
|
||||||
c = table.config,
|
c = table.config,
|
||||||
wo = c && c.widgetOptions,
|
wo = c && c.widgetOptions,
|
||||||
|
debug = ts.debug(c, 'storage'),
|
||||||
storageType = (
|
storageType = (
|
||||||
( options && options.storageType ) || ( wo && wo.storage_storageType )
|
( options && options.storageType ) || ( wo && wo.storage_storageType )
|
||||||
).toString().charAt(0).toLowerCase(),
|
).toString().charAt(0).toLowerCase(),
|
||||||
@ -72,14 +73,12 @@
|
|||||||
hasStorage = true;
|
hasStorage = true;
|
||||||
window[storageType].removeItem('_tmptest');
|
window[storageType].removeItem('_tmptest');
|
||||||
} catch (error) {
|
} 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) {
|
if (debug) {
|
||||||
console.log('Storage widget using', hasStorage ? storageType : 'cookies');
|
console.log('Storage >> Using', hasStorage ? storageType : 'cookies');
|
||||||
}
|
}
|
||||||
// *** get value ***
|
// *** get value ***
|
||||||
if ($.parseJSON) {
|
if ($.parseJSON) {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/*! Widget: uitheme - updated 9/27/2017 (v2.29.0) */
|
/*! Widget: uitheme - updated 2018-03-17 (v2.30.0) */
|
||||||
;(function ($) {
|
;(function ($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
var ts = $.tablesorter || {};
|
var ts = $.tablesorter || {};
|
||||||
@ -63,8 +63,9 @@
|
|||||||
theme = c.theme || 'jui',
|
theme = c.theme || 'jui',
|
||||||
themes = themesAll[theme] || {},
|
themes = themesAll[theme] || {},
|
||||||
remove = $.trim( [ themes.sortNone, themes.sortDesc, themes.sortAsc, themes.active ].join( ' ' ) ),
|
remove = $.trim( [ themes.sortNone, themes.sortDesc, themes.sortAsc, themes.active ].join( ' ' ) ),
|
||||||
iconRmv = $.trim( [ themes.iconSortNone, themes.iconSortDesc, themes.iconSortAsc ].join( ' ' ) );
|
iconRmv = $.trim( [ themes.iconSortNone, themes.iconSortDesc, themes.iconSortAsc ].join( ' ' ) ),
|
||||||
if (c.debug) { time = new Date(); }
|
debug = ts.debug(c, 'uitheme');
|
||||||
|
if (debug) { time = new Date(); }
|
||||||
// initialization code - run once
|
// initialization code - run once
|
||||||
if (!$table.hasClass('tablesorter-' + theme) || c.theme !== c.appliedTheme || !wo.uitheme_applied) {
|
if (!$table.hasClass('tablesorter-' + theme) || c.theme !== c.appliedTheme || !wo.uitheme_applied) {
|
||||||
wo.uitheme_applied = true;
|
wo.uitheme_applied = true;
|
||||||
@ -109,7 +110,7 @@
|
|||||||
$(this)[ event.type === 'mouseenter' ? 'addClass' : 'removeClass' ](themes.hover || '');
|
$(this)[ event.type === 'mouseenter' ? 'addClass' : 'removeClass' ](themes.hover || '');
|
||||||
});
|
});
|
||||||
|
|
||||||
$headers.each(function(){
|
$headers.each(function() {
|
||||||
var $this = $(this);
|
var $this = $(this);
|
||||||
if (!$this.find('.' + ts.css.wrapper).length) {
|
if (!$this.find('.' + ts.css.wrapper).length) {
|
||||||
// Firefox needs this inner div to position the icon & resizer correctly
|
// Firefox needs this inner div to position the icon & resizer correctly
|
||||||
@ -167,8 +168,8 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (c.debug) {
|
if (debug) {
|
||||||
console.log('Applying ' + theme + ' theme' + ts.benchmark(time));
|
console.log('uitheme >> Applied ' + theme + ' theme' + ts.benchmark(time));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
remove: function(table, c, wo, refreshing) {
|
remove: function(table, c, wo, refreshing) {
|
||||||
|
Loading…
Reference in New Issue
Block a user