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

3 lines
13 KiB
JavaScript
Raw Normal View History

2014-03-18 23:13:27 +00:00
/* tablesorter pager plugin updated 3/18/2014 (v2.15.11) */
;(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 u=this,l=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))},q=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)}l(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}))},s=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());s(b,a);h.data(b,"pagerLastSize",a.size)},t=function(b,a){if(!a.ajaxUrl){var d, e=b.config,f=e.$tbodies.eq(0).children(),g=f.length,c=a.page*a.size,h=c+a.size,k=e.widgetOptions&&e.widgetOptions.filter_filteredRow||"filtered",p=0;for(d=0;d<g;d++)f[d].className.match(k)||(f[d].style.display=p>=c&&p<h?"":"none",p+=f[d].className.match(e.cssChildRow+"|"+e.selectorRemove.slice(1))&&!a.countChildRows?0:1)}},A=function(b,a){a.size=parseInt(a.$size.val(),10)||a.size;h.data(b,"pagerLastSize",a.size);l(a);a.removeRows||(t(b,a),h(b).bind("sortEnd.pager filterEnd.pager",function(){t(b,a)}))}, B=function(b,a,d,e,f){if("function"===typeof d.ajaxProcessing){var g,c,y,m,p,v,r=a.config,n=r.$table,l="";g=d.ajaxProcessing(b,a)||[0,[]];b=n.find("thead th").length;k.showError(a);if(f)r.debug&&k.log("Ajax Error",e,f),k.showError(a,0===e.status?"Not connected, verify Network":404===e.status?"Requested page not found [404]":500===e.status?"Internal Server Error [500]":"parsererror"===f?"Requested JSON parse failed":"timeout"===f?"Time out error":"abort"===f?"Ajax Request aborted":"Uncaught error: "+ e.statusText+" ["+e.sta