Pager: apply fixedHeight patch to widget & code cleanup

This commit is contained in:
Rob Garrison 2017-06-08 19:09:28 -05:00
parent 6d486940e4
commit e12785b92c
2 changed files with 19 additions and 11 deletions

View File

@ -321,20 +321,22 @@
},
fixHeight = function(table, p) {
var d, h,
var d, h, bs,
c = table.config,
$b = c.$tbodies.eq(0);
$b.find('tr.pagerSavedHeightSpacer').remove();
if (p.fixedHeight && !p.isDisabled) {
h = $.data(table, 'pagerSavedHeight');
if (h) {
var bs = 0;
if($(table).css('border-spacing').split(" ").length>1){
bs = $(table).css('border-spacing').split(" ")[1].replace(/[^-\d\.]/g, '');
bs = 0;
if ($(table).css('border-spacing').split(' ').length > 1) {
bs = $(table).css('border-spacing').split(' ')[1].replace(/[^-\d\.]/g, '');
}
d = h - $b.height()+(bs*p.size)-bs;
if ( d > 5 && $.data(table, 'pagerLastSize') === p.size &&
$b.children('tr:visible').length < (p.size === 'all' ? p.totalRows : p.size) ) {
d = h - $b.height() + (bs * p.size) - bs;
if (
d > 5 && $.data(table, 'pagerLastSize') === p.size &&
$b.children('tr:visible').length < (p.size === 'all' ? p.totalRows : p.size)
) {
$b.append('<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice(1) + '" style="height:' + d + 'px;"></tr>');
}
}

View File

@ -611,7 +611,7 @@
},
fixHeight: function( c ) {
var d, h,
var d, h, bs,
table = c.table,
p = c.pager,
wo = c.widgetOptions,
@ -620,9 +620,15 @@
if ( wo.pager_fixedHeight && !p.isDisabled ) {
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 === 'all' ? p.totalRows : p.size ) ) {
bs = 0;
if ( $(table).css('border-spacing').split(' ').length > 1 ) {
bs = $(table).css('border-spacing').split(' ')[1].replace( /[^-\d\.]/g, '' );
}
d = h - $b.height() + (bs * p.size) - bs;
if (
d > 5 && $.data( table, 'pagerLastSize' ) === p.size &&
$b.children( 'tr:visible' ).length < ( p.size === 'all' ? p.totalRows : p.size )
) {
$b.append( '<tr class="pagerSavedHeightSpacer ' + c.selectorRemove.slice( 1 ) +
'" style="height:' + d + 'px;"></tr>' );
}