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

3 lines
12 KiB
JavaScript
Raw Normal View History

2013-12-02 19:26:31 +00:00
/*! tablesorter pager plugin minified - updated 12/2/2013 (v2.14.3) */
;(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"},ajaxProcessing:function(b){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,size:10,savePages:!0,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,w=function(b,a){var c=b.cssDisabled,e=!!a,f=Math.min(b.totalPages,b.filteredPages);b.updateArrows&&(b.$container.find(b.cssFirst+","+b.cssPrev)[e||0===b.page?"addClass":"removeClass"](c),b.$container.find(b.cssNext+","+b.cssLast)[e||b.page===f-1?"addClass":"removeClass"](c))},r=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;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(b,d){return a.page+(d?parseInt(d,10):1)}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(b){b=b.replace(/[{}\s]/g,"");var d=b.split(":"),c=a.ajaxData,e=/(rows?|pages?)$/i.test(b)?0:"";return 1<d.length&&c&&c[d[0]]?c[d[0]][d[1]]:a[b]||(c?c[b]: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)}w(a);a.initialized&&!1!==c&&(d.$table.trigger("pagerComplete",a),a.savePages&&k.storage&&k.storage(b,"tablesorter-pager",{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>'))},A=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=b.config,f=e.$tbodies.eq(0).children(),g=f.length,d=a.page*a.size,h=d+a.size,k=e.widgetOptions&&e.widgetOptions.filter_filteredRow||"filtered",n=0;for(c=0;c<g;c++)f[c].className.match(k)|| (f[c].style.display=n>=d&&n<h?"":"none",n+=f[c].className.match(e.cssChildRow+"|"+e.selectorRemove.slice(1))&&!a.countChildRows?0:1)}},B=function(b,a){a.size=parseInt(a.$size.val(),10)||a.size;h.data(b,"pagerLastSize",a.size);w(a);a.removeRows||(u(b,a),h(b).bind("sortEnd.pager filterEnd.pager",function(){u(b,a)}))},C=function(b,a,c,e,f){if("function"===typeof c.ajaxProcessing){var g,d,s,m,n,x,p=a.config,l=p.$table,q="";g=c.ajaxProcessing(b,a)||[0,[]];b=l.find("thead th").length;l.find("thead tr."+ c.cssErrorRow).remove();if(f)p.debug&&k.log("Ajax Error",e,f),h('<tr class="'+c.cssErrorRow+'"><td style="text-align:center;" colspan="'+b+'">'+(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.status+"]")+"</td></tr>").click(function(){h(this).remove()}).appendTo(l.find("th