3
* TableSorter 2.0 - Client-side table sorting with ease!
5
* @requires jQuery v1.1.3
7
* Copyright (c) 2007 Christian Bach
8
* Examples and docs at: http://tablesorter.com
9
* Dual licensed under the MIT and GPL licenses:
10
* http://www.opensource.org/licenses/mit-license.php
11
* http://www.gnu.org/licenses/gpl.html
16
tablesorterPager: new function() {
18
function updatePageDisplay(c) {
19
var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages);
21
//add the tr hover class
22
$(".info_table table tr").hover(
24
$(this).addClass("hover");
26
$(this).removeClass("hover");
31
function setPageSize(table,size) {
34
c.totalPages = Math.ceil(c.totalRows / c.size);
37
if(!c.pagerPositionSet && c.positionFixed) fixPosition(table);
40
function fixPosition(table) {
41
var c = table.config, o = $(table);
44
top: o.offset().top + o.height() + 'px',
48
c.pagerPositionSet = true;
51
function moveToFirstPage(table) {
57
function moveToLastPage(table) {
59
c.page = (c.totalPages-1);
63
function moveToNextPage(table) {
66
if(c.page >= (c.totalPages-1)) {
67
c.page = (c.totalPages-1);
72
function moveToPrevPage(table) {
82
function moveToPage(table) {
84
if(c.page < 0 || c.page > (c.totalPages-1)) {
88
renderTable(table,c.rowsCopy);
91
function renderTable(table,rows) {
95
var s = (c.page * c.size);
97
if(e > rows.length ) {
100
var tableBody = $('tbody:first',table).empty();
102
for(var i = s; i < e; i++) {
104
tableBody.append(rows[i]);
107
if(!c.pagerPositionSet && c.positionFixed) fixPosition(table,tableBody);
109
updatePageDisplay(c);
112
this.appender = function(table,rows) {
114
var c = table.config;
117
c.totalRows = rows.length;
118
c.totalPages = Math.ceil(c.totalRows / c.size);
120
renderTable(table,rows);
134
cssPageDisplay: '.pagedisplay',
135
cssPageSize: '.pagesize',
137
positionFixed: false,
138
appender: this.appender
141
this.construct = function(settings) {
143
return this.each(function() {
145
config = $.extend(this.config, $.tablesorterPager.defaults, settings);
147
var table = this, pager = config.container;
149
$(this).trigger("appendCache");
151
config.size = parseInt($(".pagesize",pager).val());
153
$(config.cssFirst,pager).click(function() {
154
moveToFirstPage(table);
157
$(config.cssNext,pager).click(function() {
158
moveToNextPage(table);
161
$(config.cssPrev,pager).click(function() {
162
moveToPrevPage(table);
165
$(config.cssLast,pager).click(function() {
166
moveToLastPage(table);
169
$(config.cssPageSize,pager).change(function() {
170
setPageSize(table,parseInt($(this).val()));
178
// extend plugin scope
180
tablesorterPager: $.tablesorterPager.construct
b'\\ No newline at end of file'