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

View File

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