CssStickyHeaders: reinitialize after update. Fixes #1553

This commit is contained in:
Rob Garrison 2018-06-16 15:42:51 -05:00
parent ab537dcc40
commit 4b98036045

View File

@ -1,4 +1,4 @@
/*! Widget: cssStickyHeaders - updated 5/24/2017 (v2.28.11) *//*
/*! Widget: cssStickyHeaders - updated 6/16/2018 (v2.30.6) *//*
* Requires a modern browser, tablesorter v2.8+
*/
/*jshint jquery:true, unused:false */
@ -7,17 +7,7 @@
var ts = $.tablesorter;
ts.addWidget({
id: 'cssStickyHeaders',
priority: 10,
options: {
cssStickyHeaders_offset : 0,
cssStickyHeaders_addCaption : false,
// jQuery selector or object to attach sticky header to
cssStickyHeaders_attachTo : null,
cssStickyHeaders_filteredToTop : true
},
init : function(table, thisWidget, c, wo) {
function cssStickyHeadersInit(c, wo) {
var offst, adjustY,
$table = c.$table,
$attach = $(wo.cssStickyHeaders_attachTo),
@ -135,21 +125,37 @@
});
$table
.unbind( ('filterEnd' + namespace).replace(/\s+/g, ' ') )
.unbind( ('filterEnd updateComplete '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
.bind('filterEnd' + namespace, function() {
if (wo.cssStickyHeaders_filteredToTop) {
// scroll top of table into view
window.scrollTo(0, $table.position().top);
}
})
.bind('updateComplete' + namespace, function() {
cssStickyHeadersInit(c, c.widgetOptions);
});
}
ts.addWidget({
id: 'cssStickyHeaders',
priority: 10,
options: {
cssStickyHeaders_offset : 0,
cssStickyHeaders_addCaption : false,
// jQuery selector or object to attach sticky header to
cssStickyHeaders_attachTo : null,
cssStickyHeaders_filteredToTop : true
},
init : function(table, thisWidget, c, wo) {
cssStickyHeadersInit(c, wo);
},
remove: function(table, c, wo, refreshing) {
if (refreshing) { return; }
var namespace = c.namespace + 'cssstickyheader ';
$(window).unbind( ('scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') );
c.$table
.unbind( ('filterEnd scroll resize '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
.unbind( ('filterEnd scroll resize updateComplete '.split(' ').join(namespace)).replace(/\s+/g, ' ') )
.add( c.$table.children('thead').children().children() )
.children('thead, caption').css({
'transform' : '',