|
|
|
(function(d){d.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,ajaxProcessing:function(){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,size:10,fixedHeight:!1,removeRows:!0,cssNext:".next",cssPrev:".prev",cssFirst:".first",cssLast:".last",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",totalRows:0,totalPages:0};var o=this,p=function(c,b){var a=c.cssDisabled,e=!!b;c.updateArrows&&(c.container[c.totalRows< c.size?"addClass":"removeClass"](a),d(c.cssFirst+","+c.cssPrev,c.container)[e||0===c.page?"addClass":"removeClass"](a),d(c.cssNext+","+c.cssLast,c.container)[e||c.page===c.totalPages-1?"addClass":"removeClass"](a))},t=function(c,b){if(0<b.totalPages){b.startRow=b.size*b.page+1;b.endRow=Math.min(b.totalRows,b.size*(b.page+1));var a=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]});if(a[0])a["INPUT"===a[0].tagName?"val":"html"](e)}p(b);d(c).trigger("pagerComplete",b)},s=function(c,b){var a,e=d(c.tBodies[0]);if(b.fixedHeight&&(e.find("tr.pagerSavedHeightSpacer").remove(),a=d.data(c,"pagerSavedHeight")))a-=e.height(),5<a&&d.data(c,"pagerLastSize")===b.size&&e.find("tr:visible").length<b.size&&e.append('<tr class="pagerSavedHeightSpacer remove-me" style="height:'+a+'px;"></tr>')},l=function(c,b){var a, e=d("tr:not(."+c.config.cssChildRow+")",c.tBodies[0]),g=e.length,f=b.page*b.size,j=f+b.size;j>g&&(j=g);for(a=0;a<g;a++)e[a].style.display=a>=f&&a<j?"":"none"},q=function(c,b){b.size=parseInt(d(b.cssPageSize,b.container).val(),10)||b.size;d.data(c,"pagerLastSize",b.size);p(b);b.removeRows||(l(c,b),d(c).bind("sortEnd.pager",function(){l(c,b);d(c).trigger("applyWidgets")}))},u=function(c,b,a,e){if("function"===typeof a.ajaxProcessing){var g,f,j,i,h=d(b),k=d(b.tBodies[0]),o=h.find("thead th").length, m="",p='<tr class="remove-me"><td style="text-align: center;" colspan="'+o+'">'+(e?e.message+" ("+e.name+")":"No rows found")+"</td></tr>",l=a.ajaxProcessing(c)||[0,[]],n=l[1]||[],q=n.length,r=l[2];if(0<q)for(c=0;c<q;c++){m+="<tr>";for(g=0;g<n[c].length;g++)m+="<td>"+n[c][g]+"</td>";m+="</tr>"}r&&r.length===o&&(f=h.hasClass("hasStickyHeaders"),i=h.find("."+(a.widgetOptions&&a.widgetOptions.stickyHeaders||"tablesorter-stickyheader")),j=h.find("tfoot tr:first").children(),h.find("thead tr.tablesorter-header th").each(function(a){var b= d(this),b=b.find("span").length?b.find("span:first"):b;b.html(r[a]);j.eq(a).html(r[a]);f&&i.length&&(b=i.find("th").eq(a),b=b.find("span").length?b.find("span:first"):b,b.html(r[a]))}));e?h.find("thead").append(p):k.html(m);a.temp.remove();h.trigger("update");a.totalRows=l[0]||0;a.totalPages=Math.ceil(a.totalRows/a.size);t(b,a);s(b,a);h.trigger("pagerChange",a)}},v=function(c,b){var a=d(c),e=b.ajaxUrl.replace(/\{page\}/g,b.page).replace(/\{size\}/g,b.size);""!==e&&(b.temp=d("<div/>",{id:"tablesorterPagerLoading", width:a.outerWidth(!0),height:a.outerHeight(!0)}),a.before(b.temp),d(document).ajaxError(function(a,d,e,i){u(null,c,b,i)}),d.getJSON(e,function(a){u(a,c,b)}))},n=function(c,b,a){var e,g,f,j=d(c.tBodies[0]),i=b.length;e=a.page*a.size;var h=e+a.size;if(!(1>i)){d(c).trigger("pagerChange",a);if(a.removeRows){h>b.length&&(h=b.length);for(d(c.tBodies[0]).empty();e<h;e++){f=b[e];i=f.length;for(g=0;g<i;g++)j[0].appendChild(f[g])}}else l(c,a);d(c).trigger("applyWidgets");a.page>=a.totalPages&&(a.page=a.totalPages- 1,k(c,a));t(c,a);a.isDisabled||s(c,a)}},w=function(c,b){b.ajax?p(b,!0):(b.isDisabled=!0,d.data(c,"pagerLastPage",b.page),d.data(c,"pagerLastSize",b.size),b.page=0,b.size=b.totalRows,b.totalPages=1,d("tr.pagerSavedHeightSpacer",c.tBodies[0]).remove(),n(c,c.config.rowsCopy,b));d(b.cssPageSize,b.container).addClass(b.cssDisabled)[0].disabled=!0},k=function(c,b){if(!b.isDisabled){if(0>b.page||b.page>b.totalPages-1)b.page=0;d.data(c,"pagerLastPage",b.page);b.ajax?v(c,b):n(c,c.config.rowsCopy,b)}},x=f
|