mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Pager: bind using unique event namespace. See #961
This commit is contained in:
parent
c705656e90
commit
dd80e3c88f
@ -159,6 +159,7 @@
|
|||||||
if ( p.initializing ) { return; }
|
if ( p.initializing ) { return; }
|
||||||
var s, t, $out, indx, len, options,
|
var s, t, $out, indx, len, options,
|
||||||
c = table.config,
|
c = table.config,
|
||||||
|
namespace = c.namespace + 'pager',
|
||||||
sz = p.size || p.settings.size || 10; // don't allow dividing by zero
|
sz = p.size || p.settings.size || 10; // don't allow dividing by zero
|
||||||
if (p.countChildRows) { t.push(c.cssChildRow); }
|
if (p.countChildRows) { t.push(c.cssChildRow); }
|
||||||
p.totalPages = Math.ceil( p.totalRows / sz ); // needed for "pageSize" method
|
p.totalPages = Math.ceil( p.totalRows / sz ); // needed for "pageSize" method
|
||||||
@ -206,10 +207,10 @@
|
|||||||
if ($out.length) {
|
if ($out.length) {
|
||||||
$out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
|
$out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
|
||||||
// rebind startRow/page inputs
|
// rebind startRow/page inputs
|
||||||
$out.find('.ts-startRow, .ts-page').unbind('change.pager').bind('change.pager', function(){
|
$out.find('.ts-startRow, .ts-page').unbind('change' + namespace).bind('change' + namespace, function(){
|
||||||
var v = $(this).val(),
|
var v = $(this).val(),
|
||||||
pg = $(this).hasClass('ts-startRow') ? Math.floor( v/p.size ) + 1 : v;
|
pg = $(this).hasClass('ts-startRow') ? Math.floor( v/p.size ) + 1 : v;
|
||||||
c.$table.trigger('pageSet.pager', [ pg ]);
|
c.$table.trigger('pageSet' + namespace, [ pg ]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -367,7 +368,7 @@
|
|||||||
pagerArrows(p);
|
pagerArrows(p);
|
||||||
if ( !p.removeRows ) {
|
if ( !p.removeRows ) {
|
||||||
hideRows(table, p);
|
hideRows(table, p);
|
||||||
$(table).bind('sortEnd.pager filterEnd.pager', function(){
|
$(table).bind('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function(){
|
||||||
hideRows(table, p);
|
hideRows(table, p);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -512,18 +513,19 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getAjax = function(table, p){
|
getAjax = function(table, p) {
|
||||||
var url = getAjaxUrl(table, p),
|
var url = getAjaxUrl(table, p),
|
||||||
$doc = $(document),
|
$doc = $(document),
|
||||||
counter,
|
counter,
|
||||||
c = table.config;
|
c = table.config,
|
||||||
|
namespace = c.namespace + 'pager';
|
||||||
if ( url !== '' ) {
|
if ( url !== '' ) {
|
||||||
if (c.showProcessing) {
|
if (c.showProcessing) {
|
||||||
ts.isProcessing(table, true); // show loading icon
|
ts.isProcessing(table, true); // show loading icon
|
||||||
}
|
}
|
||||||
$doc.bind('ajaxError.pager', function(e, xhr, settings, exception) {
|
$doc.bind('ajaxError' + namespace, function(e, xhr, settings, exception) {
|
||||||
renderAjax(null, table, p, xhr, exception);
|
renderAjax(null, table, p, xhr, exception);
|
||||||
$doc.unbind('ajaxError.pager');
|
$doc.unbind('ajaxError' + namespace);
|
||||||
});
|
});
|
||||||
|
|
||||||
counter = ++p.ajaxCounter;
|
counter = ++p.ajaxCounter;
|
||||||
@ -536,7 +538,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
renderAjax(data, table, p, jqxhr);
|
renderAjax(data, table, p, jqxhr);
|
||||||
$doc.unbind('ajaxError.pager');
|
$doc.unbind('ajaxError' + namespace);
|
||||||
if (typeof p.oldAjaxSuccess === 'function') {
|
if (typeof p.oldAjaxSuccess === 'function') {
|
||||||
p.oldAjaxSuccess(data);
|
p.oldAjaxSuccess(data);
|
||||||
}
|
}
|
||||||
@ -651,7 +653,7 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
showAllRows = function(table, p){
|
showAllRows = function(table, p) {
|
||||||
var index, $controls, len;
|
var index, $controls, len;
|
||||||
if ( p.ajax ) {
|
if ( p.ajax ) {
|
||||||
pagerArrows(p, true);
|
pagerArrows(p, true);
|
||||||
@ -798,19 +800,20 @@
|
|||||||
moveToPage(table, p);
|
moveToPage(table, p);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroyPager = function(table, p){
|
destroyPager = function(table, p) {
|
||||||
showAllRows(table, p);
|
showAllRows(table, p);
|
||||||
p.$container.hide(); // hide pager
|
p.$container.hide(); // hide pager
|
||||||
table.config.appender = null; // remove pager appender function
|
var c = table.config;
|
||||||
|
c.appender = null; // remove pager appender function
|
||||||
p.initialized = false;
|
p.initialized = false;
|
||||||
delete table.config.rowsCopy;
|
delete c.rowsCopy;
|
||||||
$(table).unbind( pagerEvents.split(' ').join('.pager ').replace(/\s+/g, ' ') );
|
$(table).unbind( pagerEvents.split(' ').join(c.namespace + 'pager ').replace(/\s+/g, ' ') );
|
||||||
if (ts.storage) {
|
if (ts.storage) {
|
||||||
ts.storage(table, p.storageKey, '');
|
ts.storage(table, p.storageKey, '');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
enablePager = function(table, p, triggered){
|
enablePager = function(table, p, triggered) {
|
||||||
var info,
|
var info,
|
||||||
c = table.config;
|
c = table.config;
|
||||||
p.$size.add(p.$goto).add(p.$container.find('.ts-startRow, .ts-page'))
|
p.$size.add(p.$goto).add(p.$container.find('.ts-startRow, .ts-page'))
|
||||||
@ -863,6 +866,7 @@
|
|||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
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',
|
||||||
// added in case the pager is reinitialized after being destroyed.
|
// added in case the pager is reinitialized after being destroyed.
|
||||||
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
|
||||||
@ -884,8 +888,8 @@
|
|||||||
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
|
p.regexRows = new RegExp('(' + (wo.filter_filteredRow || 'filtered') + '|' + c.selectorRemove.slice(1) + '|' + c.cssChildRow + ')');
|
||||||
|
|
||||||
$t
|
$t
|
||||||
.unbind( pagerEvents.split(' ').join('.pager ').replace(/\s+/g, ' ') )
|
.unbind( pagerEvents.split(' ').join(namespace + ' ').replace(/\s+/g, ' ') )
|
||||||
.bind('filterInit.pager filterStart.pager', function(e, filters) {
|
.bind('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
|
||||||
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
||||||
// don't change page if filters are the same (pager updating, etc)
|
// don't change page if filters are the same (pager updating, etc)
|
||||||
if (e.type === 'filterStart' && p.pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) {
|
if (e.type === 'filterStart' && p.pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) {
|
||||||
@ -893,7 +897,7 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// update pager after filter widget completes
|
// update pager after filter widget completes
|
||||||
.bind('filterEnd.pager sortEnd.pager', function() {
|
.bind('filterEnd sortEnd '.split(' ').join(namespace + ' '), function() {
|
||||||
p.currentFilters = c.$table.data('lastSearch');
|
p.currentFilters = c.$table.data('lastSearch');
|
||||||
if (p.initialized || p.initializing) {
|
if (p.initialized || p.initializing) {
|
||||||
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
|
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
|
||||||
@ -905,19 +909,19 @@
|
|||||||
c.$table.trigger('applyWidgets');
|
c.$table.trigger('applyWidgets');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.bind('disable.pager', function(e){
|
.bind('disable' + namespace, function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
showAllRows(table, p);
|
showAllRows(table, p);
|
||||||
})
|
})
|
||||||
.bind('enable.pager', function(e){
|
.bind('enable' + namespace, function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
enablePager(table, p, true);
|
enablePager(table, p, true);
|
||||||
})
|
})
|
||||||
.bind('destroy.pager', function(e){
|
.bind('destroy' + namespace, function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
destroyPager(table, p);
|
destroyPager(table, p);
|
||||||
})
|
})
|
||||||
.bind('updateComplete.pager', function(e, table, triggered){
|
.bind('updateComplete' + namespace, function(e, table, triggered){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
|
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
|
||||||
// don't recalculate total rows/pages if using ajax
|
// don't recalculate total rows/pages if using ajax
|
||||||
@ -936,13 +940,13 @@
|
|||||||
changeHeight(table, p);
|
changeHeight(table, p);
|
||||||
updatePageDisplay(table, p, true);
|
updatePageDisplay(table, p, true);
|
||||||
})
|
})
|
||||||
.bind('pageSize.pager refreshComplete.pager', function(e,v){
|
.bind('pageSize refreshComplete '.split(' ').join(namespace + ' '), function(e,v){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
setPageSize(table, parseInt(v, 10) || p.settings.size || 10, p);
|
setPageSize(table, parseInt(v, 10) || p.settings.size || 10, p);
|
||||||
hideRows(table, p);
|
hideRows(table, p);
|
||||||
updatePageDisplay(table, p, false);
|
updatePageDisplay(table, p, false);
|
||||||
})
|
})
|
||||||
.bind('pageSet.pager pagerUpdate.pager', function(e,v){
|
.bind('pageSet pagerUpdate '.split(' ').join(namespace + ' '), function(e,v){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// force pager refresh
|
// force pager refresh
|
||||||
if (e.type === 'pagerUpdate') {
|
if (e.type === 'pagerUpdate') {
|
||||||
@ -953,7 +957,7 @@
|
|||||||
moveToPage(table, p, true);
|
moveToPage(table, p, true);
|
||||||
updatePageDisplay(table, p, false);
|
updatePageDisplay(table, p, false);
|
||||||
})
|
})
|
||||||
.bind('pageAndSize.pager', function(e, page, size){
|
.bind('pageAndSize' + namespace, function(e, page, size){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
p.page = (parseInt(page, 10) || 1) - 1;
|
p.page = (parseInt(page, 10) || 1) - 1;
|
||||||
setPageSize(table, parseInt(size, 10) || p.settings.size || 10, p);
|
setPageSize(table, parseInt(size, 10) || p.settings.size || 10, p);
|
||||||
@ -970,8 +974,8 @@
|
|||||||
}
|
}
|
||||||
pager.find(ctrls.join(','))
|
pager.find(ctrls.join(','))
|
||||||
.attr("tabindex", 0)
|
.attr("tabindex", 0)
|
||||||
.unbind('click.pager')
|
.unbind('click' + namespace)
|
||||||
.bind('click.pager', function(e){
|
.bind('click' + namespace, function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var i, $t = $(this), l = ctrls.length;
|
var i, $t = $(this), l = ctrls.length;
|
||||||
if ( !$t.hasClass(p.cssDisabled) ) {
|
if ( !$t.hasClass(p.cssDisabled) ) {
|
||||||
@ -988,8 +992,8 @@
|
|||||||
p.$goto = pager.find(p.cssGoto);
|
p.$goto = pager.find(p.cssGoto);
|
||||||
if ( p.$goto.length ) {
|
if ( p.$goto.length ) {
|
||||||
p.$goto
|
p.$goto
|
||||||
.unbind('change.pager')
|
.unbind('change' + namespace)
|
||||||
.bind('change.pager', function(){
|
.bind('change' + namespace, function(){
|
||||||
p.page = $(this).val() - 1;
|
p.page = $(this).val() - 1;
|
||||||
moveToPage(table, p, true);
|
moveToPage(table, p, true);
|
||||||
updatePageDisplay(table, p, false);
|
updatePageDisplay(table, p, false);
|
||||||
@ -1002,7 +1006,7 @@
|
|||||||
if ( p.$size.length ) {
|
if ( p.$size.length ) {
|
||||||
// setting an option as selected appears to cause issues with initial page size
|
// setting an option as selected appears to cause issues with initial page size
|
||||||
p.$size.find('option').removeAttr('selected');
|
p.$size.find('option').removeAttr('selected');
|
||||||
p.$size.unbind('change.pager').bind('change.pager', function() {
|
p.$size.unbind('change' + namespace).bind('change' + namespace, function() {
|
||||||
p.$size.val( $(this).val() ); // in case there are more than one pagers
|
p.$size.val( $(this).val() ); // in case there are more than one pagers
|
||||||
if ( !$(this).hasClass(p.cssDisabled) ) {
|
if ( !$(this).hasClass(p.cssDisabled) ) {
|
||||||
setPageSize(table, parseInt( $(this).val(), 10 ), p);
|
setPageSize(table, parseInt( $(this).val(), 10 ), p);
|
||||||
|
File diff suppressed because one or more lines are too long
2
dist/js/jquery.tablesorter.combined.js
vendored
2
dist/js/jquery.tablesorter.combined.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! tablesorter (FORK) - updated 06-30-2015 (v2.22.2)*/
|
/*! tablesorter (FORK) - updated 07-14-2015 (v2.22.2)*/
|
||||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||||
(function(factory) {
|
(function(factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
2
dist/js/jquery.tablesorter.combined.min.js
vendored
2
dist/js/jquery.tablesorter.combined.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/jquery.tablesorter.widgets.js
vendored
2
dist/js/jquery.tablesorter.widgets.js
vendored
@ -1,4 +1,4 @@
|
|||||||
/*! tablesorter (FORK) - updated 06-30-2015 (v2.22.2)*/
|
/*! tablesorter (FORK) - updated 07-14-2015 (v2.22.2)*/
|
||||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||||
(function(factory) {
|
(function(factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
2
dist/js/jquery.tablesorter.widgets.min.js
vendored
2
dist/js/jquery.tablesorter.widgets.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-pager.min.js
vendored
2
dist/js/widgets/widget-pager.min.js
vendored
File diff suppressed because one or more lines are too long
2
dist/js/widgets/widget-sort2Hash.min.js
vendored
Normal file
2
dist/js/widgets/widget-sort2Hash.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/*! Widget: sort2Hash */
|
||||||
|
!function(a){"use strict";var b=a.tablesorter||{},c={init:function(a,b){var d,e,f,g,h,i=c.getSort(a,b);if(i){for(d=i.split(b.sort2Hash_separator),f=d.length,i=[],e=0;f>e;e++)g=d[e++],h=d[e],"undefined"!=typeof h&&i.push([g,h]);i.length&&(a.sortList=i)}a.$table.on("sortEnd.sort2hash",function(){c.setHash(a,b)})},getTableId:function(b,c){return c.sort2Hash_tableId||b.table.id||"table"+a("table").index(b.$table)},getSort:function(a,b,d){var e=c.getTableId(a,b).replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),f=new RegExp("[\\#&]"+e+"=([^&]*)").exec(window.location.hash);return null===f?"":(d&&(window.location.hash=window.location.hash.replace("&"+e+"="+f[1],"")),f[1])},setHash:function(a,b){var d=c.getTableId(a,b)+"=",e=a.sortList||[],f=e.length;f&&(c.getSort(a,b,!0),window.location.hash+=(window.location.hash.length?"":b.sort2Hash_hash)+"&"+d+[].concat.apply([],e).join(b.sort2Hash_separator))}};b.addWidget({id:"sort2Hash",options:{sort2Hash_hash:"#",sort2Hash_separator:"-",sort2Hash_tableId:null},init:function(a,b,d,e){c.init(d,e)},remove:function(a,b){b.$table.off("sortEnd.sort2hash")}})}(jQuery);
|
@ -4,7 +4,7 @@
|
|||||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||||
*/
|
*/
|
||||||
/*! tablesorter (FORK) - updated 06-30-2015 (v2.22.2)*/
|
/*! tablesorter (FORK) - updated 07-14-2015 (v2.22.2)*/
|
||||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||||
(function(factory) {
|
(function(factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██▀▀ ▀▀▀▀██
|
||||||
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
█████▀ ▀████▀ ██ ██ ▀████▀ ██ ██ ██ ██ ▀████▀ █████▀ ██ ██ █████▀
|
||||||
*/
|
*/
|
||||||
/*! tablesorter (FORK) - updated 06-30-2015 (v2.22.2)*/
|
/*! tablesorter (FORK) - updated 07-14-2015 (v2.22.2)*/
|
||||||
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
/* Includes widgets ( storage,uitheme,columns,filter,stickyHeaders,resizable,saveSort ) */
|
||||||
(function(factory) {
|
(function(factory) {
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
|
@ -232,11 +232,12 @@ tsp = ts.pager = {
|
|||||||
var ctrls, fxn,
|
var ctrls, fxn,
|
||||||
p = c.pager,
|
p = c.pager,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
|
namespace = c.namespace + 'pager',
|
||||||
s = wo.pager_selectors;
|
s = wo.pager_selectors;
|
||||||
|
|
||||||
c.$table
|
c.$table
|
||||||
.off( $.trim(p.events.split(' ').join('.pager ')) )
|
.off( $.trim(p.events.split(' ').join(namespace + ' ')) )
|
||||||
.on('filterInit.pager filterStart.pager', function(e, filters) {
|
.on('filterInit filterStart '.split(' ').join(namespace + ' '), function(e, filters) {
|
||||||
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
p.currentFilters = $.isArray(filters) ? filters : c.$table.data('lastSearch');
|
||||||
// don't change page if filters are the same (pager updating, etc)
|
// don't change page if filters are the same (pager updating, etc)
|
||||||
if (e.type === 'filterStart' && wo.pager_pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) {
|
if (e.type === 'filterStart' && wo.pager_pageReset !== false && (c.lastCombinedFilter || '') !== (p.currentFilters || []).join('')) {
|
||||||
@ -244,7 +245,7 @@ tsp = ts.pager = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
// update pager after filter widget completes
|
// update pager after filter widget completes
|
||||||
.on('filterEnd.pager sortEnd.pager', function() {
|
.on('filterEnd sortEnd '.split(' ').join(namespace + ' '), function() {
|
||||||
p.currentFilters = c.$table.data('lastSearch');
|
p.currentFilters = c.$table.data('lastSearch');
|
||||||
if (p.initialized || p.initializing) {
|
if (p.initialized || p.initializing) {
|
||||||
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
|
if (c.delayInit && c.rowsCopy && c.rowsCopy.length === 0) {
|
||||||
@ -256,19 +257,19 @@ tsp = ts.pager = {
|
|||||||
c.$table.trigger('applyWidgets');
|
c.$table.trigger('applyWidgets');
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.on('disable.pager', function(e){
|
.on('disable' + namespace, function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
tsp.showAllRows(table, c);
|
tsp.showAllRows(table, c);
|
||||||
})
|
})
|
||||||
.on('enable.pager', function(e){
|
.on('enable' + namespace, function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
tsp.enablePager(table, c, true);
|
tsp.enablePager(table, c, true);
|
||||||
})
|
})
|
||||||
.on('destroy.pager', function(e, refreshing){
|
.on('destroy' + namespace, function(e, refreshing){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
tsp.destroyPager(table, c, refreshing);
|
tsp.destroyPager(table, c, refreshing);
|
||||||
})
|
})
|
||||||
.on('updateComplete.pager', function(e, table, triggered){
|
.on('updateComplete' + namespace, function(e, table, triggered){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
|
// table can be unintentionally undefined in tablesorter v2.17.7 and earlier
|
||||||
// don't recalculate total rows/pages if using ajax
|
// don't recalculate total rows/pages if using ajax
|
||||||
@ -291,13 +292,13 @@ tsp = ts.pager = {
|
|||||||
c.$table.trigger('applyWidgets');
|
c.$table.trigger('applyWidgets');
|
||||||
tsp.updatePageDisplay(table, c);
|
tsp.updatePageDisplay(table, c);
|
||||||
})
|
})
|
||||||
.on('pageSize.pager refreshComplete.pager', function(e,v){
|
.on('pageSize refreshComplete '.split(' ').join(namespace + ' '), function(e,v){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
tsp.setPageSize(table, parseInt(v, 10) || p.setSize || 10, c);
|
tsp.setPageSize(table, parseInt(v, 10) || p.setSize || 10, c);
|
||||||
tsp.hideRows(table, c);
|
tsp.hideRows(table, c);
|
||||||
tsp.updatePageDisplay(table, c, false);
|
tsp.updatePageDisplay(table, c, false);
|
||||||
})
|
})
|
||||||
.on('pageSet.pager pagerUpdate.pager', function(e,v){
|
.on('pageSet pagerUpdate '.split(' ').join(namespace + ' '), function(e,v){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
// force pager refresh
|
// force pager refresh
|
||||||
if (e.type === 'pagerUpdate') {
|
if (e.type === 'pagerUpdate') {
|
||||||
@ -308,7 +309,7 @@ tsp = ts.pager = {
|
|||||||
tsp.moveToPage(table, p, true);
|
tsp.moveToPage(table, p, true);
|
||||||
tsp.updatePageDisplay(table, c, false);
|
tsp.updatePageDisplay(table, c, false);
|
||||||
})
|
})
|
||||||
.on('pageAndSize.pager', function(e, page, size){
|
.on('pageAndSize' + namespace, function(e, page, size){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
p.page = (parseInt(page, 10) || 1) - 1;
|
p.page = (parseInt(page, 10) || 1) - 1;
|
||||||
tsp.setPageSize(table, parseInt(size, 10) || p.setSize || 10, c);
|
tsp.setPageSize(table, parseInt(size, 10) || p.setSize || 10, c);
|
||||||
@ -325,8 +326,8 @@ tsp = ts.pager = {
|
|||||||
}
|
}
|
||||||
p.$container.find(ctrls.join(','))
|
p.$container.find(ctrls.join(','))
|
||||||
.attr("tabindex", 0)
|
.attr("tabindex", 0)
|
||||||
.off('click.pager')
|
.off('click' + namespace)
|
||||||
.on('click.pager', function(e){
|
.on('click' + namespace, function(e){
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
var i,
|
var i,
|
||||||
$c = $(this),
|
$c = $(this),
|
||||||
@ -343,8 +344,8 @@ tsp = ts.pager = {
|
|||||||
|
|
||||||
if ( p.$goto.length ) {
|
if ( p.$goto.length ) {
|
||||||
p.$goto
|
p.$goto
|
||||||
.off('change.pager')
|
.off('change' + namespace)
|
||||||
.on('change.pager', function(){
|
.on('change' + namespace, function(){
|
||||||
p.page = $(this).val() - 1;
|
p.page = $(this).val() - 1;
|
||||||
tsp.moveToPage(table, p, true);
|
tsp.moveToPage(table, p, true);
|
||||||
tsp.updatePageDisplay(table, c, false);
|
tsp.updatePageDisplay(table, c, false);
|
||||||
@ -357,8 +358,8 @@ tsp = ts.pager = {
|
|||||||
// setting an option as selected appears to cause issues with initial page size
|
// setting an option as selected appears to cause issues with initial page size
|
||||||
p.$size.find('option').removeAttr('selected');
|
p.$size.find('option').removeAttr('selected');
|
||||||
p.$size
|
p.$size
|
||||||
.off('change.pager')
|
.off('change' + namespace)
|
||||||
.on('change.pager', function() {
|
.on('change' + namespace, function() {
|
||||||
p.$size.val( $(this).val() ); // in case there are more than one pagers
|
p.$size.val( $(this).val() ); // in case there are more than one pagers
|
||||||
if ( !$(this).hasClass(wo.pager_css.disabled) ) {
|
if ( !$(this).hasClass(wo.pager_css.disabled) ) {
|
||||||
tsp.setPageSize(table, parseInt( $(this).val(), 10 ), c);
|
tsp.setPageSize(table, parseInt( $(this).val(), 10 ), c);
|
||||||
@ -414,6 +415,7 @@ tsp = ts.pager = {
|
|||||||
var s, t, $out, options, indx, len,
|
var s, t, $out, options, indx, len,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
p = c.pager,
|
p = c.pager,
|
||||||
|
namespace = c.namespace + 'pager',
|
||||||
sz = p.size || p.setSize || 10; // don't allow dividing by zero
|
sz = p.size || p.setSize || 10; // don't allow dividing by zero
|
||||||
if (wo.pager_countChildRows) { t.push(c.cssChildRow); }
|
if (wo.pager_countChildRows) { t.push(c.cssChildRow); }
|
||||||
p.$size.add(p.$goto).removeClass(wo.pager_css.disabled).removeAttr('disabled').attr('aria-disabled', 'false');
|
p.$size.add(p.$goto).removeClass(wo.pager_css.disabled).removeAttr('disabled').attr('aria-disabled', 'false');
|
||||||
@ -462,10 +464,10 @@ tsp = ts.pager = {
|
|||||||
if ($out.length) {
|
if ($out.length) {
|
||||||
$out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
|
$out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s);
|
||||||
// rebind startRow/page inputs
|
// rebind startRow/page inputs
|
||||||
$out.find('.ts-startRow, .ts-page').off('change.pager').on('change.pager', function(){
|
$out.find('.ts-startRow, .ts-page').off('change' + namespace).on('change' + namespace, function(){
|
||||||
var v = $(this).val(),
|
var v = $(this).val(),
|
||||||
pg = $(this).hasClass('ts-startRow') ? Math.floor( v/p.size ) + 1 : v;
|
pg = $(this).hasClass('ts-startRow') ? Math.floor( v/p.size ) + 1 : v;
|
||||||
c.$table.trigger('pageSet.pager', [ pg ]);
|
c.$table.trigger('pageSet' + namespace, [ pg ]);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -578,55 +580,63 @@ tsp = ts.pager = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
hideRows: function(table, c){
|
hideRows: function(table, c){
|
||||||
if (!c.widgetOptions.pager_ajaxUrl) {
|
if ( !c.widgetOptions.pager_ajaxUrl ) {
|
||||||
var i,
|
var tbodyIndex, rowIndex, $rows, len, lastIndex,
|
||||||
lastIndex = 0,
|
|
||||||
p = c.pager,
|
p = c.pager,
|
||||||
wo = c.widgetOptions,
|
wo = c.widgetOptions,
|
||||||
rows = c.$tbodies.eq(0).children('tr'),
|
tbodyLen = c.$tbodies.length,
|
||||||
l = rows.length,
|
start = ( p.page * p.size ),
|
||||||
s = ( p.page * p.size ),
|
end = start + p.size,
|
||||||
e = s + p.size,
|
filtr = wo && wo.filter_filteredRow || 'filtered',
|
||||||
f = wo && wo.filter_filteredRow || 'filtered',
|
|
||||||
last = 0, // for cache indexing
|
last = 0, // for cache indexing
|
||||||
j = 0; // size counter
|
size = 0; // size counter
|
||||||
p.cacheIndex = [];
|
p.cacheIndex = [];
|
||||||
for ( i = 0; i < l; i++ ){
|
for ( tbodyIndex = 0; tbodyIndex < tbodyLen; tbodyIndex++ ) {
|
||||||
if ( !rows[i].className.match(f) ) {
|
$rows = c.$tbodies.eq( tbodyIndex ).children( 'tr' );
|
||||||
if (j === s && rows[i].className.match(c.cssChildRow)) {
|
len = $rows.length;
|
||||||
|
lastIndex = 0;
|
||||||
|
last = 0; // for cache indexing
|
||||||
|
size = 0; // size counter
|
||||||
|
for ( rowIndex = 0; rowIndex < len; rowIndex++ ) {
|
||||||
|
if ( !$rows[ rowIndex ].className.match( filtr ) ) {
|
||||||
|
if ( size === start && $rows[ rowIndex ].className.match( c.cssChildRow ) ) {
|
||||||
// hide child rows @ start of pager (if already visible)
|
// hide child rows @ start of pager (if already visible)
|
||||||
rows[i].style.display = 'none';
|
$rows[ rowIndex ].style.display = 'none';
|
||||||
} else {
|
} else {
|
||||||
rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
|
$rows[ rowIndex ].style.display = ( size >= start && size < end ) ? '' : 'none';
|
||||||
if ( last !== j && j >= s && j < e ) {
|
if ( last !== size && size >= start && size < end ) {
|
||||||
p.cacheIndex.push(i);
|
p.cacheIndex.push( rowIndex );
|
||||||
last = j;
|
last = size;
|
||||||
}
|
}
|
||||||
// don't count child rows
|
// don't count child rows
|
||||||
j += rows[i].className.match(c.cssChildRow + '|' + c.selectorRemove.slice(1)) && !wo.pager_countChildRows ? 0 : 1;
|
size += $rows[ rowIndex ].className
|
||||||
if ( j === e && rows[i].style.display !== 'none' && rows[i].className.match(ts.css.cssHasChild) ) {
|
.match( c.cssChildRow + '|' + c.selectorRemove.slice( 1 ) ) && !wo.pager_countChildRows ? 0 : 1;
|
||||||
lastIndex = i;
|
if ( size === end && $rows[ rowIndex ].style.display !== 'none' &&
|
||||||
|
$rows[ rowIndex ].className.match( ts.css.cssHasChild ) ) {
|
||||||
|
lastIndex = rowIndex;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// add any attached child rows to last row of pager. Fixes part of issue #396
|
// 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) ) {
|
if ( lastIndex > 0 && $rows[ lastIndex ].className.match( ts.css.cssHasChild ) ) {
|
||||||
while ( ++lastIndex < l && rows[lastIndex].className.match(c.cssChildRow) ) {
|
while ( ++lastIndex < len && $rows[ lastIndex ].className.match( c.cssChildRow ) ) {
|
||||||
rows[lastIndex].style.display = '';
|
$rows[ lastIndex ].style.display = '';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
hideRowsSetup: function(table, c){
|
hideRowsSetup: function(table, c){
|
||||||
var p = c.pager;
|
var p = c.pager,
|
||||||
|
namespace = c.namespace + 'pager';
|
||||||
p.size = parseInt( p.$size.val(), 10 ) || p.size || p.setSize || 10;
|
p.size = parseInt( p.$size.val(), 10 ) || p.size || p.setSize || 10;
|
||||||
$.data(table, 'pagerLastSize', p.size);
|
$.data(table, 'pagerLastSize', p.size);
|
||||||
tsp.pagerArrows(c);
|
tsp.pagerArrows(c);
|
||||||
if ( !c.widgetOptions.pager_removeRows ) {
|
if ( !c.widgetOptions.pager_removeRows ) {
|
||||||
tsp.hideRows(table, c);
|
tsp.hideRows(table, c);
|
||||||
c.$table.on('sortEnd.pager filterEnd.pager', function(){
|
c.$table.on('sortEnd filterEnd '.split(' ').join(namespace + ' '), function(){
|
||||||
tsp.hideRows(table, c);
|
tsp.hideRows(table, c);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -762,14 +772,15 @@ tsp = ts.pager = {
|
|||||||
var counter,
|
var counter,
|
||||||
url = tsp.getAjaxUrl(table, c),
|
url = tsp.getAjaxUrl(table, c),
|
||||||
$doc = $(document),
|
$doc = $(document),
|
||||||
|
namespace = c.namespace + 'pager',
|
||||||
p = c.pager;
|
p = c.pager;
|
||||||
if ( url !== '' ) {
|
if ( url !== '' ) {
|
||||||
if (c.showProcessing) {
|
if (c.showProcessing) {
|
||||||
ts.isProcessing(table, true); // show loading icon
|
ts.isProcessing(table, true); // show loading icon
|
||||||
}
|
}
|
||||||
$doc.on('ajaxError.pager', function(e, xhr, settings, exception) {
|
$doc.on('ajaxError' + namespace, function(e, xhr, settings, exception) {
|
||||||
tsp.renderAjax(null, table, c, xhr, exception);
|
tsp.renderAjax(null, table, c, xhr, exception);
|
||||||
$doc.off('ajaxError.pager');
|
$doc.off('ajaxError' + namespace);
|
||||||
});
|
});
|
||||||
counter = ++p.ajaxCounter;
|
counter = ++p.ajaxCounter;
|
||||||
p.last.ajaxUrl = url; // remember processed url
|
p.last.ajaxUrl = url; // remember processed url
|
||||||
@ -780,7 +791,7 @@ tsp = ts.pager = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
tsp.renderAjax(data, table, c, jqxhr);
|
tsp.renderAjax(data, table, c, jqxhr);
|
||||||
$doc.off('ajaxError.pager');
|
$doc.off('ajaxError' + namespace);
|
||||||
if (typeof p.oldAjaxSuccess === 'function') {
|
if (typeof p.oldAjaxSuccess === 'function') {
|
||||||
p.oldAjaxSuccess(data);
|
p.oldAjaxSuccess(data);
|
||||||
}
|
}
|
||||||
@ -1061,9 +1072,10 @@ tsp = ts.pager = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
destroyPager: function(table, c, refreshing){
|
destroyPager: function(table, c, refreshing){
|
||||||
var p = c.pager;
|
var p = c.pager,
|
||||||
|
namespace = c.namespace + 'pager';
|
||||||
p.initialized = false;
|
p.initialized = false;
|
||||||
c.$table.off( $.trim(p.events.split(' ').join('.pager ')) );
|
c.$table.off( $.trim(p.events.split(' ').join(namespace + ' ')) );
|
||||||
if (refreshing) { return; }
|
if (refreshing) { return; }
|
||||||
tsp.showAllRows(table, c);
|
tsp.showAllRows(table, c);
|
||||||
p.$container.hide(); // hide pager
|
p.$container.hide(); // hide pager
|
||||||
|
Loading…
Reference in New Issue
Block a user