mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
disable/enable pager
This commit is contained in:
parent
1d4ba64632
commit
12177fc971
@ -28,6 +28,34 @@ Included all original [document pages](http://mottie.github.com/tablesorter/docs
|
||||
|
||||
View the [complete listing here](http://mottie.github.com/tablesorter/changelog.txt).
|
||||
|
||||
#### Version 2.0.22 (2011-10-13)
|
||||
|
||||
* Updated the pager plugin:
|
||||
* Fixed a problem that occurred when `removeRows` is set to false - fix for [issue #4](https://github.com/Mottie/tablesorter/issues/4).
|
||||
* Added "disable.pager" and "enable.pager" methods to the pager. These are useful if you want to delete a table row with the pager applied.
|
||||
|
||||
```javascript
|
||||
// Delete a row
|
||||
// this function targets a button with a "remove" class name inside a table row
|
||||
// *************
|
||||
// Use delegate or live because `removeRows` is set to `true` in the demo - hidden rows don't exist
|
||||
$('table').delegate('button.remove', 'click' ,function(){
|
||||
var t = $('table');
|
||||
// disabling the pager will restore all table rows
|
||||
t.trigger('disable.pager');
|
||||
// remove the chosen row
|
||||
$(this).closest('tr').remove();
|
||||
// restore pager
|
||||
t.trigger('enable.pager');
|
||||
});
|
||||
```
|
||||
|
||||
* Fixed the `positionFixed` option (which positions the pager below the table) to now include the `offset` option value.
|
||||
* Fixed the pager arrow buttons so that destroying and enabling the pager multiple times doesn't multiply the number of pages changed.
|
||||
* Updated the pager demo page to allow deleting rows.
|
||||
* General cleanup and added lots of comments in the plugin and demo page on what each pager option does.
|
||||
* Made one minor change to the tablesorter plugin to accomidate the pager plugin using the `removeRows` option.
|
||||
|
||||
#### Version 2.0.21.1 (2011-10-11)
|
||||
|
||||
* Added "stickyHeader" widget to the "jquery.tablesorter.widgets.js" file.
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* tablesorter pager plugin
|
||||
* updated 9/8/2011
|
||||
* updated 11/13/2011
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
@ -8,22 +8,15 @@
|
||||
|
||||
// hide arrows at extremes
|
||||
var pagerArrows = function(c) {
|
||||
var a = 'addClass', r = 'removeClass', d = c.cssDisabled;
|
||||
if (c.updateArrows) {
|
||||
c.container.removeClass(c.cssDisabled);
|
||||
$(c.cssFirst + ',' + c.cssPrev + ',' + c.cssNext + ',' + c.cssLast, c.container).removeClass(c.cssDisabled);
|
||||
if (c.page === 0) {
|
||||
$(c.cssFirst + ',' + c.cssPrev, c.container).addClass(c.cssDisabled);
|
||||
} else if (c.page === c.totalPages - 1) {
|
||||
$(c.cssNext + ',' + c.cssLast, c.container).addClass(c.cssDisabled);
|
||||
}
|
||||
// if the total # of pages is less than the selected number of visible rows, then hide the pager
|
||||
if (c.totalRows < c.size) {
|
||||
c.container.addClass(c.cssDisabled);
|
||||
}
|
||||
c.container[(c.totalRows < c.size) ? a : r](d);
|
||||
$(c.cssFirst + ',' + c.cssPrev, c.container)[(c.page === 0) ? a : r](d);
|
||||
$(c.cssNext + ',' + c.cssLast, c.container)[(c.page === c.totalPages - 1) ? a : r](d);
|
||||
}
|
||||
},
|
||||
|
||||
updatePageDisplay = function(table,c) {
|
||||
updatePageDisplay = function(table, c) {
|
||||
c.startRow = c.size * (c.page) + 1;
|
||||
c.endRow = Math.min(c.totalRows, c.size * (c.page+1));
|
||||
var out = $(c.cssPageDisplay, c.container),
|
||||
@ -47,12 +40,12 @@
|
||||
$(table).trigger('pagerComplete', c);
|
||||
},
|
||||
|
||||
fixPosition = function(table) {
|
||||
var c = table.config, o = $(table);
|
||||
fixPosition = function(table, c) {
|
||||
var o = $(table);
|
||||
if (!c.pagerPositionSet && c.positionFixed) {
|
||||
if (o.offset) {
|
||||
c.container.css({
|
||||
top: o.offset().top + o.height() + 'px',
|
||||
top: o.offset().top + o.height() + c.offset + 'px',
|
||||
position: 'absolute'
|
||||
});
|
||||
}
|
||||
@ -71,25 +64,34 @@
|
||||
}
|
||||
},
|
||||
|
||||
renderTable = function(table,rows) {
|
||||
hideRowsSetup = function(table, c){
|
||||
c.size = parseInt($(c.cssPageSize, c.container).val(), 10);
|
||||
pagerArrows(c);
|
||||
if (!c.removeRows) {
|
||||
hideRows(table, c);
|
||||
$(table).bind('sortEnd.pager', function(){
|
||||
hideRows(table, c);
|
||||
$(table).trigger("applyWidgets");
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
renderTable = function(table, rows, c) {
|
||||
var i, j, o,
|
||||
tableBody,
|
||||
c = table.config,
|
||||
tableBody = $(table.tBodies[0]),
|
||||
l = rows.length,
|
||||
s = (c.page * c.size),
|
||||
e = (s + c.size);
|
||||
$(table).trigger('pagerChange',c);
|
||||
$(table).trigger('pagerChange', c);
|
||||
if (!c.removeRows) {
|
||||
hideRows(table, c);
|
||||
} else {
|
||||
if (e > rows.length ) {
|
||||
e = rows.length;
|
||||
}
|
||||
tableBody = $(table.tBodies[0]);
|
||||
// clear the table body
|
||||
$.tablesorter.clearTableBody(table);
|
||||
for(i = s; i < e; i++) {
|
||||
//tableBody.append(rows[i]);
|
||||
for (i = s; i < e; i++) {
|
||||
o = rows[i];
|
||||
l = o.length;
|
||||
for (j = 0; j < l; j++) {
|
||||
@ -97,144 +99,171 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
fixPosition(table,tableBody);
|
||||
fixPosition(table, tableBody, c);
|
||||
$(table).trigger("applyWidgets");
|
||||
if ( c.page >= c.totalPages ) {
|
||||
moveToLastPage(table);
|
||||
moveToLastPage(table, c);
|
||||
}
|
||||
updatePageDisplay(table,c);
|
||||
updatePageDisplay(table, c);
|
||||
},
|
||||
|
||||
moveToPage = function(table) {
|
||||
var c = table.config;
|
||||
showAllRows = function(table, c){
|
||||
c.lastPage = c.page;
|
||||
c.size = c.totalRows;
|
||||
c.totalPages = 1;
|
||||
renderTable(table, c.rowsCopy, c);
|
||||
},
|
||||
|
||||
moveToPage = function(table, c) {
|
||||
if (c.isDisabled) { return; }
|
||||
if (c.page < 0 || c.page > (c.totalPages-1)) {
|
||||
c.page = 0;
|
||||
}
|
||||
renderTable(table,c.rowsCopy);
|
||||
renderTable(table, c.rowsCopy, c);
|
||||
},
|
||||
|
||||
setPageSize = function(table,size) {
|
||||
var c = table.config;
|
||||
setPageSize = function(table, size, c) {
|
||||
c.size = size;
|
||||
c.totalPages = Math.ceil(c.totalRows / c.size);
|
||||
c.pagerPositionSet = false;
|
||||
moveToPage(table);
|
||||
fixPosition(table);
|
||||
moveToPage(table, c);
|
||||
fixPosition(table, c);
|
||||
},
|
||||
|
||||
moveToFirstPage = function(table) {
|
||||
var c = table.config;
|
||||
moveToFirstPage = function(table, c) {
|
||||
c.page = 0;
|
||||
moveToPage(table);
|
||||
moveToPage(table, c);
|
||||
},
|
||||
|
||||
moveToLastPage = function(table) {
|
||||
var c = table.config;
|
||||
moveToLastPage = function(table, c) {
|
||||
c.page = (c.totalPages-1);
|
||||
moveToPage(table);
|
||||
moveToPage(table, c);
|
||||
},
|
||||
|
||||
moveToNextPage = function(table) {
|
||||
var c = table.config;
|
||||
moveToNextPage = function(table, c) {
|
||||
c.page++;
|
||||
if(c.page >= (c.totalPages-1)) {
|
||||
if (c.page >= (c.totalPages-1)) {
|
||||
c.page = (c.totalPages-1);
|
||||
}
|
||||
moveToPage(table);
|
||||
moveToPage(table, c);
|
||||
},
|
||||
|
||||
moveToPrevPage = function(table) {
|
||||
var c = table.config;
|
||||
moveToPrevPage = function(table, c) {
|
||||
c.page--;
|
||||
if(c.page <= 0) {
|
||||
if (c.page <= 0) {
|
||||
c.page = 0;
|
||||
}
|
||||
moveToPage(table);
|
||||
moveToPage(table, c);
|
||||
},
|
||||
|
||||
destroyPager = function(table){
|
||||
var c = table.config;
|
||||
c.size = c.totalRows;
|
||||
c.totalPages = 1;
|
||||
renderTable(table,c.rowsCopy);
|
||||
// hide pager
|
||||
c.container.hide();
|
||||
c.appender = null;
|
||||
$(table).unbind('destroy.pager sortStart.pager');
|
||||
destroyPager = function(table, c){
|
||||
showAllRows(table, c);
|
||||
c.container.hide(); // hide pager
|
||||
c.appender = null; // remove pager appender function
|
||||
$(table).unbind('destroy.pager sortEnd.pager enable.pager disable.pager');
|
||||
},
|
||||
|
||||
enablePager = function(table, c){
|
||||
c.isDisabled = false;
|
||||
$('table').trigger('update');
|
||||
c.page = c.lastPage || 0;
|
||||
c.totalPages = Math.ceil(c.totalRows / c.size);
|
||||
hideRowsSetup(table, c);
|
||||
};
|
||||
|
||||
this.appender = function(table,rows) {
|
||||
this.appender = function(table, rows) {
|
||||
var c = table.config;
|
||||
c.rowsCopy = rows;
|
||||
c.totalRows = rows.length;
|
||||
c.totalPages = Math.ceil(c.totalRows / c.size);
|
||||
renderTable(table,rows);
|
||||
renderTable(table, rows, c);
|
||||
};
|
||||
|
||||
this.defaults = {
|
||||
size: 10,
|
||||
offset: 0,
|
||||
// target the pager markup
|
||||
container: null,
|
||||
|
||||
// output default: '{page}/{totalPages}'
|
||||
output: '{startRow} to {endRow} of {totalRows} rows', // '{page}/{totalPages}'
|
||||
|
||||
// apply disabled classname to the pager arrows when the rows at either extreme is visible
|
||||
updateArrows: true,
|
||||
|
||||
// starting page of the pager (zero based index)
|
||||
page: 0,
|
||||
|
||||
// Number of visible rows
|
||||
size: 10,
|
||||
|
||||
// if true, moves the pager below the table at a fixed position; so if only 2 rows showing, the pager remains in the same place
|
||||
positionFixed: true,
|
||||
|
||||
// offset added to the pager top, but only when "positionFixed" is true
|
||||
offset: 0,
|
||||
|
||||
// remove rows from the table to speed up the sort of large tables.
|
||||
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
|
||||
removeRows: true, // removing rows in larger tables speeds up the sort
|
||||
|
||||
// css class names of pager arrows
|
||||
cssNext: '.next', // next page arrow
|
||||
cssPrev: '.prev', // previous page arrow
|
||||
cssFirst: '.first', // first page arrow
|
||||
cssLast: '.last', // last page arrow
|
||||
cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
|
||||
cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
|
||||
|
||||
// class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page)
|
||||
cssDisabled: 'disabled', // Note there is no period "." in front of this class name
|
||||
|
||||
// stuff not set by the user
|
||||
totalRows: 0,
|
||||
totalPages: 0,
|
||||
container: null,
|
||||
cssNext: '.next',
|
||||
cssPrev: '.prev',
|
||||
cssFirst: '.first',
|
||||
cssLast: '.last',
|
||||
cssPageDisplay: '.pagedisplay',
|
||||
cssPageSize: '.pagesize',
|
||||
cssDisabled: 'disabled',
|
||||
output: '{page}/{totalPages}', // '{startRow} to {endRow} of {totalRows} rows',
|
||||
updateArrows: false,
|
||||
positionFixed: true,
|
||||
removeRows: true, // removing rows in larger tables speeds up the sort
|
||||
appender: this.appender
|
||||
};
|
||||
|
||||
this.construct = function(settings) {
|
||||
return this.each(function() {
|
||||
var config = $.extend(this.config, $.tablesorterPager.defaults, settings),
|
||||
var c = $.extend(this.config, $.tablesorterPager.defaults, settings),
|
||||
table = this,
|
||||
pager = config.container;
|
||||
pager = c.container;
|
||||
$(this).trigger("appendCache");
|
||||
|
||||
config.size = parseInt($(".pagesize",pager).val(), 10);
|
||||
pagerArrows(config);
|
||||
if (!config.removeRows) {
|
||||
config.appender = null;
|
||||
hideRows(table, config);
|
||||
$(this).bind('sortEnd.pager', function(){
|
||||
hideRows(table, config);
|
||||
$(table).trigger("applyWidgets");
|
||||
hideRowsSetup(table, c);
|
||||
|
||||
$(c.cssFirst,pager).unbind('click.pager').bind('click.pager', function() {
|
||||
moveToFirstPage(table, c);
|
||||
return false;
|
||||
});
|
||||
$(c.cssNext,pager).unbind('click.pager').bind('click.pager', function() {
|
||||
moveToNextPage(table, c);
|
||||
return false;
|
||||
});
|
||||
$(c.cssPrev,pager).unbind('click.pager').bind('click.pager', function() {
|
||||
moveToPrevPage(table, c);
|
||||
return false;
|
||||
});
|
||||
$(c.cssLast,pager).unbind('click.pager').bind('click.pager', function() {
|
||||
moveToLastPage(table, c);
|
||||
return false;
|
||||
});
|
||||
$(c.cssPageSize,pager).unbind('change.pager').bind('change.pager', function() {
|
||||
setPageSize(table, parseInt($(this).val(), 10), c);
|
||||
return false;
|
||||
});
|
||||
|
||||
$(this)
|
||||
.unbind('disable.pager enable.pager destroy.pager')
|
||||
.bind('disable.pager', function(){
|
||||
c.isDisabled = true;
|
||||
showAllRows(table, c);
|
||||
})
|
||||
.bind('enable.pager', function(){
|
||||
enablePager(table, c);
|
||||
})
|
||||
.bind('destroy.pager', function(){
|
||||
destroyPager(table, c);
|
||||
});
|
||||
}
|
||||
|
||||
$(config.cssFirst,pager).click(function() {
|
||||
moveToFirstPage(table);
|
||||
return false;
|
||||
});
|
||||
$(config.cssNext,pager).click(function() {
|
||||
moveToNextPage(table);
|
||||
return false;
|
||||
});
|
||||
$(config.cssPrev,pager).click(function() {
|
||||
moveToPrevPage(table);
|
||||
return false;
|
||||
});
|
||||
$(config.cssLast,pager).click(function() {
|
||||
moveToLastPage(table);
|
||||
return false;
|
||||
});
|
||||
$(config.cssPageSize,pager).change(function() {
|
||||
setPageSize(table,parseInt($(this).val(), 10));
|
||||
return false;
|
||||
});
|
||||
|
||||
$(this).bind('destroy.pager', function(){
|
||||
destroyPager(table);
|
||||
});
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
4
addons/pager/jquery.tablesorter.pager.min.js
vendored
4
addons/pager/jquery.tablesorter.pager.min.js
vendored
@ -1,2 +1,2 @@
|
||||
/* tablesorter pager plugin */
|
||||
(function(d){d.extend({tablesorterPager:new function(){var l=function(a){a.updateArrows&&(a.container.removeClass(a.cssDisabled),d(a.cssFirst+","+a.cssPrev+","+a.cssNext+","+a.cssLast,a.container).removeClass(a.cssDisabled),a.page===0?d(a.cssFirst+","+a.cssPrev,a.container).addClass(a.cssDisabled):a.page===a.totalPages-1&&d(a.cssNext+","+a.cssLast,a.container).addClass(a.cssDisabled),a.totalRows<a.size&&a.container.addClass(a.cssDisabled))},o=function(a,b){b.startRow=b.size*b.page+1;b.endRow=Math.min(b.totalRows, b.size*(b.page+1));var c=d(b.cssPageDisplay,b.container),e=b.output.replace(/\{(page|totalPages|startRow|endRow|totalRows)\}/gi,function(a){return{"{page}":b.page+1,"{totalPages}":b.totalPages,"{startRow}":b.startRow,"{endRow}":b.endRow,"{totalRows}":b.totalRows}[a]});c[0].tagName==="INPUT"?c.val(e):c.html(e);l(b);b.container.show();d(a).trigger("pagerComplete",b)},m=function(a){var b=a.config,a=d(a);if(!b.pagerPositionSet&&b.positionFixed)a.offset&&b.container.css({top:a.offset().top+a.height()+ "px",position:"absolute"}),b.pagerPositionSet=!0},k=function(a,b){var c,e=d("tr",a.tBodies[0]),h=e.length,j=b.page*b.size,f=j+b.size;f>h&&(f=h);for(c=0;c<h;c++)e[c].style.display=c>=j&&c<f?"":"none"},i=function(a,b){var c,e,h,j,f=a.config,g=b.length;c=f.page*f.size;var i=c+f.size;d(a).trigger("pagerChange",f);if(f.removeRows){if(i>b.length)i=b.length;j=d(a.tBodies[0]);for(d.tablesorter.clearTableBody(a);c<i;c++){h=b[c];g=h.length;for(e=0;e<g;e++)j[0].appendChild(h[e])}}else k(a,f);m(a,j);d(a).trigger("applyWidgets"); f.page>=f.totalPages&&n(a);o(a,f)},g=function(a){var b=a.config;if(b.page<0||b.page>b.totalPages-1)b.page=0;i(a,b.rowsCopy)},n=function(a){var b=a.config;b.page=b.totalPages-1;g(a)};this.appender=function(a,b){var c=a.config;c.rowsCopy=b;c.totalRows=b.length;c.totalPages=Math.ceil(c.totalRows/c.size);i(a,b)};this.defaults={size:10,offset:0,page:0,totalRows:0,totalPages:0,container:null,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize", cssDisabled:"disabled",output:"{page}/{totalPages}",updateArrows:!1,positionFixed:!0,removeRows:!0,appender:this.appender};this.construct=function(a){return this.each(function(){var b=d.extend(this.config,d.tablesorterPager.defaults,a),c=this,e=b.container;d(this).trigger("appendCache");b.size=parseInt(d(".pagesize",e).val(),10);l(b);if(!b.removeRows)b.appender=null,k(c,b),d(this).bind("sortEnd.pager",function(){k(c,b);d(c).trigger("applyWidgets")});d(b.cssFirst,e).click(function(){c.config.page= 0;g(c);return!1});d(b.cssNext,e).click(function(){var a=c.config;a.page++;if(a.page>=a.totalPages-1)a.page=a.totalPages-1;g(c);return!1});d(b.cssPrev,e).click(function(){var a=c.config;a.page--;if(a.page<=0)a.page=0;g(c);return!1});d(b.cssLast,e).click(function(){n(c);return!1});d(b.cssPageSize,e).change(function(){var a=parseInt(d(this).val(),10),b=c.config;b.size=a;b.totalPages=Math.ceil(b.totalRows/b.size);b.pagerPositionSet=!1;g(c);m(c);return!1});d(this).bind("destroy.pager",function(){var a= c.config;a.size=a.totalRows;a.totalPages=1;i(c,a.rowsCopy);a.container.hide();a.appender=null;d(c).unbind("destroy.pager sortStart.pager")})})}}});d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery);
|
||||
/* tablesorter pager plugin - updated 11/13/2011 */
|
||||
(function(d){d.extend({tablesorterPager:new function(){var j=function(c){var a=c.cssDisabled;c.updateArrows&&(c.container[c.totalRows<c.size?"addClass":"removeClass"](a),d(c.cssFirst+","+c.cssPrev,c.container)[c.page===0?"addClass":"removeClass"](a),d(c.cssNext+","+c.cssLast,c.container)[c.page===c.totalPages-1?"addClass":"removeClass"](a))},p=function(c,a){a.startRow=a.size*a.page+1;a.endRow=Math.min(a.totalRows,a.size*(a.page+1));var b=d(a.cssPageDisplay,a.container),e=a.output.replace(/\{(page|totalPages|startRow|endRow|totalRows)\}/gi, function(b){return{"{page}":a.page+1,"{totalPages}":a.totalPages,"{startRow}":a.startRow,"{endRow}":a.endRow,"{totalRows}":a.totalRows}[b]});b[0].tagName==="INPUT"?b.val(e):b.html(e);j(a);a.container.show();d(c).trigger("pagerComplete",a)},m=function(c,a){var b=d(c);if(!a.pagerPositionSet&&a.positionFixed)b.offset&&a.container.css({top:b.offset().top+b.height()+a.offset+"px",position:"absolute"}),a.pagerPositionSet=true},k=function(c,a){var b,e=d("tr",c.tBodies[0]),g=e.length,f=a.page*a.size,i=f+ a.size;i>g&&(i=g);for(b=0;b<g;b++)e[b].style.display=b>=f&&b<i?"":"none"},n=function(c,a){a.size=parseInt(d(a.cssPageSize,a.container).val(),10);j(a);a.removeRows||(k(c,a),d(c).bind("sortEnd.pager",function(){k(c,a);d(c).trigger("applyWidgets")}))},h=function(c,a,b){var e,g,h,i=d(c.tBodies[0]),j=a.length;e=b.page*b.size;var l=e+b.size;d(c).trigger("pagerChange",b);if(b.removeRows){if(l>a.length)l=a.length;for(d.tablesorter.clearTableBody(c);e<l;e++){h=a[e];j=h.length;for(g=0;g<j;g++)i[0].appendChild(h[g])}}else k(c, b);m(c,i,b);d(c).trigger("applyWidgets");if(b.page>=b.totalPages)b.page=b.totalPages-1,f(c,b);p(c,b)},o=function(c,a){a.lastPage=a.page;a.size=a.totalRows;a.totalPages=1;h(c,a.rowsCopy,a)},f=function(c,a){if(!a.isDisabled){if(a.page<0||a.page>a.totalPages-1)a.page=0;h(c,a.rowsCopy,a)}};this.appender=function(c,a){var b=c.config;b.rowsCopy=a;b.totalRows=a.length;b.totalPages=Math.ceil(b.totalRows/b.size);h(c,a,b)};this.defaults={container:null,output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:true, page:0,size:10,positionFixed:true,offset:0,removeRows:true,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",totalRows:0,totalPages:0,appender:this.appender};this.construct=function(c){return this.each(function(){var a=d.extend(this.config,d.tablesorterPager.defaults,c),b=this,e=a.container;d(this).trigger("appendCache");n(b,a);d(a.cssFirst,e).unbind("click.pager").bind("click.pager",function(){a.page=0;f(b, a);return false});d(a.cssNext,e).unbind("click.pager").bind("click.pager",function(){a.page++;if(a.page>=a.totalPages-1)a.page=a.totalPages-1;f(b,a);return false});d(a.cssPrev,e).unbind("click.pager").bind("click.pager",function(){a.page--;if(a.page<=0)a.page=0;f(b,a);return false});d(a.cssLast,e).unbind("click.pager").bind("click.pager",function(){a.page=a.totalPages-1;f(b,a);return false});d(a.cssPageSize,e).unbind("change.pager").bind("change.pager",function(){var c=parseInt(d(this).val(),10); a.size=c;a.totalPages=Math.ceil(a.totalRows/a.size);a.pagerPositionSet=false;f(b,a);m(b,a);return false});d(this).unbind("disable.pager enable.pager destroy.pager").bind("disable.pager",function(){a.isDisabled=true;o(b,a)}).bind("enable.pager",function(){a.isDisabled=false;d("table").trigger("update");a.page=a.lastPage||0;a.totalPages=Math.ceil(a.totalRows/a.size);n(b,a)}).bind("destroy.pager",function(){o(b,a);a.container.hide();a.appender=null;d(b).unbind("destroy.pager sortEnd.pager enable.pager disable.pager")})})}}}); d.fn.extend({tablesorterPager:d.tablesorterPager.construct})})(jQuery);
|
||||
|
@ -1,5 +1,32 @@
|
||||
TableSorter Change Log
|
||||
|
||||
Version 2.0.22 (2011-10-13)
|
||||
============================
|
||||
|
||||
* Updated the pager plugin:
|
||||
* Fixed a problem that occurred when `removeRows` is set to false - fix for [issue #4](https://github.com/Mottie/tablesorter/issues/4).
|
||||
* Added "disable.pager" and "enable.pager" methods to the pager. These are useful if you want to delete a table row with the pager applied.
|
||||
|
||||
// Delete a row
|
||||
// this function targets a button with a "remove" class name inside a table row
|
||||
// *************
|
||||
// Use delegate or live because `removeRows` is set to `true` in the demo - hidden rows don't exist
|
||||
$('table').delegate('button.remove', 'click' ,function(){
|
||||
var t = $('table');
|
||||
// disabling the pager will restore all table rows
|
||||
t.trigger('disable.pager');
|
||||
// remove the chosen row
|
||||
$(this).closest('tr').remove();
|
||||
// restore pager
|
||||
t.trigger('enable.pager');
|
||||
});
|
||||
|
||||
* Fixed the `positionFixed` option (which positions the pager below the table) to now include the `offset` option value.
|
||||
* Fixed the pager arrow buttons so that destroying and enabling the pager multiple times doesn't multiply the number of pages changed.
|
||||
* Updated the pager demo page to allow deleting rows.
|
||||
* General cleanup and added lots of comments in the plugin and demo page on what each pager option does.
|
||||
* Made one minor change to the tablesorter plugin to accomidate the pager plugin using the `removeRows` option.
|
||||
|
||||
Version 2.0.21.1 (2011-10-11)
|
||||
============================
|
||||
|
||||
|
@ -45,4 +45,8 @@ span.tip em {padding: 0 2px;background-color: #00ce53; color: #fff; font-size:90
|
||||
div.digg {float: right;}
|
||||
.next-up { padding-top: 10px; font-size: 90%; }
|
||||
.narrow-block { width: 50%; margin: 0 auto; }
|
||||
.spacer { height: 800px; }
|
||||
.spacer { height: 800px; }
|
||||
#pager-demo th.remove { width: 20px; } /* pager demo */
|
||||
#pager-demo button.remove { width: 20px; height: 20px; font-size: 10px; color: #800; }
|
||||
.box { width: 48%; float: left; padding: 0 1%; }
|
||||
.clear { clear: both; }
|
@ -34,17 +34,52 @@
|
||||
|
||||
<script id="js">$(function(){
|
||||
|
||||
// **********************************
|
||||
// Description of ALL pager options
|
||||
// **********************************
|
||||
var pagerOptions = {
|
||||
// target the pager markup
|
||||
|
||||
// target the pager markup - see the HTML block below
|
||||
container: $("#pager"),
|
||||
// output default: '{page}/{totalPages}'
|
||||
|
||||
// output string - default is '{page}/{totalPages}'; possible variables: {page}, {totalPages}, {startRow}, {endRow} and {totalRows}
|
||||
output: '{startRow} to {endRow} ({totalRows})',
|
||||
// apply disabled classname to the pager arrows when the rows at either extreme is visible
|
||||
|
||||
// apply disabled classname to the pager arrows when the rows at either extreme is visible - default is true
|
||||
updateArrows: true,
|
||||
// do not absolutely position the pager
|
||||
positionFixed: false
|
||||
|
||||
// starting page of the pager (zero based index)
|
||||
page: 0,
|
||||
|
||||
// Number of visible rows - default is 10
|
||||
size: 10,
|
||||
|
||||
// if true, moves the pager below the table at a fixed position; so if only 2 rows showing, the pager remains in the same place
|
||||
// default is true
|
||||
positionFixed: false,
|
||||
|
||||
// offset added to the pager top, but only when "positionFixed" is true
|
||||
offset: 0,
|
||||
|
||||
// remove rows from the table to speed up the sort of large tables.
|
||||
// setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
|
||||
removeRows: false,
|
||||
|
||||
// css class names of pager arrows
|
||||
cssNext: '.next', // next page arrow
|
||||
cssPrev: '.prev', // previous page arrow
|
||||
cssFirst: '.first', // go to first page arrow
|
||||
cssLast: '.last', // go to last page arrow
|
||||
cssPageDisplay: '.pagedisplay', // location of where the "output" is displayed
|
||||
cssPageSize: '.pagesize', // page size selector - select dropdown that sets the "size" option
|
||||
|
||||
// class added to arrows when at the extremes (i.e. prev/first arrows are "disabled" when on the first page)
|
||||
cssDisabled: 'disabled' // Note there is no period "." in front of this class name
|
||||
|
||||
};
|
||||
|
||||
// Initialize tablesorter
|
||||
// ***********************
|
||||
$("table")
|
||||
.tablesorter({
|
||||
widthFixed: true,
|
||||
@ -52,9 +87,11 @@
|
||||
})
|
||||
|
||||
// initialize the pager plugin
|
||||
// ****************************
|
||||
.tablesorterPager(pagerOptions)
|
||||
|
||||
// bind to pager events
|
||||
// *********************
|
||||
.bind('pagerChange pagerComplete', function(e,c){
|
||||
var msg = '" event triggered, ' + (e.type === 'pagerChange' ? 'going to' : 'now on') +
|
||||
' page ' + (c.page + 1) + '/' + c.totalPages;
|
||||
@ -64,20 +101,35 @@
|
||||
});
|
||||
|
||||
// Add two new rows using the "addRows" method
|
||||
// the "update" method doesn't work here because not all
|
||||
// rows are present in the table when the pager is applied
|
||||
// the "update" method doesn't work here because not all rows are
|
||||
// present in the table when the pager is applied ("removeRows" is false)
|
||||
// ***********************************************************************
|
||||
$('button:contains(Add)').click(function(){
|
||||
// add two rows
|
||||
var row = '<tr><td>StudentXX</td><td>Mathematics</td><td>male</td><td>33</td><td>39</td><td>54</td><td>73</td></tr>' +
|
||||
'<tr><td>StudentYY</td><td>Mathematics</td><td>female</td><td>83</td><td>89</td><td>84</td><td>83</td></tr>',
|
||||
var row = '<tr><td>StudentXX</td><td>Mathematics</td><td>male</td><td>33</td><td>39</td><td>54</td><td>73</td><td><button class="remove" title="Remove this row">X</button></td></tr>' +
|
||||
'<tr><td>StudentYY</td><td>Mathematics</td><td>female</td><td>83</td><td>89</td><td>84</td><td>83</td><td><button class="remove" title="Remove this row">X</button></td></tr>',
|
||||
$row = $(row);
|
||||
$('table')
|
||||
.find('tbody').append($row)
|
||||
.trigger('addRows', [$row]);
|
||||
});
|
||||
|
||||
// Delete a row
|
||||
// *************
|
||||
$('table').delegate('button.remove', 'click' ,function(){
|
||||
var t = $('table');
|
||||
// disabling the pager will restore all table rows
|
||||
t.trigger('disable.pager');
|
||||
// remove chosen row
|
||||
$(this).closest('tr').remove();
|
||||
// restore pager
|
||||
t.trigger('enable.pager');
|
||||
});
|
||||
|
||||
// Destroy pager
|
||||
// **************
|
||||
$('button:contains(Destroy)').click(function(){
|
||||
// Exterminate, annhilate, destroy! http://www.youtube.com/watch?v=LOqn8FxuyFs
|
||||
$('table').trigger('destroy.pager');
|
||||
|
||||
// fancy disable/enable buttons - not really needed
|
||||
@ -87,9 +139,9 @@
|
||||
});
|
||||
|
||||
// Restore pager
|
||||
// **************
|
||||
$('button:contains(Restore)').click(function(){
|
||||
|
||||
// restore the pager
|
||||
// initialize the pager
|
||||
$('table').tablesorterPager(pagerOptions);
|
||||
|
||||
// fancy disable/enable buttons - not really needed
|
||||
@ -100,7 +152,7 @@
|
||||
|
||||
});</script>
|
||||
</head>
|
||||
<body>
|
||||
<body id="pager-demo">
|
||||
<div id="banner">
|
||||
<h1>table<em>sorter</em></h1>
|
||||
<h2>Pager plugin</h2>
|
||||
@ -113,12 +165,14 @@
|
||||
<p class="tip">
|
||||
<em>NOTE!</em> The following are not part of the original plugin:
|
||||
<ul>
|
||||
<li>This pager plugin can be applied to the original tablesorter, but there is one exception - setting the `removeRows` option to false will break the sort.</li>
|
||||
<li>Added "pagerChange" and "pagerComplete" events in version 2.0.7.</li>
|
||||
<li>Updated pager functions, removed "separator" option, and added output string formatting (e.g. "1 to 10 (50)") to version 2.0.9.</li>
|
||||
<li>Added "cssDisabled" and "pagerArrows" options which controls the look of the pager and arrows when the pager is on the first or last page. Added in version 2.0.9.</li>
|
||||
<li>Added a new "addRows" method to allow adding new rows while the pager is applied to a table. Using "update" would remove all non-visible rows. New in version 2.0.16.</li>
|
||||
<li>New "destroy.pager" method will reveal the entire table, remove the pager functionality, and hide the actual pager. Added in version 2.0.16.</li>
|
||||
<li>Reduced the number of rows in the demo from 1022 to 50, so you don't have to scroll forever (when the pager is destroyed) to see the code below the table (v2.0.16).</li>
|
||||
<li>New "disable.pager" and "enable.pager" methods added to make it easier to add or delete rows from the table. Added in version 2.0.21.2.</li>
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
@ -159,6 +213,7 @@
|
||||
<th>Japanese</th>
|
||||
<th>Calculus</th>
|
||||
<th>Geometry</th>
|
||||
<th class="remove sorter-false"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tfoot>
|
||||
@ -170,6 +225,7 @@
|
||||
<th>Japanese</th>
|
||||
<th>Calculus</th>
|
||||
<th>Geometry</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
<tbody>
|
||||
@ -181,6 +237,7 @@
|
||||
<td>70</td>
|
||||
<td>75</td>
|
||||
<td>80</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student02</td>
|
||||
@ -190,6 +247,7 @@
|
||||
<td>88</td>
|
||||
<td>100</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student03</td>
|
||||
@ -199,6 +257,7 @@
|
||||
<td>95</td>
|
||||
<td>80</td>
|
||||
<td>85</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student04</td>
|
||||
@ -208,6 +267,7 @@
|
||||
<td>55</td>
|
||||
<td>100</td>
|
||||
<td>100</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student05</td>
|
||||
@ -217,6 +277,7 @@
|
||||
<td>80</td>
|
||||
<td>95</td>
|
||||
<td>80</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student06</td>
|
||||
@ -226,6 +287,7 @@
|
||||
<td>99</td>
|
||||
<td>100</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student07</td>
|
||||
@ -235,6 +297,7 @@
|
||||
<td>68</td>
|
||||
<td>90</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student08</td>
|
||||
@ -244,6 +307,7 @@
|
||||
<td>90</td>
|
||||
<td>90</td>
|
||||
<td>85</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student09</td>
|
||||
@ -253,6 +317,7 @@
|
||||
<td>50</td>
|
||||
<td>65</td>
|
||||
<td>75</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student10</td>
|
||||
@ -262,6 +327,7 @@
|
||||
<td>100</td>
|
||||
<td>100</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student11</td>
|
||||
@ -271,6 +337,7 @@
|
||||
<td>85</td>
|
||||
<td>100</td>
|
||||
<td>100</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student12</td>
|
||||
@ -280,6 +347,7 @@
|
||||
<td>75</td>
|
||||
<td>70</td>
|
||||
<td>85</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student13</td>
|
||||
@ -289,6 +357,7 @@
|
||||
<td>80</td>
|
||||
<td>100</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student14</td>
|
||||
@ -298,6 +367,7 @@
|
||||
<td>45</td>
|
||||
<td>55</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student15</td>
|
||||
@ -307,6 +377,7 @@
|
||||
<td>35</td>
|
||||
<td>100</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student16</td>
|
||||
@ -316,6 +387,7 @@
|
||||
<td>50</td>
|
||||
<td>30</td>
|
||||
<td>70</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student17</td>
|
||||
@ -325,6 +397,7 @@
|
||||
<td>100</td>
|
||||
<td>55</td>
|
||||
<td>65</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student18</td>
|
||||
@ -334,6 +407,7 @@
|
||||
<td>49</td>
|
||||
<td>55</td>
|
||||
<td>75</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student19</td>
|
||||
@ -343,6 +417,7 @@
|
||||
<td>90</td>
|
||||
<td>88</td>
|
||||
<td>70</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student20</td>
|
||||
@ -352,6 +427,7 @@
|
||||
<td>45</td>
|
||||
<td>40</td>
|
||||
<td>80</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student21</td>
|
||||
@ -361,6 +437,7 @@
|
||||
<td>45</td>
|
||||
<td>100</td>
|
||||
<td>100</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Student22</td>
|
||||
@ -370,35 +447,36 @@
|
||||
<td>99</td>
|
||||
<td>100</td>
|
||||
<td>90</td>
|
||||
<td><button class="remove" title="Remove this row">X</button></td>
|
||||
</tr>
|
||||
<tr><td>Student23</td><td>Mathematics</td><td>male</td><td>82</td><td>77</td><td>0</td><td>79</td></tr>
|
||||
<tr><td>Student24</td><td>Languages</td><td>female</td><td>100</td><td>91</td><td>13</td><td>82</td></tr>
|
||||
<tr><td>Student25</td><td>Mathematics</td><td>male</td><td>22</td><td>96</td><td>82</td><td>53</td></tr>
|
||||
<tr><td>Student26</td><td>Languages</td><td>female</td><td>37</td><td>29</td><td>56</td><td>59</td></tr>
|
||||
<tr><td>Student27</td><td>Mathematics</td><td>male</td><td>86</td><td>82</td><td>69</td><td>23</td></tr>
|
||||
<tr><td>Student28</td><td>Languages</td><td>female</td><td>44</td><td>25</td><td>43</td><td>1</td></tr>
|
||||
<tr><td>Student29</td><td>Mathematics</td><td>male</td><td>77</td><td>47</td><td>22</td><td>38</td></tr>
|
||||
<tr><td>Student30</td><td>Languages</td><td>female</td><td>19</td><td>35</td><td>23</td><td>10</td></tr>
|
||||
<tr><td>Student31</td><td>Mathematics</td><td>male</td><td>90</td><td>27</td><td>17</td><td>50</td></tr>
|
||||
<tr><td>Student32</td><td>Languages</td><td>female</td><td>60</td><td>75</td><td>33</td><td>38</td></tr>
|
||||
<tr><td>Student33</td><td>Mathematics</td><td>male</td><td>4</td><td>31</td><td>37</td><td>15</td></tr>
|
||||
<tr><td>Student34</td><td>Languages</td><td>female</td><td>77</td><td>97</td><td>81</td><td>44</td></tr>
|
||||
<tr><td>Student35</td><td>Mathematics</td><td>male</td><td>5</td><td>81</td><td>51</td><td>95</td></tr>
|
||||
<tr><td>Student36</td><td>Languages</td><td>female</td><td>70</td><td>61</td><td>70</td><td>94</td></tr>
|
||||
<tr><td>Student37</td><td>Mathematics</td><td>male</td><td>60</td><td>3</td><td>61</td><td>84</td></tr>
|
||||
<tr><td>Student38</td><td>Languages</td><td>female</td><td>63</td><td>39</td><td>0</td><td>11</td></tr>
|
||||
<tr><td>Student39</td><td>Mathematics</td><td>male</td><td>50</td><td>46</td><td>32</td><td>38</td></tr>
|
||||
<tr><td>Student40</td><td>Languages</td><td>female</td><td>51</td><td>75</td><td>25</td><td>3</td></tr>
|
||||
<tr><td>Student41</td><td>Mathematics</td><td>male</td><td>43</td><td>34</td><td>28</td><td>78</td></tr>
|
||||
<tr><td>Student42</td><td>Languages</td><td>female</td><td>11</td><td>89</td><td>60</td><td>95</td></tr>
|
||||
<tr><td>Student43</td><td>Mathematics</td><td>male</td><td>48</td><td>92</td><td>18</td><td>88</td></tr>
|
||||
<tr><td>Student44</td><td>Languages</td><td>female</td><td>82</td><td>2</td><td>59</td><td>73</td></tr>
|
||||
<tr><td>Student45</td><td>Mathematics</td><td>male</td><td>91</td><td>73</td><td>37</td><td>39</td></tr>
|
||||
<tr><td>Student46</td><td>Languages</td><td>female</td><td>4</td><td>8</td><td>12</td><td>10</td></tr>
|
||||
<tr><td>Student47</td><td>Mathematics</td><td>male</td><td>89</td><td>10</td><td>6</td><td>11</td></tr>
|
||||
<tr><td>Student48</td><td>Languages</td><td>female</td><td>90</td><td>32</td><td>21</td><td>18</td></tr>
|
||||
<tr><td>Student49</td><td>Mathematics</td><td>male</td><td>42</td><td>49</td><td>49</td><td>72</td></tr>
|
||||
<tr><td>Student50</td><td>Languages</td><td>female</td><td>56</td><td>37</td><td>67</td><td>54</td></tr>
|
||||
<tr><td>Student23</td><td>Mathematics</td><td>male</td><td>82</td><td>77</td><td>0</td><td>79</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student24</td><td>Languages</td><td>female</td><td>100</td><td>91</td><td>13</td><td>82</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student25</td><td>Mathematics</td><td>male</td><td>22</td><td>96</td><td>82</td><td>53</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student26</td><td>Languages</td><td>female</td><td>37</td><td>29</td><td>56</td><td>59</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student27</td><td>Mathematics</td><td>male</td><td>86</td><td>82</td><td>69</td><td>23</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student28</td><td>Languages</td><td>female</td><td>44</td><td>25</td><td>43</td><td>1</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student29</td><td>Mathematics</td><td>male</td><td>77</td><td>47</td><td>22</td><td>38</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student30</td><td>Languages</td><td>female</td><td>19</td><td>35</td><td>23</td><td>10</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student31</td><td>Mathematics</td><td>male</td><td>90</td><td>27</td><td>17</td><td>50</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student32</td><td>Languages</td><td>female</td><td>60</td><td>75</td><td>33</td><td>38</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student33</td><td>Mathematics</td><td>male</td><td>4</td><td>31</td><td>37</td><td>15</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student34</td><td>Languages</td><td>female</td><td>77</td><td>97</td><td>81</td><td>44</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student35</td><td>Mathematics</td><td>male</td><td>5</td><td>81</td><td>51</td><td>95</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student36</td><td>Languages</td><td>female</td><td>70</td><td>61</td><td>70</td><td>94</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student37</td><td>Mathematics</td><td>male</td><td>60</td><td>3</td><td>61</td><td>84</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student38</td><td>Languages</td><td>female</td><td>63</td><td>39</td><td>0</td><td>11</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student39</td><td>Mathematics</td><td>male</td><td>50</td><td>46</td><td>32</td><td>38</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student40</td><td>Languages</td><td>female</td><td>51</td><td>75</td><td>25</td><td>3</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student41</td><td>Mathematics</td><td>male</td><td>43</td><td>34</td><td>28</td><td>78</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student42</td><td>Languages</td><td>female</td><td>11</td><td>89</td><td>60</td><td>95</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student43</td><td>Mathematics</td><td>male</td><td>48</td><td>92</td><td>18</td><td>88</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student44</td><td>Languages</td><td>female</td><td>82</td><td>2</td><td>59</td><td>73</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student45</td><td>Mathematics</td><td>male</td><td>91</td><td>73</td><td>37</td><td>39</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student46</td><td>Languages</td><td>female</td><td>4</td><td>8</td><td>12</td><td>10</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student47</td><td>Mathematics</td><td>male</td><td>89</td><td>10</td><td>6</td><td>11</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student48</td><td>Languages</td><td>female</td><td>90</td><td>32</td><td>21</td><td>18</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student49</td><td>Mathematics</td><td>male</td><td>42</td><td>49</td><td>49</td><td>72</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
<tr><td>Student50</td><td>Languages</td><td>female</td><td>56</td><td>37</td><td>67</td><td>54</td><td><button class="remove" title="Remove this row">X</button></td></tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
</div>
|
||||
<p>
|
||||
<strong>Author:</strong> <a class="external" href="http://lovepeacenukes.com">Christian Bach</a><br>
|
||||
<strong>Version:</strong> 2.0.21.1 (forked from <a href="http://tablesorter.com/docs/">version 2.0.5</a>, <a href="../changelog.txt">changelog</a>)<br>
|
||||
<strong>Version:</strong> 2.0.22 (forked from <a href="http://tablesorter.com/docs/">version 2.0.5</a>, <a href="../changelog.txt">changelog</a>)<br>
|
||||
<strong>Licence:</strong>
|
||||
Dual licensed under <a class="external" href="http://www.opensource.org/licenses/mit-license.php">MIT</a>
|
||||
or <a class="external" href="http://www.opensource.org/licenses/gpl-license.php">GPL</a> licenses.
|
||||
@ -287,54 +287,78 @@
|
||||
run these samples, just like you and your users will need Javascript enabled to use tablesorter.
|
||||
</p>
|
||||
|
||||
<strong>Basic</strong>
|
||||
<div class="box">
|
||||
<h3>Basic</h3>
|
||||
<h4>Sorting</h4>
|
||||
<ul>
|
||||
<li><a href="example-option-sort-list.html">Set an initial sorting order using options</a></li>
|
||||
<li><a href="example-trigger-sort.html">Sort table using a link outside the table</a></li>
|
||||
<li><a href="example-child-rows.html">How to add rows that sort with their parent row</a></li>
|
||||
<li><a href="example-option-sort-force.html">Force a default sorting order</a></li>
|
||||
<li><a href="example-option-sort-append.html">Append a sort to the selected sorting order</a></li>
|
||||
<li><a href="example-option-digits.html">Dealing with digits!</a></li>
|
||||
<li><a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> <span class="tip"><em>New! v2.0.10</em></span></li>
|
||||
<li><a href="example-child-rows.html">How to add rows that sort with their parent row</a></li>
|
||||
<li><a href="example-option-sort-order.html">Direction of initial sort</a></li>
|
||||
<li><a href="example-apply-widget.html">Applying widgets</a></li>
|
||||
<li><a href="example-widget-zebra.html">Applying the zebra stripe widget</a></li>
|
||||
<li><a href="example-widget-columns.html">Applying the columns widget</a> <span class="tip"><em>New! v2.0.17</em></span></li>
|
||||
<li><a href="example-widget-filter.html">Applying the filter widget</a> <span class="tip"><em>New! v2.0.18</em></span></li>
|
||||
<li><a href="example-widget-sticky-header.html">Applying the sticky header widget</a> <span class="tip"><em>New! v2.0.21.1</em></span></li>
|
||||
<li><a href="example-widget-ui-theme.html">Applying the jQuery UI theme widget</a> <span class="tip"><em>New! v2.0.9</em></span></li>
|
||||
<li><a href="example-parsers-class-name.html">Disable or set the column parser using class names</a> <span class="tip"><em>New! v2.0.11</em></span></li>
|
||||
<li><a href="example-options-headers.html">Disable sort using headers options</a></li>
|
||||
<li><a href="example-options-headers-locked.html">Lock sort order using header options</a></li>
|
||||
<li><a href="example-options-headers-order.html">Set initial sort order using header options</a></li>
|
||||
<li><a href="example-option-sort-key.html">Change the default multi-sorting key</a></li>
|
||||
</ul>
|
||||
<strong>Metadata - setting inline options</strong>
|
||||
|
||||
<h4>Parsers / Extracting Content</h4>
|
||||
<ul>
|
||||
<li><a href="example-meta-sort-list.html">Set a initial sorting order using metadata</a></li>
|
||||
<li><a href="example-meta-headers.html">Disable header using metadata</a></li>
|
||||
<li><a href="example-meta-parsers.html">Setting column parser using metadata</a></li>
|
||||
<li><a href="example-option-digits.html">Dealing with digits!</a></li>
|
||||
<li><a href="example-options-headers-digits-strings.html">Dealing with text strings in numerical sorts</a> <span class="tip"><em>New! v2.0.10</em></span></li>
|
||||
<li><a href="example-parsers-class-name.html">Disable or set the column parser using class names</a> <span class="tip"><em>New! v2.0.11</em></span></li>
|
||||
<li><a href="example-parsers.html">Parser, writing your own</a></li>
|
||||
<li><a href="example-option-text-extraction.html">Dealing with markup inside cells (textExtraction function)</a></li>
|
||||
</ul>
|
||||
<strong>Advanced</strong>
|
||||
|
||||
<h4>Widgets / Plugins</h4>
|
||||
<ul>
|
||||
<li><a href="example-apply-widget.html">Applying widgets</a></li>
|
||||
<li><a href="example-widget-columns.html">Columns widget</a> <span class="tip"><em>New! v2.0.17</em></span></li>
|
||||
<li><a href="example-widget-filter.html">Filter widget</a> <span class="tip"><em>New! v2.0.18</em></span></li>
|
||||
<li><a href="example-widget-ui-theme.html">jQuery UI theme widget</a> <span class="tip"><em>New! v2.0.9</em></span></li>
|
||||
<li><a href="example-widget-sticky-header.html">Sticky header widget</a> <span class="tip"><em>New! v2.0.21.1</em></span></li>
|
||||
<li><a href="example-widget-zebra.html">Zebra stripe widget</a></li>
|
||||
<li><a href="example-widgets.html">Widgets, writing your own</a></li>
|
||||
<li><a href="example-pager.html">Pager plugin</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="box">
|
||||
<h3>Advanced</h3>
|
||||
<h4>Adding / Removing Content</h4>
|
||||
<ul>
|
||||
<li><a href="example-triggers.html">Triggers sortEnd and sortStart (Displaying sorting progress)</a></li>
|
||||
<li><a href="example-empty-table.html">Initializing tablesorter on a empty table</a></li>
|
||||
<li><a href="example-ajax.html">Appending table data with ajax</a></li>
|
||||
<li><a href="example-add-rows.html">Adding a table row</a> <span class="tip"><em>New! v2.0.16</em></span></li>
|
||||
<li><a href="example-update-cell.html">Update the table after cell content has changed</a></li>
|
||||
<li><a href="example-option-text-extraction.html">Dealing with markup inside cells (textExtraction function)</a></li>
|
||||
<li><a href="example-option-render-header.html">Modify how the header is rendered to allow for custom styling</a></li>
|
||||
<li><a href="example-extending-defaults.html">Extending default options</a></li>
|
||||
<li><a href="example-option-debug.html">Enabling debug mode</a></li>
|
||||
<li><a href="example-parsers.html">Parser, writing your own</a></li>
|
||||
<li><a href="example-widgets.html">Widgets, writing your own</a></li>
|
||||
<li><a href="example-pager.html">Pager plugin</a> - examples of how to add and remove rows</li>
|
||||
</ul>
|
||||
|
||||
<strong>Companion plugins</strong>
|
||||
<h4>Change Header Style</h4>
|
||||
<ul>
|
||||
<li><a href="example-pager.html">Pager plugin</a></li>
|
||||
<li><a href="example-option-render-header.html">Modify how the header is rendered to allow for custom styling</a></li>
|
||||
</ul>
|
||||
|
||||
<h3>Other</h3>
|
||||
<h4>Options & Events</h4>
|
||||
<ul>
|
||||
<li><a href="example-triggers.html">Triggers sortEnd and sortStart (Displaying sorting progress)</a></li>
|
||||
<li><a href="example-extending-defaults.html">Extending default options</a></li>
|
||||
<li><a href="example-option-debug.html">Enabling debug mode</a></li>
|
||||
</ul>
|
||||
|
||||
<h4>Metadata - setting inline options</h4>
|
||||
<ul>
|
||||
<li>*Note* As of version 2.0.11, you can use class names instead of meta data (<a href="example-parsers-class-name.html">demo</a>)</li>
|
||||
<li><a href="example-meta-sort-list.html">Set a initial sorting order using metadata</a></li>
|
||||
<li><a href="example-meta-headers.html">Disable header using metadata</a></li>
|
||||
<li><a href="example-meta-parsers.html">Setting column parser using metadata</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<br class="clear">
|
||||
|
||||
<a name="Configuration"></a>
|
||||
<h1>Configuration</h1>
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* TableSorter 2.0 - Client-side table sorting with ease!
|
||||
* Version 2.0.21
|
||||
* Version 2.0.22
|
||||
* @requires jQuery v1.2.3
|
||||
*
|
||||
* Copyright (c) 2007 Christian Bach
|
||||
@ -300,7 +300,8 @@
|
||||
for (i = 0; i < totalRows; i++) {
|
||||
pos = n[i][checkCell];
|
||||
rows.push(r[pos]);
|
||||
if (!c.appender) {
|
||||
// removeRows used by the pager plugin
|
||||
if (!c.appender || !c.removeRows) {
|
||||
l = r[pos].length;
|
||||
for (j = 0; j < l; j++) {
|
||||
table.tBodies[0].appendChild(r[pos][j]);
|
||||
|
5
js/jquery.tablesorter.min.js
vendored
5
js/jquery.tablesorter.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user