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

3 lines
15 KiB
JavaScript
Raw Normal View History

2014-07-17 17:40:11 +00:00
/* tablesorter pager plugin updated 7/17/2014 (v2.17.5) */
;(function(h){var k=h.tablesorter;h.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(c,a){return a},ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(c){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,pageReset:0,size:10,savePages:!0,storageKey:"tablesorter-pager",fixedHeight:!1,countChildRows:!1,removeRows:!1,cssFirst:".first",cssPrev:".prev",cssNext:".next",cssLast:".last", cssGoto:".gotoPage",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssErrorRow:"tablesorter-errorRow",cssDisabled:"disabled",totalRows:0,totalPages:0,filteredRows:0,filteredPages:0,ajaxCounter:0,currentFilters:[],startRow:0,endRow:0,$size:null,last:{}};var w=this,p=function(c,a){var b=c.cssDisabled,d=!!a,g=d||0===c.page,f=Math.min(c.totalPages,c.filteredPages),d=d||c.page===f-1||0===f;c.updateArrows&&(c.$container.find(c.cssFirst+","+c.cssPrev)[g?"addClass":"removeClass"](b).attr("aria-disabled", g),c.$container.find(c.cssNext+","+c.cssLast)[d?"addClass":"removeClass"](b).attr("aria-disabled",d))},t=function(c,a,b){var d,g,f,l=c.config;d=l.$table.hasClass("hasFilters");f=[];g=a.size||10;f=[l.widgetOptions&&l.widgetOptions.filter_filteredRow||"filtered",l.selectorRemove.replace(/^(\w+\.)/g,"")];a.countChildRows&&f.push(l.cssChildRow);f.join("|");d&&!a.ajaxUrl?h.isEmptyObject(l.cache)?a.filteredRows=a.totalRows=l.$tbodies.eq(0).children("tr").not(a.countChildRows?"":"."+l.cssChildRow).length: (a.filteredRows=0,h.each(l.cache[0].normalized,function(e,b){a.filteredRows+=a.regexRows.test(b[l.columns].$row[0].className)?0:1})):d||(a.filteredRows=a.totalRows);a.totalPages=Math.ceil(a.totalRows/g);l.totalRows=a.totalRows;l.filteredRows=a.filteredRows;a.filteredPages=Math.ceil(a.filteredRows/g)||0;if(0<=Math.min(a.totalPages,a.filteredPages)&&(f=a.size*a.page>a.filteredRows,a.startRow=f?1:0===a.filteredRows?0:a.size*a.page+1,a.page=f?0:a.page,a.endRow=Math.min(a.filteredRows,a.totalRows,a.size* (a.page+1)),d=a.$container.find(a.cssPageDisplay),f=(a.ajaxData&&a.ajaxData.output?a.ajaxData.output||a.output:a.output).replace(/\{page([\-+]\d+)?\}/gi,function(e,b){return a.totalPages?a.page+(b?parseInt(b,10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(b){b=b.replace(/[{}\s]/g,"");var c=b.split(":"),d=a.ajaxData,g=/(rows?|pages?)$/i.test(b)?0:"";return 1<c.length&&d&&d[c[0]]?d[c[0]][c[1]]:a[b]||(d?d[b]:g)||g}),d.length&&(d["INPUT"===d[0].tagName?"val":"html"](f),a.$goto.length))){f="";g=Math.min(a.totalPages, a.filteredPages);for(d=1;d<=g;d++)f+="<option>"+d+"</option>";a.$goto.html(f).val(a.page+1)}p(a);a.initialized&&!1!==b&&(l.$table.trigger("pagerComplete",a),a.savePages&&k.storage&&k.storage(c,a.storageKey,{page:a.page,size:a.size}))},u=function(c,a){var b,d=c.config,g=d.$tbodies.eq(0);a.fixedHeight&&(g.find("tr.pagerSavedHeightSpacer").remove(),b=h.data(c,"pagerSavedHeight"))&&(b-=g.height(),5<b&&h.data(c,"pagerLastSize")===a.size&&g.children("tr:visible").length<a.size&&g.append('<tr class="pagerSavedHeightSpacer '+ d.selectorRemove.replace(/^(\w+\.)/g,"")+'" style="height:'+b+'px;"></tr>'))},z=function(c,a){var b=c.config.$tbodies.eq(0);b.find("tr.pagerSavedHeightSpacer").remove();h.data(c,"pagerSavedHeight",b.height());u(c,a);h.data(c,"pagerLastSize",a.size)},v=function(c,a){if(!a.ajaxUrl){var b,d=0,g=c.config,f=g.$tbodies.eq(0).children("tr"),h=f.length,e=a.page*a.size,m=e+a.size,n=g.widgetOptions&&g.widgetOptions.filter_filteredRow||"filtered",s=0;for(b=0;b<h;b++)f[b].className.match(n)||(s===e&&f[b].className.match(g.cssChildRow)? f[b].style.display="none":(f[b].style.display=s>=e&&s<m?"":"none",s+=f[b].className.match(g.cssChildRow+"|"+g.selectorRemove.replace(/^(\w+\.)/g,""))&&!a.countChildRows?0:1,s===m&&"none"!==f[b].style.display&&f[b].className.match(k.css.cssHasChild)&&(d=b)));if(0<d&&f[d].className.match(k.css.cssHasChild))for(;++d<h&&f[d].className.match(g.cssChildRow);)f[d].style.display=""}},A=function(c,a){a.size=parseInt(a.$size.val(),10)||a.size;h.data(c,"pagerLastSize",a.size);p(a);a.removeRows||(v(c,