tablesorter/addons/pager/jquery.tablesorter.pager.min.js

2 lines
8.1 KiB
JavaScript
Raw Normal View History

/*! tablesorter pager plugin minified - updated 10/15/2012 */
;(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:!1,cssFirst:".first",cssPrev:".prev",cssNext:".next",cssLast:".last",cssGoto:".gotoPage",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssDisabled:"disabled",totalRows:0,totalPages:0,filteredRows:0,filteredPages:0};var p=this,r=function(c,b){var a= c.cssDisabled,e=!!b,f=Math.min(c.totalPages,c.filteredPages);c.updateArrows&&(d(c.cssFirst+","+c.cssPrev,c.container)[e||0===c.page?"addClass":"removeClass"](a),d(c.cssNext+","+c.cssLast,c.container)[e||c.page===f-1?"addClass":"removeClass"](a))},t=function(c,b){var a,e,f;a=d(c).hasClass("hasFilters");b.filteredRows=a?d(c).find("tbody tr:not(.filtered)").length:b.totalRows;b.filteredPages=a?Math.ceil(b.filteredRows/b.size):b.totalPages;if(0<Math.min(b.totalPages,b.filteredPages)&&(f=b.size*b.page> b.filteredRows,b.startRow=f?1:b.size*b.page+1,b.page=f?0:b.page,b.endRow=Math.min(b.filteredRows,b.totalRows,b.size*(b.page+1)),e=d(b.cssPageDisplay,b.container),a=b.output.replace(/\{(page|filteredRows|filteredPages|totalPages|startRow|endRow|totalRows)\}/gi,function(a){return{"{page}":b.page+1,"{filteredRows}":b.filteredRows,"{filteredPages}":b.filteredPages,"{totalPages}":b.totalPages,"{startRow}":b.startRow,"{endRow}":b.endRow,"{totalRows}":b.totalRows}[a]}),e[0]&&(e["INPUT"===e[0].tagName?"val": "html"](a),d(b.cssGoto,b.container).length))){f="";e=Math.min(b.totalPages,b.filteredPages);for(a=1;a<=e;a++)f+="<option>"+a+"</option>";d(b.cssGoto,b.container).html(f).val(b.page+1)}r(b);b.initialized&&d(c).trigger("pagerComplete",b)},u=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>')},s=function(c,b){var a=d(c.tBodies[0]);a.find("tr.pagerSavedHeightSpacer").remove();d.data(c,"pagerSavedHeight",a.height());u(c,b);d.data(c,"pagerLastSize",b.size)},q=function(c,b){if(!b.ajaxUrl){var a,e=d("tr:not(."+c.config.cssChildRow+")",c.tBodies),f=e.length,g=b.page*b.size,i=g+b.size,h=0;for(a=0;a<f;a++)/filtered/.test(e[a].className)||(e[a].style.display=h>=g&&h<i?"":"none",h++)}},w=function(c,b){b.size=parseInt(d(b.cssPageSize,b.container).val(),10)||b.size;d.data(c,"pagerLastSize", b.size);r(b);b.removeRows||(q(c,b),d(c).bind("sortEnd.pager filterEnd.pager",function(){q(c,b)}))},x=function(c,b,a,e){if("function"===typeof a.ajaxProcessing){var f,g,i,h,j=d(b),l=b.config,q=d(b.tBodies).filter(":not(."+l.cssInfoBlock+")"),p=j.find("thead th").length,n="",r='<tr class="'+l.selectorRemove+'"><td style="text-align: center;" colspan="'+p+'">'+(e?e.message+" ("+e.name+")":"No rows found")+"</td></tr>",k=a.ajaxProcessing(c)||[0,[]],v=k[1]||[],s=v.length,m=k[2];if(0<s)for(c=0;c<s;c++){n+= "<tr>";for(f=0;f<v[c].length;f++)n+="<td>"+v[c][f]+"</td>";n+="</tr>"}m&&m.length===p&&(g=j.hasClass("hasStickyHeaders"),h=j.find("."+(l.widgetOptions&&l.widgetOptions.stickyHeaders||"tablesorter-stickyheader")),i=j.find("tfoot tr:first").children(),j.find("th."+l.cssHeader).each(function(a){var b=d(this),c;b.find("."+l.cssIcon).length?(c=b.find("."+l.cssIcon).clone(!0),b.find(".tablesorter-header-inner").html(m[a]).append(c),g&&h.length&&(c=h.find("th").eq(a).find("."+l.cssIcon).clone(!0),h.find("th").eq(a).find(".tablesorter-header-inner").html(m[a]).append(c))): (b.find(".tablesorter-header-inner").html(m[a]),h.find("th").eq(a).find(".tablesorter-header-inner").html(m[a]));i.eq(a).html(m[a]);g&&h.length&&(b=h.find("th").eq(a),b=b.find("span").length?b.find("span:first"):b,b.html(m[a]))}));e?j.find("thead").append(r):q.html(n);a.temp.remove();a.initialized&&j.trigger("update");a.totalRows=k[0]||0;a.totalPages=Math.ceil(a.totalRows/a.size);t(b,a);u(b,a);a.initialized&&j.trigger("pagerChange",a)}a.initial