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

3 lines
14 KiB
JavaScript
Raw Normal View History

2014-04-24 00:41:05 +00:00
/* tablesorter pager plugin updated 4/23/2014 (v2.16.0) */
;(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,f=d||0===c.page,g=Math.min(c.totalPages,c.filteredPages),d=d||c.page===g-1||0===c.totalPages;c.updateArrows&&(c.$container.find(c.cssFirst+","+c.cssPrev)[f?"addClass":"removeClass"](b).attr("aria-disabled", f),c.$container.find(c.cssNext+","+c.cssLast)[d?"addClass":"removeClass"](b).attr("aria-disabled",d))},t=function(c,a,b){var d,f,g,l=c.config;d=l.$table.hasClass("hasFilters")&&!a.ajaxUrl;g=[];f=a.size||10;g=[l.widgetOptions&&l.widgetOptions.filter_filteredRow||"filtered",l.selectorRemove];a.countChildRows&&g.push(l.cssChildRow);g.join("|");a.totalPages=Math.ceil(a.totalRows/f);a.filteredRows=d?0:a.totalRows;a.filteredPages=a.totalPages;d&&(h.each(l.cache[0].normalized,function(e,c){a.filteredRows+= a.regexRows.test(c[l.columns].$row[0].className)?0:1}),a.filteredPages=Math.ceil(a.filteredRows/f)||0);if(0<=Math.min(a.totalPages,a.filteredPages)&&(g=a.size*a.page>a.filteredRows,a.startRow=g?1:0===a.filteredRows?0:a.size*a.page+1,a.page=g?0:a.page,a.endRow=Math.min(a.filteredRows,a.totalRows,a.size*(a.page+1)),d=a.$container.find(a.cssPageDisplay),g=(a.ajaxData&&a.ajaxData.output?a.ajaxData.output||a.output:a.output).replace(/\{page([\-+]\d+)?\}/gi,function(c,b){return a.totalPages?a.page+(b?parseInt(b, 10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(c){c=c.replace(/[{}\s]/g,"");var b=c.split(":"),d=a.ajaxData,f=/(rows?|pages?)$/i.test(c)?0:"";return 1<b.length&&d&&d[b[0]]?d[b[0]][b[1]]:a[c]||(d?d[c]:f)||f}),d.length&&(d["INPUT"===d[0].tagName?"val":"html"](g),a.$goto.length))){g="";f=Math.min(a.totalPages,a.filteredPages);for(d=1;d<=f;d++)g+="<option>"+d+"</option>";a.$goto.html(g).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,f=d.$tbodies.eq(0);a.fixedHeight&&(f.find("tr.pagerSavedHeightSpacer").remove(),b=h.data(c,"pagerSavedHeight"))&&(b-=f.height(),5<b&&h.data(c,"pagerLastSize")===a.size&&f.children("tr:visible").length<a.size&&f.append('<tr class="pagerSavedHeightSpacer '+d.selectorRemove.replace(/(tr)?\./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,f=c.config,g=f.$tbodies.eq(0).children(),h=g.length,e=a.page*a.size,m=e+a.size,n=f.widgetOptions&&f.widgetOptions.filter_filteredRow||"filtered",r=0;for(b=0;b<h;b++)g[b].className.match(n)||(r===e&&g[b].className.match(f.cssChildRow)?g[b].style.display="none":(g[b].style.display=r>=e&&r<m?"":"none",r+=g[b].className.match(f.cssChildRow+"|"+f.selectorRemove.slice(1))&&!a.countChildRows? 0:1,r===m&&"none"!==g[b].style.display&&g[b].className.match(k.css.cssHasChild)&&(d=b)));if(0<d&&g[d].className.match(k.css.cssHasChild))for(;++d<h&&g[d].className.match(f.cssChildRow);)g[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,a),h(c).bind("sortEnd.pager filterEnd.pager",function(){v(c,a)}))},B=function(c,a,b,d,f){if("function"===typeof b.ajaxProcessing){var g,l,e,m,n,r,s=a.config,q=s.$table,p="";g=b.ajaxProcessing(c, a)||[0,[]];c=q