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

3 lines
14 KiB
JavaScript
Raw Normal View History

2014-06-29 04:04:50 +00:00
/* tablesorter pager plugin updated 6/28/2014 (v2.17.3) */
;(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,e=!!a,g=e||0===c.page,f=Math.min(c.totalPages,c.filteredPages),e=e||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)[e?"addClass":"removeClass"](b).attr("aria-disabled",e))},t=function(c,a,b){var e,g,f,l=c.config;e=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("|");a.totalPages=Math.ceil(a.totalRows/g);e&&!a.ajaxUrl?(a.filteredRows=0,h.each(l.cache[0].normalized,function(d,c){a.filteredRows+=a.regexRows.test(c[l.columns].$row[0].className)? 0:1})):e||(a.filteredRows=a.totalRows);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)),e=a.$container.find(a.cssPageDisplay),f=(a.ajaxData&&a.ajaxData.output?a.ajaxData.output||a.output:a.output).replace(/\{page([\-+]\d+)?\}/gi,function(d,c){return a.totalPages?a.page+(c?parseInt(c,10):1): 0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(d){d=d.replace(/[{}\s]/g,"");var c=d.split(":"),b=a.ajaxData,e=/(rows?|pages?)$/i.test(d)?0:"";return 1<c.length&&b&&b[c[0]]?b[c[0]][c[1]]:a[d]||(b?b[d]:e)||e}),e.length&&(e["INPUT"===e[0].tagName?"val":"html"](f),a.$goto.length))){f="";g=Math.min(a.totalPages,a.filteredPages);for(e=1;e<=g;e++)f+="<option>"+e+"</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,e=c.config,g=e.$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 '+e.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,e=0,g=c.config,f=g.$tbodies.eq(0).children("tr"),h=f.length,d=a.page*a.size,m=d+a.size,n=g.widgetOptions&&g.widgetOptions.filter_filteredRow||"filtered",r=0;for(b=0;b<h;b++)f[b].className.match(n)||(r===d&&f[b].className.match(g.cssChildRow)?f[b].style.display="none":(f[b].style.display=r>=d&&r<m?"":"none",r+=f[b].className.match(g.cssChildRow+"|"+g.selectorRemove.replace(/^(\w+\.)/g,""))&&!a.countChildRows? 0:1,r===m&&"none"!==f[b].style.display&&f[b].className.match(k.css.cssHasChild)&&(e=b)));if(0<e&&f[e].className.match(k.css.cssHasChild))for(;++e<h&&f[e].className.match(g.cssChildRow);)f[e].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,a),h(c).bind("sortEnd.pager filterEnd.pager",function(){v(c,a)}))},B=function(c,a,b,e,g){if("function"===typeof b.ajaxProcessing){var f,l,d,m,n,r,s=a.config,q=s.$table,p="";f=b.ajaxProcess