2014-12-23 03:12:59 +00:00
|
|
|
/* Pager widget for TableSorter 12/22/2014 (v2.18.4) - requires jQuery 1.7+ */
|
2013-10-18 03:59:07 +00:00
|
|
|
/*jshint browser:true, jquery:true, unused:false */
|
|
|
|
;(function($){
|
|
|
|
"use strict";
|
|
|
|
var tsp,
|
|
|
|
ts = $.tablesorter;
|
|
|
|
|
|
|
|
ts.addWidget({
|
|
|
|
id: "pager",
|
2013-11-09 05:49:30 +00:00
|
|
|
priority: 55, // load pager after filter widget
|
2013-10-18 03:59:07 +00:00
|
|
|
options : {
|
|
|
|
// output default: '{page}/{totalPages}'
|
|
|
|
// possible variables: {page}, {totalPages}, {filteredPages}, {startRow}, {endRow}, {filteredRows} and {totalRows}
|
|
|
|
pager_output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
|
|
|
|
|
|
|
|
// apply disabled classname to the pager arrows when the rows at either extreme is visible
|
|
|
|
pager_updateArrows: true,
|
|
|
|
|
|
|
|
// starting page of the pager (zero based index)
|
|
|
|
pager_startPage: 0,
|
|
|
|
|
2014-04-20 06:59:23 +00:00
|
|
|
// reset pager after filtering; set to desired page #
|
|
|
|
// set to false to not change page at filter start
|
|
|
|
pager_pageReset: 0,
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
// Number of visible rows
|
|
|
|
pager_size: 10,
|
|
|
|
|
2014-09-17 06:45:27 +00:00
|
|
|
// Number of options to include in the pager number selector
|
|
|
|
pager_maxOptionSize: 20,
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
// Save pager page & size if the storage script is loaded (requires $.tablesorter.storage in jquery.tablesorter.widgets.js)
|
|
|
|
pager_savePages: true,
|
|
|
|
|
2014-01-16 23:16:56 +00:00
|
|
|
//defines custom storage key
|
|
|
|
pager_storageKey: 'tablesorter-pager',
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
// if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
|
|
|
|
// table row set to a height to compensate; default is false
|
|
|
|
pager_fixedHeight: false,
|
|
|
|
|
2013-10-30 21:56:08 +00:00
|
|
|
// count child rows towards the set page size? (set true if it is a visible table row within the pager)
|
|
|
|
// if true, child row(s) may not appear to be attached to its parent row, may be split across pages or
|
|
|
|
// may distort the table if rowspan or cellspans are included.
|
|
|
|
pager_countChildRows: false,
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
// remove rows from the table to speed up the sort of large tables.
|
|
|
|
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
|
|
|
|
pager_removeRows: false, // removing rows in larger tables speeds up the sort
|
|
|
|
|
|
|
|
// use this format: "http://mydatabase.com?page={page}&size={size}&{sortList:col}&{filterList:fcol}"
|
|
|
|
// where {page} is replaced by the page number, {size} is replaced by the number of records to show,
|
|
|
|
// {sortList:col} adds the sortList to the url into a "col" array, and {filterList:fcol} adds
|
|
|
|
// the filterList to the url into an "fcol" array.
|
|
|
|
// So a sortList = [[2,0],[3,0]] becomes "&col[2]=0&col[3]=0" in the url
|
|
|
|
// and a filterList = [[2,Blue],[3,13]] becomes "&fcol[2]=Blue&fcol[3]=13" in the url
|
|
|
|
pager_ajaxUrl: null,
|
|
|
|
|
|
|
|
// modify the url after all processing has been applied
|
|
|
|
pager_customAjaxUrl: function(table, url) { return url; },
|
|
|
|
|
|
|
|
// modify the $.ajax object to allow complete control over your ajax requests
|
|
|
|
pager_ajaxObject: {
|
|
|
|
dataType: 'json'
|
|
|
|
},
|
|
|
|
|
2013-12-15 11:07:22 +00:00
|
|
|
// set this to false if you want to block ajax loading on init
|
|
|
|
pager_processAjaxOnInit: true,
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
// process ajax so that the following information is returned:
|
|
|
|
// [ total_rows (number), rows (array of arrays), headers (array; optional) ]
|
|
|
|
// example:
|
|
|
|
// [
|
|
|
|
// 100, // total rows
|
|
|
|
// [
|
|
|
|
// [ "row1cell1", "row1cell2", ... "row1cellN" ],
|
|
|
|
// [ "row2cell1", "row2cell2", ... "row2cellN" ],
|
|
|
|
// ...
|
|
|
|
// [ "rowNcell1", "rowNcell2", ... "rowNcellN" ]
|
|
|
|
// ],
|
|
|
|
// [ "header1", "header2", ... "headerN" ] // optional
|
|
|
|
// ]
|
|
|
|
pager_ajaxProcessing: function(ajax){ return [ 0, [], null ]; },
|
|
|
|
|
|
|
|
// css class names of pager arrows
|
|
|
|
pager_css: {
|
|
|
|
container : 'tablesorter-pager',
|
|
|
|
errorRow : 'tablesorter-errorRow', // error information row (don't include period at beginning)
|
|
|
|
disabled : 'disabled' // class added to arrows @ extremes (i.e. prev/first arrows "disabled" on first page)
|
|
|
|
},
|
|
|
|
|
|
|
|
// jQuery selectors
|
|
|
|
pager_selectors: {
|
|
|
|
container : '.pager', // target the pager markup
|
|
|
|
first : '.first', // go to first page arrow
|
|
|
|
prev : '.prev', // previous page arrow
|
|
|
|
next : '.next', // next page arrow
|
|
|
|
last : '.last', // go to last page arrow
|
2014-06-23 18:01:26 +00:00
|
|
|
gotoPage : '.gotoPage', // go to page selector - select dropdown that sets the current page
|
2013-10-18 03:59:07 +00:00
|
|
|
pageDisplay : '.pagedisplay', // location of where the "output" is displayed
|
|
|
|
pageSize : '.pagesize' // page size selector - select dropdown that sets the "size" option
|
|
|
|
}
|
|
|
|
},
|
|
|
|
init: function(table){
|
|
|
|
tsp.init(table);
|
|
|
|
},
|
|
|
|
// only update to complete sorter initialization
|
|
|
|
format: function(table, c){
|
|
|
|
if (!(c.pager && c.pager.initialized)){
|
|
|
|
return tsp.initComplete(table, c);
|
|
|
|
}
|
|
|
|
tsp.moveToPage(table, c.pager, false);
|
|
|
|
},
|
2013-11-09 05:49:30 +00:00
|
|
|
remove: function(table, c){
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.destroyPager(table, c);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/* pager widget functions */
|
|
|
|
tsp = ts.pager = {
|
|
|
|
|
|
|
|
init: function(table) {
|
|
|
|
// check if tablesorter has initialized
|
|
|
|
if (table.hasInitialized && table.config.pager.initialized) { return; }
|
|
|
|
var t,
|
|
|
|
c = table.config,
|
|
|
|
wo = c.widgetOptions,
|
|
|
|
s = wo.pager_selectors,
|
|
|
|
|
|
|
|
// save pager variables
|
|
|
|
p = c.pager = $.extend({
|
|
|
|
totalPages: 0,
|
|
|
|
filteredRows: 0,
|
|
|
|
filteredPages: 0,
|
|
|
|
currentFilters: [],
|
|
|
|
page: wo.pager_startPage,
|
|
|
|
startRow: 0,
|
|
|
|
endRow: 0,
|
2013-11-27 17:07:52 +00:00
|
|
|
ajaxCounter: 0,
|
2013-10-18 03:59:07 +00:00
|
|
|
$size: null,
|
|
|
|
last: {}
|
|
|
|
}, c.pager);
|
|
|
|
|
2014-02-22 17:17:26 +00:00
|
|
|
// pager initializes multiple times before table has completed initialization
|
|
|
|
if (p.isInitializing) { return; }
|
|
|
|
|
|
|
|
p.isInitializing = true;
|
2013-11-09 05:49:30 +00:00
|
|
|
if (c.debug) {
|
|
|
|
ts.log('Pager initializing');
|
|
|
|
}
|
|
|
|
|
2014-05-22 04:39:55 +00:00
|
|
|
p.size = $.data(table, 'pagerLastSize') || wo.pager_size;
|
2013-10-18 03:59:07 +00:00
|
|
|
// added in case the pager is reinitialized after being destroyed.
|
|
|
|
p.$container = $(s.container).addClass(wo.pager_css.container).show();
|
|
|
|
// goto selector
|
2014-06-23 18:01:26 +00:00
|
|
|
p.$goto = p.$container.find(s.gotoPage); // goto is a reserved word #657
|
2013-10-18 03:59:07 +00:00
|
|
|
// page size selector
|
|
|
|
p.$size = p.$container.find(s.pageSize);
|
2014-10-20 20:44:56 +00:00
|
|
|
p.totalRows = c.$tbodies.eq(0).children('tr').not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow ).length;
|
2014-04-18 16:04:45 +00:00
|
|
|
p.oldAjaxSuccess = p.oldAjaxSuccess || wo.pager_ajaxObject.success;
|
2013-10-18 03:59:07 +00:00
|
|
|
c.appender = tsp.appender;
|
2014-10-31 16:52:25 +00:00
|
|
|
p.initializing = true;
|
2013-10-18 03:59:07 +00:00
|
|
|
if (wo.pager_savePages && ts.storage) {
|
2014-01-16 23:16:56 +00:00
|
|
|
t = ts.storage(table, wo.pager_storageKey) || {}; // fixes #387
|
2013-10-18 03:59:07 +00:00
|
|
|
p.page = isNaN(t.page) ? p.page : t.page;
|
2013-10-18 12:49:57 +00:00
|
|
|
p.size = ( isNaN(t.size) ? p.size : t.size ) || 10;
|
2013-11-09 05:49:30 +00:00
|
|
|
$.data(table, 'pagerLastSize', p.size);
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
2014-04-23 21:09:26 +00:00
|
|
|
|
|
|
|
// skipped rows
|
2014-10-31 01:58:36 +00:00
|
|
|
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
|
2014-04-23 21:09:26 +00:00
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
// clear initialized flag
|
|
|
|
p.initialized = false;
|
|
|
|
// before initialization event
|
|
|
|
c.$table.trigger('pagerBeforeInitialized', c);
|
|
|
|
|
|
|
|
tsp.enablePager(table, c, false);
|
|
|
|
|
2014-09-30 22:17:17 +00:00
|
|
|
// p must have ajaxObject
|
2014-10-02 16:30:39 +00:00
|
|
|
p.ajaxObject = wo.pager_ajaxObject; // $.extend({}, wo.pager_ajaxObject );
|
|
|
|
p.ajaxObject.url = wo.pager_ajaxUrl;
|
2014-09-30 22:17:17 +00:00
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( typeof(wo.pager_ajaxUrl) === 'string' ) {
|
|
|
|
// ajax pager; interact with database
|
|
|
|
p.ajax = true;
|
|
|
|
// When filtering with ajax, allow only custom filtering function, disable default filtering since it will be done server side.
|
|
|
|
wo.filter_serversideFiltering = true;
|
|
|
|
c.serverSideSorting = true;
|
|
|
|
tsp.moveToPage(table, p);
|
|
|
|
} else {
|
|
|
|
p.ajax = false;
|
|
|
|
// Regular pager; all rows stored in memory
|
2014-03-31 10:07:19 +00:00
|
|
|
c.$table.trigger("appendCache", [{}, true]);
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
initComplete: function(table, c){
|
|
|
|
var p = c.pager;
|
|
|
|
tsp.bindEvents(table, c);
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.setPageSize(table, 0, c); // page size 0 is ignored
|
2013-10-18 03:59:07 +00:00
|
|
|
|
2014-11-03 20:44:08 +00:00
|
|
|
if (!p.ajax) {
|
|
|
|
tsp.hideRowsSetup(table, c);
|
|
|
|
}
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
// pager initialized
|
2014-02-23 06:46:34 +00:00
|
|
|
p.initialized = true;
|
2014-10-31 16:52:25 +00:00
|
|
|
p.initializing = false;
|
2014-02-23 06:46:34 +00:00
|
|
|
p.isInitializing = false;
|
2014-10-31 20:18:30 +00:00
|
|
|
c.$table.trigger('pagerInitialized', c);
|
|
|
|
// filter widget not initialized; it will update the output display & fire off the pagerComplete event
|
|
|
|
if ( !( c.widgetOptions.filter_initialized && ts.hasWidget(table, 'filter') ) ) {
|
2014-11-03 18:35:48 +00:00
|
|
|
// if ajax, then don't fire off pagerComplete
|
|
|
|
tsp.updatePageDisplay(table, c, !p.ajax);
|
2014-10-31 20:18:30 +00:00
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
bindEvents: function(table, c){
|
|
|
|
var ctrls, fxn,
|
|
|
|
p = c.pager,
|
|
|
|
wo = c.widgetOptions,
|
|
|
|
s = wo.pager_selectors;
|
|
|
|
|
|
|
|
c.$table
|
2014-10-31 20:18:30 +00:00
|
|
|
.off('filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet '.split(' ').join('.pager '))
|
2014-11-03 18:57:33 +00:00
|
|
|
.on('filterInit.pager filterStart.pager', function(e) {
|
2014-10-31 20:18:30 +00:00
|
|
|
p.currentFilters = c.$table.data('lastSearch');
|
2014-11-03 14:05:22 +00:00
|
|
|
// don't change page if filters are the same (pager updating, etc)
|
2014-11-03 18:57:33 +00:00
|
|
|
if (e.type === 'filterStart' && wo.pager_pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) {
|
2014-04-20 06:59:23 +00:00
|
|
|
p.page = wo.pager_pageReset; // fixes #456 & #565
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
})
|
|
|
|
// update pager after filter widget completes
|
2014-10-02 16:30:39 +00:00
|
|
|
.on('filterEnd.pager sortEnd.pager', function() {
|
2014-11-03 14:05:22 +00:00
|
|
|
p.currentFilters = c.$table.data('lastSearch');
|
2014-10-31 16:52:25 +00:00
|
|
|
if (p.initialized || p.initializing) {
|
2014-07-11 19:51:50 +00:00
|
|
|
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
|
|
|
|
// make sure we have a copy of all table rows once the cache has been built
|
|
|
|
tsp.updateCache(table);
|
|
|
|
}
|
2014-12-23 02:44:29 +00:00
|
|
|
tsp.updatePageDisplay(table, c, false);
|
2014-09-15 20:12:30 +00:00
|
|
|
// tsp.moveToPage(table, p, false); <-- called when applyWidgets is triggered
|
2014-08-12 15:32:52 +00:00
|
|
|
c.$table.trigger('applyWidgets');
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
})
|
2014-10-02 16:30:39 +00:00
|
|
|
.on('disable.pager', function(e){
|
2013-10-18 03:59:07 +00:00
|
|
|
e.stopPropagation();
|
|
|
|
tsp.showAllRows(table, c);
|
|
|
|
})
|
|
|
|
.on('enable.pager', function(e){
|
|
|
|
e.stopPropagation();
|
|
|
|
tsp.enablePager(table, c, true);
|
|
|
|
})
|
|
|
|
.on('destroy.pager', function(e){
|
|
|
|
e.stopPropagation();
|
|
|
|
tsp.destroyPager(table, c);
|
|
|
|
})
|
2014-08-27 15:15:52 +00:00
|
|
|
.on('updateComplete.pager', function(e, table, triggered){
|
2013-10-18 03:59:07 +00:00
|
|
|
e.stopPropagation();
|
2014-08-12 15:32:52 +00:00
|
|
|
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
|
|
|
|
if (!table || triggered) { return; }
|
|
|
|
var $rows = c.$tbodies.eq(0).children('tr').not(c.selectorRemove);
|
2014-10-20 20:44:56 +00:00
|
|
|
p.totalRows = $rows.length - ( wo.pager_countChildRows ? 0 : $rows.filter('.' + c.cssChildRow).length );
|
2014-05-22 04:39:55 +00:00
|
|
|
p.totalPages = Math.ceil( p.totalRows / p.size );
|
2014-08-12 15:32:52 +00:00
|
|
|
if ($rows.length && c.rowsCopy && c.rowsCopy.length === 0) {
|
|
|
|
// make a copy of all table rows once the cache has been built
|
|
|
|
tsp.updateCache(table);
|
|
|
|
}
|
2014-10-09 23:22:10 +00:00
|
|
|
if ( p.page >= p.totalPages ) {
|
|
|
|
tsp.moveToLastPage(table, p);
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.hideRows(table, c);
|
2014-10-09 23:22:10 +00:00
|
|
|
tsp.changeHeight(table, c);
|
|
|
|
tsp.updatePageDisplay(table, c);
|
2014-02-22 17:17:26 +00:00
|
|
|
// make sure widgets are applied - fixes #450
|
|
|
|
c.$table.trigger('applyWidgets');
|
2013-10-18 03:59:07 +00:00
|
|
|
})
|
|
|
|
.on('pageSize.pager', function(e,v){
|
|
|
|
e.stopPropagation();
|
|
|
|
tsp.setPageSize(table, parseInt(v, 10) || 10, c);
|
|
|
|
tsp.hideRows(table, c);
|
|
|
|
tsp.updatePageDisplay(table, c, false);
|
|
|
|
if (p.$size.length) { p.$size.val(p.size); } // twice?
|
|
|
|
})
|
|
|
|
.on('pageSet.pager', function(e,v){
|
|
|
|
e.stopPropagation();
|
|
|
|
p.page = (parseInt(v, 10) || 1) - 1;
|
|
|
|
if (p.$goto.length) { p.$goto.val(c.size); } // twice?
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.updatePageDisplay(table, c, false);
|
|
|
|
});
|
|
|
|
|
|
|
|
// clicked controls
|
|
|
|
ctrls = [ s.first, s.prev, s.next, s.last ];
|
|
|
|
fxn = [ 'moveToFirstPage', 'moveToPrevPage', 'moveToNextPage', 'moveToLastPage' ];
|
|
|
|
p.$container.find(ctrls.join(','))
|
2014-01-11 19:08:37 +00:00
|
|
|
.attr("tabindex", 0)
|
2014-10-02 16:30:39 +00:00
|
|
|
.off('click.pager')
|
|
|
|
.on('click.pager', function(e){
|
2013-11-09 05:49:30 +00:00
|
|
|
e.stopPropagation();
|
2013-10-18 03:59:07 +00:00
|
|
|
var i,
|
|
|
|
$c = $(this),
|
|
|
|
l = ctrls.length;
|
|
|
|
if ( !$c.hasClass(wo.pager_css.disabled) ) {
|
|
|
|
for (i = 0; i < l; i++) {
|
|
|
|
if ($c.is(ctrls[i])) {
|
|
|
|
tsp[fxn[i]](table, p);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if ( p.$goto.length ) {
|
|
|
|
p.$goto
|
2014-10-02 16:30:39 +00:00
|
|
|
.off('change')
|
|
|
|
.on('change', function(){
|
2013-10-18 03:59:07 +00:00
|
|
|
p.page = $(this).val() - 1;
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.updatePageDisplay(table, c, false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( p.$size.length ) {
|
2014-07-31 12:42:21 +00:00
|
|
|
// setting an option as selected appears to cause issues with initial page size
|
|
|
|
p.$size.find('option').removeAttr('selected');
|
2013-10-18 03:59:07 +00:00
|
|
|
p.$size
|
2014-10-02 16:30:39 +00:00
|
|
|
.off('change.pager')
|
|
|
|
.on('change.pager', function() {
|
2013-10-18 03:59:07 +00:00
|
|
|
p.$size.val( $(this).val() ); // in case there are more than one pagers
|
|
|
|
if ( !$(this).hasClass(wo.pager_css.disabled) ) {
|
|
|
|
tsp.setPageSize(table, parseInt( $(this).val(), 10 ), c);
|
|
|
|
tsp.changeHeight(table, c);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
// hide arrows at extremes
|
|
|
|
pagerArrows: function(c, disable) {
|
|
|
|
var p = c.pager,
|
|
|
|
dis = !!disable,
|
2014-01-11 19:08:37 +00:00
|
|
|
first = dis || p.page === 0,
|
2014-02-02 04:06:01 +00:00
|
|
|
tp = Math.min( p.totalPages, p.filteredPages ),
|
2014-06-22 11:37:02 +00:00
|
|
|
last = dis || p.page === tp - 1 || tp === 0,
|
2013-10-18 03:59:07 +00:00
|
|
|
wo = c.widgetOptions,
|
2014-02-02 04:06:01 +00:00
|
|
|
s = wo.pager_selectors;
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( wo.pager_updateArrows ) {
|
2014-01-11 19:08:37 +00:00
|
|
|
p.$container.find(s.first + ',' + s.prev).toggleClass(wo.pager_css.disabled, first).attr('aria-disabled', first);
|
|
|
|
p.$container.find(s.next + ',' + s.last).toggleClass(wo.pager_css.disabled, last).attr('aria-disabled', last);
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-10-09 21:49:49 +00:00
|
|
|
calcFilters: function(table, c) {
|
2014-10-20 20:44:56 +00:00
|
|
|
var wo = c.widgetOptions,
|
|
|
|
p = c.pager,
|
2014-10-09 21:49:49 +00:00
|
|
|
hasFilters = c.$table.hasClass('hasFilters');
|
2014-10-20 20:44:56 +00:00
|
|
|
if (hasFilters && !wo.pager_ajaxUrl) {
|
2014-07-11 19:51:50 +00:00
|
|
|
if ($.isEmptyObject(c.cache)) {
|
|
|
|
// delayInit: true so nothing is in the cache
|
2014-10-20 20:44:56 +00:00
|
|
|
p.filteredRows = p.totalRows = c.$tbodies.eq(0).children('tr').not( wo.pager_countChildRows ? '' : '.' + c.cssChildRow ).length;
|
2014-07-11 19:51:50 +00:00
|
|
|
} else {
|
|
|
|
p.filteredRows = 0;
|
|
|
|
$.each(c.cache[0].normalized, function(i, el) {
|
|
|
|
p.filteredRows += p.regexRows.test(el[c.columns].$row[0].className) ? 0 : 1;
|
|
|
|
});
|
|
|
|
}
|
2014-10-09 21:49:49 +00:00
|
|
|
} else if (!hasFilters) {
|
2014-06-21 06:24:21 +00:00
|
|
|
p.filteredRows = p.totalRows;
|
2014-04-18 16:36:19 +00:00
|
|
|
}
|
2014-10-09 21:49:49 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
updatePageDisplay: function(table, c, completed) {
|
2014-10-31 16:52:25 +00:00
|
|
|
if ( c.pager.initializing ) { return; }
|
2014-10-09 23:22:10 +00:00
|
|
|
var s, t, $out,
|
2014-10-09 21:49:49 +00:00
|
|
|
wo = c.widgetOptions,
|
|
|
|
p = c.pager,
|
|
|
|
sz = p.size || 10; // don't allow dividing by zero
|
|
|
|
if (wo.pager_countChildRows) { t.push(c.cssChildRow); }
|
|
|
|
p.$size.add(p.$goto).removeClass(wo.pager_css.disabled).removeAttr('disabled').attr('aria-disabled', 'false');
|
2014-07-11 19:51:50 +00:00
|
|
|
p.totalPages = Math.ceil( p.totalRows / sz ); // needed for "pageSize" method
|
2014-07-03 15:59:48 +00:00
|
|
|
c.totalRows = p.totalRows;
|
2014-10-09 21:49:49 +00:00
|
|
|
tsp.calcFilters(table, c);
|
2014-07-03 14:32:27 +00:00
|
|
|
c.filteredRows = p.filteredRows;
|
2014-06-21 06:24:21 +00:00
|
|
|
p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0;
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) {
|
2014-11-03 18:57:33 +00:00
|
|
|
t = (p.size * p.page > p.filteredRows) && completed;
|
2013-10-18 03:59:07 +00:00
|
|
|
p.startRow = (t) ? 1 : (p.filteredRows === 0 ? 0 : p.size * p.page + 1);
|
|
|
|
p.page = (t) ? 0 : p.page;
|
|
|
|
p.endRow = Math.min( p.filteredRows, p.totalRows, p.size * ( p.page + 1 ) );
|
2014-07-22 12:42:15 +00:00
|
|
|
$out = p.$container.find(wo.pager_selectors.pageDisplay);
|
2013-10-18 03:59:07 +00:00
|
|
|
// form the output string (can now get a new output string from the server)
|
|
|
|
s = ( p.ajaxData && p.ajaxData.output ? p.ajaxData.output || wo.pager_output : wo.pager_output )
|
|
|
|
// {page} = one-based index; {page+#} = zero based index +/- value
|
|
|
|
.replace(/\{page([\-+]\d+)?\}/gi, function(m,n){
|
2013-12-15 11:57:49 +00:00
|
|
|
return p.totalPages ? p.page + (n ? parseInt(n, 10) : 1) : 0;
|
2013-10-18 03:59:07 +00:00
|
|
|
})
|
|
|
|
// {totalPages}, {extra}, {extra:0} (array) or {extra : key} (object)
|
|
|
|
.replace(/\{\w+(\s*:\s*\w+)?\}/gi, function(m){
|
2014-07-22 12:42:15 +00:00
|
|
|
var len, indx,
|
|
|
|
str = m.replace(/[{}\s]/g,''),
|
2013-12-02 16:18:52 +00:00
|
|
|
extra = str.split(':'),
|
|
|
|
data = p.ajaxData,
|
|
|
|
// return zero for default page/row numbers
|
|
|
|
deflt = /(rows?|pages?)$/i.test(str) ? 0 : '';
|
2014-07-22 12:42:15 +00:00
|
|
|
if (/(startRow|page)/.test(extra[0]) && extra[1] === 'input') {
|
|
|
|
len = ('' + (extra[0] === 'page' ? p.totalPages : p.totalRows)).length;
|
|
|
|
indx = extra[0] === 'page' ? p.page + 1 : p.startRow;
|
|
|
|
return '<input type="text" class="ts-' + extra[0] + '" style="max-width:' + len + 'em" value="' + indx + '"/>';
|
|
|
|
}
|
2013-12-02 16:18:52 +00:00
|
|
|
return extra.length > 1 && data && data[extra[0]] ? data[extra[0]][extra[1]] : p[str] || (data ? data[str] : deflt) || deflt;
|
2013-10-18 03:59:07 +00:00
|
|
|
});
|
2014-09-17 06:45:27 +00:00
|
|
|
|
2014-07-22 12:42:15 +00:00
|
|
|
if ($out.length) {
|
|
|
|
$out[ ($out[0].tagName === 'INPUT') ? 'val' : 'html' ](s);
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( p.$goto.length ) {
|
2014-10-07 13:14:36 +00:00
|
|
|
t = '';
|
|
|
|
$.each(tsp.buildPageSelect(p, c), function(i, opt){
|
|
|
|
t += '<option value="' + opt + '">' + opt + '</option>';
|
|
|
|
});
|
2014-10-09 21:10:34 +00:00
|
|
|
// innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228
|
2014-10-09 23:22:10 +00:00
|
|
|
p.$goto.html(t).val( p.page + 1 );
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
2014-07-22 12:42:15 +00:00
|
|
|
// rebind startRow/page inputs
|
2014-10-02 16:30:39 +00:00
|
|
|
$out.find('.ts-startRow, .ts-page').off('change').on('change', function(){
|
2014-07-22 12:42:15 +00:00
|
|
|
var v = $(this).val(),
|
|
|
|
pg = $(this).hasClass('ts-startRow') ? Math.floor( v/p.size ) + 1 : v;
|
|
|
|
c.$table.trigger('pageSet.pager', [ pg ]);
|
|
|
|
});
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
tsp.pagerArrows(c);
|
2014-10-09 23:22:10 +00:00
|
|
|
tsp.fixHeight(table, c);
|
2014-03-07 02:28:47 +00:00
|
|
|
if (p.initialized && completed !== false) {
|
2013-10-18 03:59:07 +00:00
|
|
|
c.$table.trigger('pagerComplete', c);
|
|
|
|
// save pager info to storage
|
|
|
|
if (wo.pager_savePages && ts.storage) {
|
2014-01-16 23:16:56 +00:00
|
|
|
ts.storage(table, wo.pager_storageKey, {
|
2013-10-18 03:59:07 +00:00
|
|
|
page : p.page,
|
|
|
|
size : p.size
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2014-09-17 06:45:27 +00:00
|
|
|
buildPageSelect: function(p, c) {
|
|
|
|
// Filter the options page number link array if it's larger than 'pager_maxOptionSize'
|
|
|
|
// as large page set links will slow the browser on large dom inserts
|
2014-10-02 16:30:39 +00:00
|
|
|
var i, central_focus_size, focus_option_pages, insert_index, option_length, focus_length,
|
2014-09-17 06:45:27 +00:00
|
|
|
wo = c.widgetOptions,
|
2014-10-09 22:05:56 +00:00
|
|
|
pg = Math.min( p.totalPages, p.filteredPages ) || 1,
|
2014-09-17 06:45:27 +00:00
|
|
|
// make skip set size multiples of 5
|
|
|
|
skip_set_size = Math.ceil( ( pg / wo.pager_maxOptionSize ) / 5 ) * 5,
|
|
|
|
large_collection = pg > wo.pager_maxOptionSize,
|
|
|
|
current_page = p.page + 1,
|
|
|
|
start_page = skip_set_size,
|
|
|
|
end_page = pg - skip_set_size,
|
|
|
|
option_pages = [1],
|
|
|
|
// construct default options pages array
|
|
|
|
option_pages_start_page = (large_collection) ? skip_set_size : 1;
|
|
|
|
|
|
|
|
for ( i = option_pages_start_page; i <= pg; ) {
|
|
|
|
option_pages.push(i);
|
|
|
|
i = i + ( large_collection ? skip_set_size : 1 );
|
|
|
|
}
|
|
|
|
option_pages.push(pg);
|
|
|
|
|
|
|
|
if (large_collection) {
|
|
|
|
focus_option_pages = [];
|
|
|
|
// don't allow central focus size to be > 5 on either side of current page
|
|
|
|
central_focus_size = Math.max( Math.floor( wo.pager_maxOptionSize / skip_set_size ) - 1, 5 );
|
|
|
|
|
|
|
|
start_page = current_page - central_focus_size;
|
|
|
|
if (start_page < 1) { start_page = 1; }
|
|
|
|
end_page = current_page + central_focus_size;
|
|
|
|
if (end_page > pg) { end_page = pg; }
|
|
|
|
// construct an array to get a focus set around the current page
|
|
|
|
for (i = start_page; i <= end_page ; i++) {
|
|
|
|
focus_option_pages.push(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
// keep unique values
|
|
|
|
option_pages = $.grep(option_pages, function(value, indx) {
|
|
|
|
return $.inArray(value, option_pages) === indx;
|
|
|
|
});
|
|
|
|
|
|
|
|
option_length = option_pages.length;
|
|
|
|
focus_length = focus_option_pages.length;
|
|
|
|
|
|
|
|
// make sure at all option_pages aren't replaced
|
|
|
|
if (option_length - focus_length > skip_set_size / 2 && option_length + focus_length > wo.pager_maxOptionSize ) {
|
|
|
|
insert_index = Math.floor(option_length / 2) - Math.floor(focus_length / 2);
|
|
|
|
Array.prototype.splice.apply(option_pages, [ insert_index, focus_length ]);
|
|
|
|
}
|
|
|
|
option_pages = option_pages.concat(focus_option_pages);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// keep unique values again
|
|
|
|
option_pages = $.grep(option_pages, function(value, indx) {
|
|
|
|
return $.inArray(value, option_pages) === indx;
|
|
|
|
})
|
|
|
|
.sort(function(a,b) { return a - b; });
|
|
|
|
|
|
|
|
return option_pages;
|
|
|
|
},
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
fixHeight: function(table, c) {
|
|
|
|
var d, h,
|
|
|
|
p = c.pager,
|
|
|
|
wo = c.widgetOptions,
|
|
|
|
$b = c.$tbodies.eq(0);
|
2014-10-09 23:22:10 +00:00
|
|
|
$b.find('tr.pagerSavedHeightSpacer').remove();
|
|
|
|
if (wo.pager_fixedHeight && !p.isDisabled) {
|
2013-10-18 03:59:07 +00:00
|
|
|
h = $.data(table, 'pagerSavedHeight');
|
|
|
|
if (h) {
|
|
|
|
d = h - $b.height();
|
|
|
|
if ( d > 5 && $.data(table, 'pagerLastSize') === p.size && $b.children('tr:visible').length < p.size ) {
|
2014-10-09 23:22:10 +00:00
|
|
|
$b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '" style="height:' + d + 'px;"></tr>');
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
changeHeight: function(table, c) {
|
2014-10-09 23:22:10 +00:00
|
|
|
var h, $b = c.$tbodies.eq(0);
|
2013-10-18 03:59:07 +00:00
|
|
|
$b.find('tr.pagerSavedHeightSpacer').remove();
|
2014-10-09 23:22:10 +00:00
|
|
|
if (!$b.children('tr:visible').length) {
|
|
|
|
$b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '"><td> </td></tr>');
|
|
|
|
}
|
|
|
|
h = $b.children('tr').eq(0).height() * c.pager.size;
|
|
|
|
$.data(table, 'pagerSavedHeight', h);
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.fixHeight(table, c);
|
|
|
|
$.data(table, 'pagerLastSize', c.pager.size);
|
|
|
|
},
|
|
|
|
|
|
|
|
hideRows: function(table, c){
|
|
|
|
if (!c.widgetOptions.pager_ajaxUrl) {
|
|
|
|
var i,
|
2014-03-31 10:07:19 +00:00
|
|
|
lastIndex = 0,
|
2013-10-18 03:59:07 +00:00
|
|
|
p = c.pager,
|
2013-10-30 21:56:08 +00:00
|
|
|
wo = c.widgetOptions,
|
2014-06-03 12:58:11 +00:00
|
|
|
rows = c.$tbodies.eq(0).children('tr'),
|
2013-10-18 03:59:07 +00:00
|
|
|
l = rows.length,
|
|
|
|
s = ( p.page * p.size ),
|
|
|
|
e = s + p.size,
|
2013-10-30 21:56:08 +00:00
|
|
|
f = wo && wo.filter_filteredRow || 'filtered',
|
2013-10-18 03:59:07 +00:00
|
|
|
j = 0; // size counter
|
|
|
|
for ( i = 0; i < l; i++ ){
|
|
|
|
if ( !rows[i].className.match(f) ) {
|
2014-03-31 10:07:19 +00:00
|
|
|
if (j === s && rows[i].className.match(c.cssChildRow)) {
|
|
|
|
// hide child rows @ start of pager (if already visible)
|
|
|
|
rows[i].style.display = 'none';
|
|
|
|
} else {
|
|
|
|
rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
|
|
|
|
// don't count child rows
|
2014-10-31 01:58:36 +00:00
|
|
|
j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) && !wo.pager_countChildRows ? 0 : 1;
|
2014-03-31 10:07:19 +00:00
|
|
|
if ( j === e && rows[i].style.display !== 'none' && rows[i].className.match(ts.css.cssHasChild) ) {
|
|
|
|
lastIndex = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// add any attached child rows to last row of pager. Fixes part of issue #396
|
|
|
|
if ( lastIndex > 0 && rows[lastIndex].className.match(ts.css.cssHasChild) ) {
|
|
|
|
while ( ++lastIndex < l && rows[lastIndex].className.match(c.cssChildRow) ) {
|
|
|
|
rows[lastIndex].style.display = '';
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
hideRowsSetup: function(table, c){
|
|
|
|
var p = c.pager;
|
|
|
|
p.size = parseInt( p.$size.val(), 10 ) || p.size;
|
|
|
|
$.data(table, 'pagerLastSize', p.size);
|
|
|
|
tsp.pagerArrows(c);
|
|
|
|
if ( !c.widgetOptions.pager_removeRows ) {
|
|
|
|
tsp.hideRows(table, c);
|
|
|
|
c.$table.on('sortEnd.pager filterEnd.pager', function(){
|
|
|
|
tsp.hideRows(table, c);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
renderAjax: function(data, table, c, xhr, exception){
|
|
|
|
var p = c.pager,
|
|
|
|
wo = c.widgetOptions;
|
|
|
|
// process data
|
|
|
|
if ( $.isFunction(wo.pager_ajaxProcessing) ) {
|
|
|
|
// ajaxProcessing result: [ total, rows, headers ]
|
2014-02-19 19:27:23 +00:00
|
|
|
var i, j, t, hsh, $f, $sh, th, d, l, rr_count,
|
2013-10-18 03:59:07 +00:00
|
|
|
$t = c.$table,
|
|
|
|
tds = '',
|
2014-05-26 22:08:41 +00:00
|
|
|
result = wo.pager_ajaxProcessing(data, table, xhr) || [ 0, [] ],
|
2013-10-18 03:59:07 +00:00
|
|
|
hl = $t.find('thead th').length;
|
|
|
|
|
2014-02-05 12:10:55 +00:00
|
|
|
// Clean up any previous error.
|
|
|
|
ts.showError(table);
|
2013-10-18 03:59:07 +00:00
|
|
|
|
|
|
|
if ( exception ) {
|
2013-11-09 05:49:30 +00:00
|
|
|
if (c.debug) {
|
|
|
|
ts.log('Ajax Error', xhr, exception);
|
|
|
|
}
|
2014-02-05 12:10:55 +00:00
|
|
|
ts.showError(table, exception.message + ' (' + xhr.status + ')');
|
2014-07-11 19:51:50 +00:00
|
|
|
c.$tbodies.eq(0).children('tr').detach();
|
2014-03-07 03:13:45 +00:00
|
|
|
p.totalRows = 0;
|
2013-10-18 03:59:07 +00:00
|
|
|
} else {
|
|
|
|
// process ajax object
|
|
|
|
if (!$.isArray(result)) {
|
|
|
|
p.ajaxData = result;
|
2014-07-03 15:59:48 +00:00
|
|
|
c.totalRows = p.totalRows = result.total;
|
2014-07-03 14:32:27 +00:00
|
|
|
c.filteredRows = p.filteredRows = typeof result.filteredRows !== 'undefined' ? result.filteredRows : result.total;
|
2013-10-18 03:59:07 +00:00
|
|
|
th = result.headers;
|
|
|
|
d = result.rows;
|
|
|
|
} else {
|
|
|
|
// allow [ total, rows, headers ] or [ rows, total, headers ]
|
|
|
|
t = isNaN(result[0]) && !isNaN(result[1]);
|
2014-03-07 03:13:45 +00:00
|
|
|
// ensure a zero returned row count doesn't fail the logical ||
|
2013-10-18 03:59:07 +00:00
|
|
|
rr_count = result[t ? 1 : 0];
|
|
|
|
p.totalRows = isNaN(rr_count) ? p.totalRows || 0 : rr_count;
|
2014-07-02 20:43:15 +00:00
|
|
|
// can't set filtered rows when returning an array
|
2014-07-03 15:59:48 +00:00
|
|
|
c.totalRows = c.filteredRows = p.filteredRows = p.totalRows;
|
2013-12-15 10:49:55 +00:00
|
|
|
d = p.totalRows === 0 ? [""] : result[t ? 0 : 1] || []; // row data
|
2013-10-18 03:59:07 +00:00
|
|
|
th = result[2]; // headers
|
|
|
|
}
|
2014-07-02 20:43:15 +00:00
|
|
|
l = d && d.length;
|
2013-10-18 03:59:07 +00:00
|
|
|
if (d instanceof jQuery) {
|
2014-04-09 12:24:17 +00:00
|
|
|
if (wo.pager_processAjaxOnInit) {
|
|
|
|
// append jQuery object
|
2014-07-11 19:51:50 +00:00
|
|
|
c.$tbodies.eq(0).children('tr').detach();
|
2014-06-17 03:36:08 +00:00
|
|
|
c.$tbodies.eq(0).append(d);
|
2014-04-09 12:24:17 +00:00
|
|
|
}
|
2013-11-09 05:49:30 +00:00
|
|
|
} else if (l) {
|
2013-10-18 03:59:07 +00:00
|
|
|
// build table from array
|
2013-11-09 05:49:30 +00:00
|
|
|
for ( i = 0; i < l; i++ ) {
|
|
|
|
tds += '<tr>';
|
|
|
|
for ( j = 0; j < d[i].length; j++ ) {
|
2013-11-26 19:40:59 +00:00
|
|
|
// build tbody cells; watch for data containing HTML markup - see #434
|
2013-12-02 19:26:31 +00:00
|
|
|
tds += /^\s*<td/.test(d[i][j]) ? $.trim(d[i][j]) : '<td>' + d[i][j] + '</td>';
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
2013-11-09 05:49:30 +00:00
|
|
|
tds += '</tr>';
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
// add rows to first tbody
|
2014-01-07 01:10:07 +00:00
|
|
|
if (wo.pager_processAjaxOnInit) {
|
|
|
|
c.$tbodies.eq(0).html( tds );
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
2014-04-09 12:24:17 +00:00
|
|
|
wo.pager_processAjaxOnInit = true;
|
2013-10-18 03:59:07 +00:00
|
|
|
// only add new header text if the length matches
|
|
|
|
if ( th && th.length === hl ) {
|
|
|
|
hsh = $t.hasClass('hasStickyHeaders');
|
2014-06-03 12:58:11 +00:00
|
|
|
$sh = hsh ? wo.$sticky.children('thead:first').children('tr').children() : '';
|
2013-10-18 03:59:07 +00:00
|
|
|
$f = $t.find('tfoot tr:first').children();
|
|
|
|
// don't change td headers (may contain pager)
|
|
|
|
c.$headers.filter('th').each(function(j){
|
|
|
|
var $t = $(this), icn;
|
|
|
|
// add new test within the first span it finds, or just in the header
|
|
|
|
if ( $t.find('.' + ts.css.icon).length ) {
|
|
|
|
icn = $t.find('.' + ts.css.icon).clone(true);
|
|
|
|
$t.find('.tablesorter-header-inner').html( th[j] ).append(icn);
|
|
|
|
if ( hsh && $sh.length ) {
|
|
|
|
icn = $sh.eq(j).find('.' + ts.css.icon).clone(true);
|
|
|
|
$sh.eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icn);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$t.find('.tablesorter-header-inner').html( th[j] );
|
|
|
|
if (hsh && $sh.length) {
|
|
|
|
$sh.eq(j).find('.tablesorter-header-inner').html( th[j] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$f.eq(j).html( th[j] );
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (c.showProcessing) {
|
|
|
|
ts.isProcessing(table); // remove loading icon
|
|
|
|
}
|
2013-11-09 05:49:30 +00:00
|
|
|
// make sure last pager settings are saved, prevents multiple server side calls with
|
|
|
|
// the same parameters
|
2014-03-07 02:28:47 +00:00
|
|
|
p.totalPages = Math.ceil( p.totalRows / ( p.size || 10 ) );
|
|
|
|
p.last.totalRows = p.totalRows;
|
2013-11-09 05:49:30 +00:00
|
|
|
p.last.currentFilters = p.currentFilters;
|
|
|
|
p.last.sortList = (c.sortList || []).join(',');
|
2014-10-31 16:52:25 +00:00
|
|
|
p.initializing = false;
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.updatePageDisplay(table, c);
|
2014-02-22 17:17:26 +00:00
|
|
|
$t.trigger('updateCache', [function(){
|
2013-12-13 00:46:45 +00:00
|
|
|
if (p.initialized) {
|
2014-05-28 17:16:14 +00:00
|
|
|
// apply widgets after table has rendered & after a delay to prevent
|
|
|
|
// multiple applyWidget blocking code from blocking this trigger
|
|
|
|
setTimeout(function(){
|
|
|
|
$t
|
|
|
|
.trigger('applyWidgets')
|
|
|
|
.trigger('pagerChange', p);
|
|
|
|
}, 0);
|
2013-12-13 00:46:45 +00:00
|
|
|
}
|
|
|
|
}]);
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
if (!p.initialized) {
|
2014-02-22 17:17:26 +00:00
|
|
|
c.$table.trigger('applyWidgets');
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getAjax: function(table, c){
|
2013-11-27 17:07:52 +00:00
|
|
|
var counter,
|
|
|
|
url = tsp.getAjaxUrl(table, c),
|
|
|
|
$doc = $(document),
|
|
|
|
p = c.pager;
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( url !== '' ) {
|
|
|
|
if (c.showProcessing) {
|
|
|
|
ts.isProcessing(table, true); // show loading icon
|
|
|
|
}
|
|
|
|
$doc.on('ajaxError.pager', function(e, xhr, settings, exception) {
|
|
|
|
tsp.renderAjax(null, table, c, xhr, exception);
|
2014-10-02 16:30:39 +00:00
|
|
|
$doc.off('ajaxError.pager');
|
2013-10-18 03:59:07 +00:00
|
|
|
});
|
2013-11-27 17:07:52 +00:00
|
|
|
counter = ++p.ajaxCounter;
|
2014-11-03 14:05:22 +00:00
|
|
|
p.last.ajaxUrl = url; // remember processed url
|
2014-10-02 16:30:39 +00:00
|
|
|
p.ajaxObject.url = url; // from the ajaxUrl option and modified by customAjaxUrl
|
|
|
|
p.ajaxObject.success = function(data, status, jqxhr) {
|
2013-11-27 17:07:52 +00:00
|
|
|
// Refuse to process old ajax commands that were overwritten by new ones - see #443
|
|
|
|
if (counter < p.ajaxCounter){
|
|
|
|
return;
|
|
|
|
}
|
2014-05-26 22:08:41 +00:00
|
|
|
tsp.renderAjax(data, table, c, jqxhr);
|
2014-10-02 16:30:39 +00:00
|
|
|
$doc.off('ajaxError.pager');
|
2014-04-18 16:04:45 +00:00
|
|
|
if (typeof p.oldAjaxSuccess === 'function') {
|
|
|
|
p.oldAjaxSuccess(data);
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
};
|
2013-11-09 05:49:30 +00:00
|
|
|
if (c.debug) {
|
2014-10-02 16:30:39 +00:00
|
|
|
ts.log('ajax initialized', p.ajaxObject);
|
2013-11-09 05:49:30 +00:00
|
|
|
}
|
2014-10-02 16:30:39 +00:00
|
|
|
$.ajax(p.ajaxObject);
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
getAjaxUrl: function(table, c) {
|
|
|
|
var p = c.pager,
|
|
|
|
wo = c.widgetOptions,
|
|
|
|
url = (wo.pager_ajaxUrl) ? wo.pager_ajaxUrl
|
|
|
|
// allow using "{page+1}" in the url string to switch to a non-zero based index
|
|
|
|
.replace(/\{page([\-+]\d+)?\}/, function(s,n){ return p.page + (n ? parseInt(n, 10) : 0); })
|
|
|
|
.replace(/\{size\}/g, p.size) : '',
|
|
|
|
sl = c.sortList,
|
2013-11-09 05:49:30 +00:00
|
|
|
fl = p.currentFilters || $(table).data('lastSearch') || [],
|
2013-10-18 03:59:07 +00:00
|
|
|
sortCol = url.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),
|
|
|
|
filterCol = url.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),
|
|
|
|
arry = [];
|
|
|
|
if (sortCol) {
|
|
|
|
sortCol = sortCol[1];
|
|
|
|
$.each(sl, function(i,v){
|
|
|
|
arry.push(sortCol + '[' + v[0] + ']=' + v[1]);
|
|
|
|
});
|
|
|
|
// if the arry is empty, just add the col parameter... "&{sortList:col}" becomes "&col"
|
|
|
|
url = url.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : sortCol );
|
|
|
|
arry = [];
|
|
|
|
}
|
|
|
|
if (filterCol) {
|
|
|
|
filterCol = filterCol[1];
|
|
|
|
$.each(fl, function(i,v){
|
|
|
|
if (v) {
|
|
|
|
arry.push(filterCol + '[' + i + ']=' + encodeURIComponent(v));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
// if the arry is empty, just add the fcol parameter... "&{filterList:fcol}" becomes "&fcol"
|
|
|
|
url = url.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g, arry.length ? arry.join('&') : filterCol );
|
2013-11-09 05:49:30 +00:00
|
|
|
p.currentFilters = fl;
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
if ( $.isFunction(wo.pager_customAjaxUrl) ) {
|
|
|
|
url = wo.pager_customAjaxUrl(table, url);
|
|
|
|
}
|
2013-11-09 05:49:30 +00:00
|
|
|
if (c.debug) {
|
|
|
|
ts.log('Pager ajax url: ' + url);
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
return url;
|
|
|
|
},
|
|
|
|
|
|
|
|
renderTable: function(table, rows) {
|
2014-04-21 00:39:59 +00:00
|
|
|
var $tb, index, count, added,
|
2013-10-18 03:59:07 +00:00
|
|
|
c = table.config,
|
|
|
|
p = c.pager,
|
|
|
|
wo = c.widgetOptions,
|
2014-04-18 16:36:19 +00:00
|
|
|
f = c.$table.hasClass('hasFilters'),
|
2013-10-18 03:59:07 +00:00
|
|
|
l = rows && rows.length || 0, // rows may be undefined
|
|
|
|
s = ( p.page * p.size ),
|
2014-04-18 16:36:19 +00:00
|
|
|
e = p.size;
|
2014-07-11 19:51:50 +00:00
|
|
|
if ( l < 1 ) {
|
|
|
|
if (c.debug) {
|
|
|
|
ts.log('Pager: no rows for pager to render');
|
|
|
|
}
|
|
|
|
// empty table, abort!
|
|
|
|
return;
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( p.page >= p.totalPages ) {
|
|
|
|
// lets not render the table more than once
|
|
|
|
return tsp.moveToLastPage(table, p);
|
|
|
|
}
|
|
|
|
p.isDisabled = false; // needed because sorting will change the page and re-enable the pager
|
|
|
|
if (p.initialized) { c.$table.trigger('pagerChange', c); }
|
|
|
|
if ( !wo.pager_removeRows ) {
|
|
|
|
tsp.hideRows(table, c);
|
|
|
|
} else {
|
|
|
|
ts.clearTableBody(table);
|
|
|
|
$tb = ts.processTbody(table, c.$tbodies.eq(0), true);
|
2014-04-18 16:36:19 +00:00
|
|
|
// not filtered, start from the calculated starting point (s)
|
|
|
|
// if filtered, start from zero
|
|
|
|
index = f ? 0 : s;
|
|
|
|
count = f ? 0 : s;
|
2014-05-26 22:08:41 +00:00
|
|
|
added = 0;
|
2014-04-18 16:36:19 +00:00
|
|
|
while (added < e && index < rows.length) {
|
|
|
|
if (!f || !/filtered/.test(rows[index][0].className)){
|
|
|
|
count++;
|
|
|
|
if (count > s && added <= e) {
|
|
|
|
added++;
|
|
|
|
$tb.append(rows[index]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
index++;
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
ts.processTbody(table, $tb, false);
|
|
|
|
}
|
2014-10-31 17:35:05 +00:00
|
|
|
tsp.updatePageDisplay(table, c);
|
2013-10-18 03:59:07 +00:00
|
|
|
|
|
|
|
wo.pager_startPage = p.page;
|
|
|
|
wo.pager_size = p.size;
|
2014-03-07 02:28:47 +00:00
|
|
|
if (table.isUpdating) {
|
2014-08-12 15:32:52 +00:00
|
|
|
c.$table.trigger('updateComplete', [ table, true ]);
|
2014-03-07 02:28:47 +00:00
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
showAllRows: function(table, c){
|
|
|
|
var p = c.pager,
|
|
|
|
wo = c.widgetOptions;
|
|
|
|
if ( p.ajax ) {
|
|
|
|
tsp.pagerArrows(c, true);
|
|
|
|
} else {
|
|
|
|
p.isDisabled = true;
|
|
|
|
$.data(table, 'pagerLastPage', p.page);
|
|
|
|
$.data(table, 'pagerLastSize', p.size);
|
|
|
|
p.page = 0;
|
|
|
|
p.size = p.totalRows;
|
|
|
|
p.totalPages = 1;
|
2014-01-11 19:08:37 +00:00
|
|
|
c.$table
|
|
|
|
.addClass('pagerDisabled')
|
|
|
|
.removeAttr('aria-describedby')
|
|
|
|
.find('tr.pagerSavedHeightSpacer').remove();
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.renderTable(table, c.rowsCopy);
|
2014-08-12 15:32:52 +00:00
|
|
|
c.$table.trigger('applyWidgets');
|
2013-11-09 05:49:30 +00:00
|
|
|
if (c.debug) {
|
|
|
|
ts.log('pager disabled');
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
// disable size selector
|
|
|
|
p.$size.add(p.$goto).each(function(){
|
2014-01-11 19:08:37 +00:00
|
|
|
$(this).attr('aria-disabled', 'true').addClass(wo.pager_css.disabled)[0].disabled = true;
|
2013-10-18 03:59:07 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2014-07-11 19:51:50 +00:00
|
|
|
// updateCache if delayInit: true
|
|
|
|
// this is normally done by "appendToTable" function in the tablesorter core AFTER a sort
|
|
|
|
updateCache: function(table) {
|
|
|
|
var c = table.config,
|
|
|
|
p = c.pager;
|
|
|
|
c.$table.trigger('updateCache', [ function(){
|
|
|
|
if ( !$.isEmptyObject(table.config.cache) ) {
|
|
|
|
var i,
|
|
|
|
rows = [],
|
|
|
|
n = table.config.cache[0].normalized;
|
|
|
|
p.totalRows = n.length;
|
|
|
|
for (i = 0; i < p.totalRows; i++) {
|
|
|
|
rows.push(n[i][c.columns].$row);
|
|
|
|
}
|
|
|
|
c.rowsCopy = rows;
|
|
|
|
tsp.moveToPage(table, p, true);
|
|
|
|
// clear out last search to force an update
|
|
|
|
p.last.currentFilters = [' '];
|
|
|
|
}
|
|
|
|
} ]);
|
|
|
|
},
|
|
|
|
|
2014-03-07 02:28:47 +00:00
|
|
|
moveToPage: function(table, p, pageMoved) {
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( p.isDisabled ) { return; }
|
2014-07-11 19:51:50 +00:00
|
|
|
if ( pageMoved !== false && p.initialized && $.isEmptyObject(table.config.cache)) {
|
|
|
|
return tsp.updateCache(table);
|
|
|
|
}
|
2014-10-09 21:49:49 +00:00
|
|
|
var pg, c = table.config,
|
2014-10-02 16:30:39 +00:00
|
|
|
wo = c.widgetOptions,
|
2014-10-09 23:22:10 +00:00
|
|
|
l = p.last;
|
2014-10-31 16:52:25 +00:00
|
|
|
|
|
|
|
// abort page move if the table has filters and has not been initialized
|
|
|
|
if (p.ajax && !wo.filter_initialized && ts.hasWidget(table, 'filter')) { return; }
|
|
|
|
|
2014-10-09 21:49:49 +00:00
|
|
|
tsp.calcFilters(table, c);
|
|
|
|
pg = Math.min( p.totalPages, p.filteredPages );
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( p.page < 0 ) { p.page = 0; }
|
|
|
|
if ( p.page > ( pg - 1 ) && pg !== 0 ) { p.page = pg - 1; }
|
2014-10-31 16:52:25 +00:00
|
|
|
|
2014-03-04 00:07:14 +00:00
|
|
|
// 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;
|
|
|
|
p.currentFilters = (p.currentFilters || []).join('') === '' ? [] : p.currentFilters;
|
2014-03-04 13:20:21 +00:00
|
|
|
// don't allow rendering multiple times on the same page/size/totalRows/filters/sorts
|
|
|
|
if ( l.page === p.page && l.size === p.size && l.totalRows === p.totalRows &&
|
2013-11-09 05:49:30 +00:00
|
|
|
(l.currentFilters || []).join(',') === (p.currentFilters || []).join(',') &&
|
2014-10-02 16:30:39 +00:00
|
|
|
// check for ajax url changes see #730
|
2014-09-28 13:37:47 +00:00
|
|
|
(l.ajaxUrl || '') === (p.ajaxObject.url || '') &&
|
2014-10-02 16:30:39 +00:00
|
|
|
// & ajax url option changes (dynamically add/remove/rename sort & filter parameters)
|
|
|
|
(l.optAjaxUrl || '') === (wo.pager_ajaxUrl || '') &&
|
2014-02-02 04:06:01 +00:00
|
|
|
l.sortList === (c.sortList || []).join(',') ) {
|
2014-02-22 17:17:26 +00:00
|
|
|
return;
|
2014-02-02 04:06:01 +00:00
|
|
|
}
|
2013-11-09 05:49:30 +00:00
|
|
|
if (c.debug) {
|
|
|
|
ts.log('Pager changing to page ' + p.page);
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
p.last = {
|
|
|
|
page : p.page,
|
|
|
|
size : p.size,
|
2013-11-09 05:49:30 +00:00
|
|
|
// fixes #408; modify sortList otherwise it auto-updates
|
|
|
|
sortList : (c.sortList || []).join(','),
|
2014-03-04 13:20:21 +00:00
|
|
|
totalRows : p.totalRows,
|
2014-09-28 13:37:47 +00:00
|
|
|
currentFilters : p.currentFilters || [],
|
2014-10-02 16:30:39 +00:00
|
|
|
ajaxUrl : p.ajaxObject.url || '',
|
|
|
|
optAjaxUrl : wo.pager_ajaxUrl
|
2013-10-18 03:59:07 +00:00
|
|
|
};
|
|
|
|
if (p.ajax) {
|
|
|
|
tsp.getAjax(table, c);
|
|
|
|
} else if (!p.ajax) {
|
|
|
|
tsp.renderTable(table, c.rowsCopy);
|
|
|
|
}
|
|
|
|
$.data(table, 'pagerLastPage', p.page);
|
2014-03-07 02:28:47 +00:00
|
|
|
if (p.initialized && pageMoved !== false) {
|
2014-09-15 20:12:30 +00:00
|
|
|
c.$table
|
|
|
|
.trigger('pageMoved', c)
|
|
|
|
.trigger('applyWidgets');
|
2014-03-07 02:28:47 +00:00
|
|
|
if (!p.ajax && table.isUpdating) {
|
2014-08-12 15:32:52 +00:00
|
|
|
c.$table.trigger('updateComplete', [ table, true ]);
|
2014-03-07 02:28:47 +00:00
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
setPageSize: function(table, size, c) {
|
|
|
|
var p = c.pager;
|
2013-11-09 05:49:30 +00:00
|
|
|
p.size = size || p.size || 10;
|
|
|
|
p.$size.val(p.size);
|
2013-10-18 03:59:07 +00:00
|
|
|
$.data(table, 'pagerLastPage', p.page);
|
|
|
|
$.data(table, 'pagerLastSize', p.size);
|
2013-11-09 05:49:30 +00:00
|
|
|
p.totalPages = Math.ceil( p.totalRows / p.size );
|
2014-03-18 22:40:03 +00:00
|
|
|
p.filteredPages = Math.ceil( p.filteredRows / p.size );
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
moveToFirstPage: function(table, p) {
|
|
|
|
p.page = 0;
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
moveToLastPage: function(table, p) {
|
|
|
|
p.page = ( Math.min( p.totalPages, p.filteredPages ) - 1 );
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
moveToNextPage: function(table, p) {
|
|
|
|
p.page++;
|
|
|
|
if ( p.page >= ( Math.min( p.totalPages, p.filteredPages ) - 1 ) ) {
|
|
|
|
p.page = ( Math.min( p.totalPages, p.filteredPages ) - 1 );
|
|
|
|
}
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
moveToPrevPage: function(table, p) {
|
|
|
|
p.page--;
|
|
|
|
if ( p.page <= 0 ) {
|
|
|
|
p.page = 0;
|
|
|
|
}
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
destroyPager: function(table, c){
|
|
|
|
var p = c.pager;
|
|
|
|
tsp.showAllRows(table, c);
|
|
|
|
p.$container.hide(); // hide pager
|
|
|
|
c.appender = null; // remove pager appender function
|
|
|
|
p.initialized = false;
|
2014-04-11 01:16:22 +00:00
|
|
|
delete table.config.rowsCopy;
|
2014-10-31 20:18:30 +00:00
|
|
|
c.$table.off('filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet '.split(' ').join('.pager '));
|
2013-10-18 03:59:07 +00:00
|
|
|
if (ts.storage) {
|
2014-02-22 17:17:26 +00:00
|
|
|
ts.storage(table, c.widgetOptions.pager_storageKey, '');
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
enablePager: function(table, c, triggered){
|
2014-01-11 19:08:37 +00:00
|
|
|
var info, p = c.pager;
|
2013-10-18 03:59:07 +00:00
|
|
|
p.isDisabled = false;
|
|
|
|
p.page = $.data(table, 'pagerLastPage') || p.page || 0;
|
2013-11-09 05:49:30 +00:00
|
|
|
p.size = $.data(table, 'pagerLastSize') || parseInt(p.$size.find('option[selected]').val(), 10) || p.size || 10;
|
2013-10-18 03:59:07 +00:00
|
|
|
p.$size.val(p.size); // set page size
|
2013-12-20 14:45:34 +00:00
|
|
|
p.totalPages = Math.ceil( Math.min( p.totalRows, p.filteredRows ) / p.size );
|
2013-10-18 03:59:07 +00:00
|
|
|
c.$table.removeClass('pagerDisabled');
|
2014-01-11 19:08:37 +00:00
|
|
|
// if table id exists, include page display with aria info
|
|
|
|
if ( table.id ) {
|
|
|
|
info = table.id + '_pager_info';
|
2014-02-22 17:17:26 +00:00
|
|
|
p.$container.find(c.widgetOptions.pager_selectors.pageDisplay).attr('id', info);
|
2014-01-11 19:08:37 +00:00
|
|
|
c.$table.attr('aria-describedby', info);
|
|
|
|
}
|
2014-10-09 23:22:10 +00:00
|
|
|
tsp.changeHeight(table, c);
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( triggered ) {
|
2014-01-07 01:10:07 +00:00
|
|
|
c.$table.trigger('updateRows');
|
2013-10-18 03:59:07 +00:00
|
|
|
tsp.setPageSize(table, p.size, c);
|
|
|
|
tsp.hideRowsSetup(table, c);
|
2013-11-09 05:49:30 +00:00
|
|
|
if (c.debug) {
|
|
|
|
ts.log('pager enabled');
|
|
|
|
}
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
appender: function(table, rows) {
|
2013-11-01 18:43:18 +00:00
|
|
|
var c = table.config,
|
2013-11-09 05:49:30 +00:00
|
|
|
wo = c.widgetOptions,
|
2013-11-01 18:43:18 +00:00
|
|
|
p = c.pager;
|
2013-10-18 03:59:07 +00:00
|
|
|
if ( !p.ajax ) {
|
2013-11-01 18:43:18 +00:00
|
|
|
c.rowsCopy = rows;
|
2014-10-20 20:44:56 +00:00
|
|
|
p.totalRows = wo.pager_countChildRows ? c.$tbodies.eq(0).children('tr').length : rows.length;
|
2013-11-09 05:49:30 +00:00
|
|
|
p.size = $.data(table, 'pagerLastSize') || p.size || wo.pager_size || 10;
|
|
|
|
p.totalPages = Math.ceil( p.totalRows / p.size );
|
2014-07-11 19:51:50 +00:00
|
|
|
tsp.moveToPage(table, p);
|
2014-02-02 04:06:01 +00:00
|
|
|
// update display here in case all rows are removed
|
|
|
|
tsp.updatePageDisplay(table, c, false);
|
2014-03-07 02:28:47 +00:00
|
|
|
} else {
|
|
|
|
tsp.moveToPage(table, p, true);
|
2013-10-18 03:59:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2014-02-05 12:10:55 +00:00
|
|
|
// see #486
|
|
|
|
ts.showError = function(table, message){
|
|
|
|
$(table).each(function(){
|
|
|
|
var $row,
|
|
|
|
c = this.config,
|
2014-10-20 20:44:56 +00:00
|
|
|
wo = c.widgetOptions,
|
|
|
|
errorRow = c.pager && c.pager.cssErrorRow || wo.pager_css && wo.pager_css.errorRow || 'tablesorter-errorRow';
|
2014-02-05 12:10:55 +00:00
|
|
|
if (c) {
|
|
|
|
if (typeof message === 'undefined') {
|
|
|
|
c.$table.find('thead').find(c.selectorRemove).remove();
|
|
|
|
} else {
|
|
|
|
$row = ( /tr\>/.test(message) ? $(message) : $('<tr><td colspan="' + c.columns + '">' + message + '</td></tr>') )
|
|
|
|
.click(function(){
|
|
|
|
$(this).remove();
|
|
|
|
})
|
|
|
|
// add error row to thead instead of tbody, or clicking on the header will result in a parser error
|
|
|
|
.appendTo( c.$table.find('thead:first') )
|
2014-10-31 01:58:36 +00:00
|
|
|
.addClass( errorRow + ' ' + c.selectorRemove.slice(1) )
|
2014-02-05 12:10:55 +00:00
|
|
|
.attr({
|
|
|
|
role : 'alert',
|
|
|
|
'aria-live' : 'assertive'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2013-10-18 03:59:07 +00:00
|
|
|
})(jQuery);
|