3 tablesorterPager: new function() {
5 function updatePageDisplay(c) {
6 var s = $(c.cssPageDisplay,c.container).val((c.page+1) + c.seperator + c.totalPages);
9 function setPageSize(table,size) {
12 c.totalPages = Math.ceil(c.totalRows / c.size);
13 c.pagerPositionSet = false;
18 function fixPosition(table) {
20 if(!c.pagerPositionSet && c.positionFixed) {
21 var c = table.config, o = $(table);
24 top: o.offset().top + o.height() + 'px',
28 c.pagerPositionSet = true;
32 function moveToFirstPage(table) {
38 function moveToLastPage(table) {
40 c.page = (c.totalPages-1);
44 function moveToNextPage(table) {
47 if(c.page >= (c.totalPages-1)) {
48 c.page = (c.totalPages-1);
53 function moveToPrevPage(table) {
63 function moveToPage(table) {
65 if(c.page < 0 || c.page > (c.totalPages-1)) {
69 renderTable(table,c.rowsCopy);
72 function renderTable(table,rows) {
76 var s = (c.page * c.size);
78 if(e > rows.length ) {
83 var tableBody = $(table.tBodies[0]);
85 // clear the table body
87 $.tablesorter.clearTableBody(table);
89 for(var i = s; i < e; i++) {
91 //tableBody.append(rows[i]);
95 for(var j=0; j < l; j++) {
97 tableBody[0].appendChild(o[j]);
102 fixPosition(table,tableBody);
104 $(table).trigger("applyWidgets");
106 if( c.page >= c.totalPages ) {
107 moveToLastPage(table);
110 updatePageDisplay(c);
113 this.appender = function(table,rows) {
115 var c = table.config;
118 c.totalRows = rows.length;
119 c.totalPages = Math.ceil(c.totalRows / c.size);
121 renderTable(table,rows);
135 cssPageDisplay: '.pagedisplay',
136 cssPageSize: '.pagesize',
139 appender: this.appender
142 this.construct = function(settings) {
144 return this.each(function() {
146 config = $.extend(this.config, $.tablesorterPager.defaults, settings);
148 var table = this, pager = config.container;
150 $(this).trigger("appendCache");
152 config.size = parseInt($(".pagesize",pager).val());
154 $(config.cssFirst,pager).click(function() {
155 moveToFirstPage(table);
158 $(config.cssNext,pager).click(function() {
159 moveToNextPage(table);
162 $(config.cssPrev,pager).click(function() {
163 moveToPrevPage(table);
166 $(config.cssLast,pager).click(function() {
167 moveToLastPage(table);
170 $(config.cssPageSize,pager).change(function() {
171 setPageSize(table,parseInt($(this).val()));
179 // extend plugin scope
181 tablesorterPager: $.tablesorterPager.construct