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

3 lines
13 KiB
JavaScript
Raw Normal View History

2014-03-31 11:13:35 +00:00
/* tablesorter pager plugin updated 3/31/2014 (v2.15.12) */
;(function(h){var k=h.tablesorter;h.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(b,a){return a},ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(b){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page: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 v=this,m=function(b,a){var d=b.cssDisabled,e=!!a,f=e||0===b.page,g=Math.min(b.totalPages,b.filteredPages),e=e||b.page===g-1||0===b.totalPages;b.updateArrows&&(b.$container.find(b.cssFirst+","+b.cssPrev)[f?"addClass":"removeClass"](d).attr("aria-disabled",f), b.$container.find(b.cssNext+","+b.cssLast)[e?"addClass":"removeClass"](d).attr("aria-disabled",e))},p=function(b,a,d){var e,f,g,c=b.config;e=c.$table.hasClass("hasFilters")&&!a.ajaxUrl;g=(c.widgetOptions&&c.widgetOptions.filter_filteredRow||"filtered")+","+c.selectorRemove+(a.countChildRows?"":",."+c.cssChildRow);f=a.size||10;a.totalPages=Math.ceil(a.totalRows/f);a.filteredRows=e?c.$tbodies.eq(0).children("tr").not("."+g).length:a.totalRows;a.filteredPages=e?Math.ceil(a.filteredRows/f)||1:a.totalPages; 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)),e=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,e=/(rows?|pages?)$/i.test(c)?0:"";return 1<b.length&&d&&d[b[0]]?d[b[0]][b[1]]:a[c]||(d?d[c]:e)||e}),e.length&&(e["INPUT"===e[0].tagName?"val":"html"](g),a.$goto.length))){g="";f=Math.min(a.totalPages,a.filteredPages);for(e=1;e<=f;e++)g+="<option>"+e+"</option>";a.$goto.html(g).val(a.page+1)}m(a);a.initialized&&!1!==d&&(c.$table.trigger("pagerComplete",a),a.savePages&&k.storage&&k.storage(b,a.storageKey,{page:a.page,size:a.size}))},t=function(b,a){var d,e=b.config,f=e.$tbodies.eq(0);a.fixedHeight&& (f.find("tr.pagerSavedHeightSpacer").remove(),d=h.data(b,"pagerSavedHeight"))&&(d-=f.height(),5<d&&h.data(b,"pagerLastSize")===a.size&&f.children("tr:visible").length<a.size&&f.append('<tr class="pagerSavedHeightSpacer '+e.selectorRemove.replace(/(tr)?\./g,"")+'" style="height:'+d+'px;"></tr>'))},z=function(b,a){var d=b.config.$tbodies.eq(0);d.find("tr.pagerSavedHeightSpacer").remove();h.data(b,"pagerSavedHeight",d.height());t(b,a);h.data(b,"pagerLastSize",a.size)},u=function(b,a){if(!a.ajaxUrl){var d, e=0,f=b.config,g=f.$tbodies.eq(0).children(),c=g.length,h=a.page*a.size,l=h+a.size,q=f.widgetOptions&&f.widgetOptions.filter_filteredRow||"filtered",r=0;for(d=0;d<c;d++)g[d].className.match(q)||(r===h&&g[d].className.match(f.cssChildRow)?g[d].style.display="none":(g[d].style.display=r>=h&&r<l?"":"none",r+=g[d].className.match(f.cssChildRow+"|"+f.selectorRemove.slice(1))&&!a.countChildRows?0:1,r===l&&"none"!==g[d].style.display&&g[d].className.match(k.css.cssHasChild)&&(e=d)));if(0<e&&g[e].className.match(k.css.cssHasChild))for(;++e< c&&g[e].className.match(f.cssChildRow);)g[e].style.display=""}},A=function(b,a){a.size=parseInt(a.$size.val(),10)||a.size;h.data(b,"pagerLastSize",a.size);m(a);a.removeRows||(u(b,a),h(b).bind("sortEnd.pager filterEnd.pager",function(){u(b,a)}))},B=function(b,a,d,e,f){if("function"===typeof d.ajaxProcessing){var g,c,y,l,q,r,s=a.config,n=s.$table,m="";g=d.ajaxProcessing(b,a)||[0,[]];b=n.find("thead th").length;k.showError(a);if(f)s.debug&&k.log("Ajax Error",e,f),k.showError(a,0===e.status?"Not