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

3 lines
13 KiB
JavaScript
Raw Normal View History

2014-04-10 15:29:04 +00:00
/* tablesorter pager plugin updated 4/10/2014 (v2.15.14) */
;(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 c=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"](c).attr("aria-disabled",f), b.$container.find(b.cssNext+","+b.cssLast)[e?"addClass":"removeClass"](c).attr("aria-disabled",e))},p=function(b,a,c){var e,f,g,d=b.config;e=d.$table.hasClass("hasFilters")&&!a.ajaxUrl;g=(d.widgetOptions&&d.widgetOptions.filter_filteredRow||"filtered")+","+d.selectorRemove+(a.countChildRows?"":",."+d.cssChildRow);f=a.size||10;a.totalPages=Math.ceil(a.totalRows/f);a.filteredRows=e?d.$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(d,b){return a.totalPages?a.page+(b?parseInt(b,10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(d){d=d.replace(/[{}\s]/g,"");var b=d.split(":"), c=a.ajaxData,e=/(rows?|pages?)$/i.test(d)?0:"";return 1<b.length&&c&&c[b[0]]?c[b[0]][b[1]]:a[d]||(c?c[d]: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!==c&&(d.$table.trigger("pagerComplete",a),a.savePages&&k.storage&&k.storage(b,a.storageKey,{page:a.page,size:a.size}))},t=function(b,a){var c,e=b.config,f=e.$tbodies.eq(0);a.fixedHeight&& (f.find("tr.pagerSavedHeightSpacer").remove(),c=h.data(b,"pagerSavedHeight"))&&(c-=f.height(),5<c&&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:'+c+'px;"></tr>'))},z=function(b,a){var c=b.config.$tbodies.eq(0);c.find("tr.pagerSavedHeightSpacer").remove();h.data(b,"pagerSavedHeight",c.height());t(b,a);h.data(b,"pagerLastSize",a.size)},u=function(b,a){if(!a.ajaxUrl){var c, e=0,f=b.config,g=f.$tbodies.eq(0).children(),d=g.length,h=a.page*a.size,l=h+a.size,q=f.widgetOptions&&f.widgetOptions.filter_filteredRow||"filtered",r=0;for(c=0;c<d;c++)g[c].className.match(q)||(r===h&&g[c].className.match(f.cssChildRow)?g[c].style.display="none":(g[c].style.display=r>=h&&r<l?"":"none",r+=g[c].className.match(f.cssChildRow+"|"+f.selectorRemove.slice(1))&&!a.countChildRows?0:1,r===l&&"none"!==g[c].style.display&&g[c].className.match(k.css.cssHasChild)&&(e=c)));if(0<e&&g[e].className.match(k.css.cssHasChild))for(;++e< d&&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,c,e,f){if("function"===typeof c.ajaxProcessing){var g,d,y,l,q,r,s=a.config,n=s.$table,m="";g=c.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