updated pager plugin - fixes #151

This commit is contained in:
Mottie 2012-10-13 14:41:34 -05:00
parent 9087cdaf22
commit 597ec7d768
2 changed files with 31 additions and 18 deletions

View File

@ -17,7 +17,8 @@ td.tablesorter-pager {
/* pager output text */ /* pager output text */
.tablesorter-pager .pagedisplay { .tablesorter-pager .pagedisplay {
padding: 0 5px 0 5px; padding: 0 5px 0 5px;
width: 50px; width: auto;
white-space: nowrap;
text-align: center; text-align: center;
} }

View File

@ -148,16 +148,18 @@
}, },
hideRows = function(table, c){ hideRows = function(table, c){
var i, if (!c.ajaxUrl) {
rows = $('tr:not(.' + table.config.cssChildRow + ')', table.tBodies), var i,
l = rows.length, rows = $('tr:not(.' + table.config.cssChildRow + ')', table.tBodies),
s = ( c.page * c.size ), l = rows.length,
e = s + c.size, s = ( c.page * c.size ),
j = 0; // size counter e = s + c.size,
for ( i = 0; i < l; i++ ){ j = 0; // size counter
if (!/filtered/.test(rows[i].className)) { for ( i = 0; i < l; i++ ){
rows[i].style.display = ( j >= s && j < e ) ? '' : 'none'; if (!/filtered/.test(rows[i].className)) {
j++; rows[i].style.display = ( j >= s && j < e ) ? '' : 'none';
j++;
}
} }
} }
}, },
@ -180,9 +182,10 @@
// ajaxProcessing result: [ total, rows, headers ] // ajaxProcessing result: [ total, rows, headers ]
var i, j, hsh, $f, $sh, var i, j, hsh, $f, $sh,
$t = $(table), $t = $(table),
$b = $(table.tBodies).filter(':not(.' + table.config.cssInfoBlock + ')'), tc = table.config,
$b = $(table.tBodies).filter(':not(.' + tc.cssInfoBlock + ')'),
hl = $t.find('thead th').length, tds = '', hl = $t.find('thead th').length, tds = '',
err = '<tr class="remove-me"><td style="text-align: center;" colspan="' + hl + '">' + err = '<tr class="' + tc.selectorRemove + '"><td style="text-align: center;" colspan="' + hl + '">' +
(exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '</td></tr>', (exception ? exception.message + ' (' + exception.name + ')' : 'No rows found') + '</td></tr>',
result = c.ajaxProcessing(data) || [ 0, [] ], result = c.ajaxProcessing(data) || [ 0, [] ],
d = result[1] || [], d = result[1] || [],
@ -201,13 +204,22 @@
// only add new header text if the length matches // only add new header text if the length matches
if ( th && th.length === hl ) { if ( th && th.length === hl ) {
hsh = $t.hasClass('hasStickyHeaders'); hsh = $t.hasClass('hasStickyHeaders');
$sh = $t.find('.' + ((c.widgetOptions && c.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader')); $sh = $t.find('.' + ((tc.widgetOptions && tc.widgetOptions.stickyHeaders) || 'tablesorter-stickyheader'));
$f = $t.find('tfoot tr:first').children(); $f = $t.find('tfoot tr:first').children();
$t.find('thead tr.tablesorter-header th').each(function(j){ $t.find('th.' + tc.cssHeader).each(function(j){
var $t = $(this), var $t = $(this), tar, icn;
// add new test within the first span it finds, or just in the header // add new test within the first span it finds, or just in the header
tar = ( $t.find('span').length ) ? $t.find('span:first') : $t; if ( $t.find('.' + tc.cssIcon).length ) {
tar.html( th[j] ); icn = $t.find('.' + tc.cssIcon).clone(true);
$t.find('.tablesorter-header-inner').html( th[j] ).append(icn);
if ( hsh && $sh.length ) {
icn = $sh.find('th').eq(j).find('.' + tc.cssIcon).clone(true);
$sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] ).append(icn);
}
} else {
$t.find('.tablesorter-header-inner').html( th[j] );
$sh.find('th').eq(j).find('.tablesorter-header-inner').html( th[j] );
}
$f.eq(j).html( th[j] ); $f.eq(j).html( th[j] );
// update sticky headers // update sticky headers
if ( hsh && $sh.length ){ if ( hsh && $sh.length ){