mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
Widgets: update remove function
columnSelector, cssStickyHeaders, pager, repeatHeaders, saveSort & stickyHeaders
This commit is contained in:
parent
43d0bd3fdb
commit
19b69c9ac3
@ -1859,11 +1859,11 @@ ts.addWidget({
|
||||
.unbind( 'pagerComplete filterEnd '.split(' ').join(namespace) )
|
||||
.next('.' + ts.css.stickyWrap).remove();
|
||||
if (wo.$sticky && wo.$sticky.length) { wo.$sticky.remove(); } // remove cloned table
|
||||
// don't unbind if any table on the page still has stickyheaders applied
|
||||
if (!$('.hasStickyHeaders').length) {
|
||||
$(window).add(wo.stickyHeaders_xScroll).add(wo.stickyHeaders_yScroll).add(wo.stickyHeaders_attachTo)
|
||||
.unbind( 'scroll resize '.split(' ').join(namespace) );
|
||||
}
|
||||
$(window)
|
||||
.add(wo.stickyHeaders_xScroll)
|
||||
.add(wo.stickyHeaders_yScroll)
|
||||
.add(wo.stickyHeaders_attachTo)
|
||||
.unbind( 'scroll resize '.split(' ').join(namespace) );
|
||||
ts.addHeaderResizeEvent(table, false);
|
||||
}
|
||||
});
|
||||
@ -2091,7 +2091,8 @@ ts.addWidget({
|
||||
}
|
||||
}
|
||||
},
|
||||
remove: function(table) {
|
||||
remove: function(table, c) {
|
||||
c.$table.removeClass('hasSaveSort');
|
||||
// clear storage
|
||||
if (ts.storage) { ts.storage( table, 'tablesorter-savesort', '' ); }
|
||||
}
|
||||
|
@ -344,7 +344,8 @@ ts.addWidget({
|
||||
init: function(table, thisWidget, c, wo) {
|
||||
tsColSel.init(table, c, wo);
|
||||
},
|
||||
remove: function(table, c){
|
||||
remove: function(table, c, wo, refreshing) {
|
||||
if (refreshing) { return; }
|
||||
var csel = c.selector;
|
||||
csel.$container.empty();
|
||||
if (csel.$popup) { csel.$popup.empty(); }
|
||||
|
@ -134,7 +134,8 @@
|
||||
});
|
||||
|
||||
},
|
||||
remove: function(table, c, wo){
|
||||
remove: function(table, c, wo, refreshing) {
|
||||
if (refreshing) { return; }
|
||||
var namespace = c.namespace + 'cssstickyheader ';
|
||||
$(window).unbind('scroll resize '.split(' ').join(namespace));
|
||||
c.$table
|
||||
|
@ -111,8 +111,8 @@ ts.addWidget({
|
||||
}
|
||||
tsp.moveToPage(table, c.pager, false);
|
||||
},
|
||||
remove: function(table, c, wo, temp){
|
||||
tsp.destroyPager(table, c, temp);
|
||||
remove: function(table, c, wo, refreshing){
|
||||
tsp.destroyPager(table, c, refreshing);
|
||||
}
|
||||
});
|
||||
|
||||
@ -141,6 +141,7 @@ tsp = ts.pager = {
|
||||
last: {},
|
||||
// save original pager size
|
||||
setSize: wo.pager_size,
|
||||
setPage: wo.pager_startPage,
|
||||
events: 'filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete ' +
|
||||
'pageSize pageSet pageAndSize pagerUpdate '
|
||||
}, c.pager);
|
||||
@ -166,7 +167,7 @@ tsp = ts.pager = {
|
||||
p.initializing = true;
|
||||
if (wo.pager_savePages && ts.storage) {
|
||||
t = ts.storage(table, wo.pager_storageKey) || {}; // fixes #387
|
||||
p.page = isNaN(t.page) ? p.page : t.page;
|
||||
p.page = ( isNaN(t.page) ? p.page : t.page ) || p.setPage || 1;
|
||||
p.size = ( isNaN(t.size) ? p.size : t.size ) || p.setSize || 10;
|
||||
$.data(table, 'pagerLastSize', p.size);
|
||||
}
|
||||
@ -257,9 +258,9 @@ tsp = ts.pager = {
|
||||
e.stopPropagation();
|
||||
tsp.enablePager(table, c, true);
|
||||
})
|
||||
.on('destroy.pager', function(e, tmp){
|
||||
.on('destroy.pager', function(e, refreshing){
|
||||
e.stopPropagation();
|
||||
tsp.destroyPager(table, c, tmp);
|
||||
tsp.destroyPager(table, c, refreshing);
|
||||
})
|
||||
.on('updateComplete.pager', function(e, table, triggered){
|
||||
e.stopPropagation();
|
||||
@ -1005,15 +1006,15 @@ tsp = ts.pager = {
|
||||
tsp.moveToPage(table, p, true);
|
||||
},
|
||||
|
||||
destroyPager: function(table, c, tmp){
|
||||
destroyPager: function(table, c, refreshing){
|
||||
var p = c.pager;
|
||||
tsp.showAllRows(table, c);
|
||||
p.initialized = false;
|
||||
if (tmp) { return; }
|
||||
c.$table.off(p.events.split(' ').join('.pager '));
|
||||
if (refreshing) { return; }
|
||||
tsp.showAllRows(table, c);
|
||||
p.$container.hide(); // hide pager
|
||||
c.appender = null; // remove pager appender function
|
||||
delete table.config.rowsCopy;
|
||||
c.$table.off(p.events.split(' ').join('.pager '));
|
||||
if (ts.storage) {
|
||||
ts.storage(table, c.widgetOptions.pager_storageKey, '');
|
||||
}
|
||||
|
@ -4,10 +4,10 @@
|
||||
*/
|
||||
/*global jQuery: false */
|
||||
;(function($){
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
$.tablesorter.addWidget({
|
||||
id: "repeatHeaders",
|
||||
id: 'repeatHeaders',
|
||||
priority: 10,
|
||||
options: {
|
||||
rowsToSkip : 4
|
||||
@ -18,11 +18,12 @@
|
||||
// cache and collect all TH headers
|
||||
if (!wo.repeatHeaders) {
|
||||
h = '<tr class="repeated-header remove-me">';
|
||||
$.each(c.headerContent, function(i,t) {
|
||||
h += '<th>' + t + '</th>';
|
||||
});
|
||||
// "remove-me" class was added in case the table needs to be updated, the "remove-me" rows will be
|
||||
// removed prior to the update to prevent including the rows in the update - see "selectorRemove" option
|
||||
for (i = 0; i < c.columns; i++) {
|
||||
// only get the headerContent text
|
||||
h += '<th>' + $.trim( c.$headers.eq(i).text() ) + '</th>';
|
||||
}
|
||||
// 'remove-me' class was added in case the table needs to be updated, the 'remove-me' rows will be
|
||||
// removed prior to the update to prevent including the rows in the update - see 'selectorRemove' option
|
||||
wo.repeatHeaders = h + '</tr>';
|
||||
}
|
||||
|
||||
@ -30,10 +31,10 @@
|
||||
skip = wo && wo.rowsToSkip || 4;
|
||||
|
||||
// remove appended headers by classname
|
||||
c.$table.find("tr.repeated-header").remove();
|
||||
c.$table.find('tr.repeated-header').remove();
|
||||
$tr = c.$tbodies.find('tr');
|
||||
l = $tr.length;
|
||||
// loop all tr elements and insert a copy of the "headers"
|
||||
// loop all tr elements and insert a copy of the 'headers'
|
||||
for (i = skip; i < l; i += skip) {
|
||||
// insert a copy of the table head every X rows
|
||||
$tr.eq(i).before(wo.repeatHeaders);
|
||||
@ -41,8 +42,9 @@
|
||||
},
|
||||
// this remove function is called when using the refreshWidgets method or when destroying the tablesorter plugin
|
||||
// this function only applies to tablesorter v2.4+
|
||||
remove: function(table, c){
|
||||
c.$table.find("tr.repeated-header").remove();
|
||||
remove: function(table, c, wo){
|
||||
wo.repeatHeaders = '';
|
||||
c.$table.find('tr.repeated-header').remove();
|
||||
}
|
||||
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user