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

3 lines
15 KiB
JavaScript
Raw Normal View History

2014-08-02 02:31:33 +00:00
/* tablesorter pager plugin updated 8/1/2014 (v2.17.6) */
;(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,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(b,a){var d=b.cssDisabled,e=!!a,g=e||0===b.page,f=Math.min(b.totalPages,b.filteredPages),e=e||b.page===f-1||0===f;b.updateArrows&&(b.$container.find(b.cssFirst+","+b.cssPrev)[g?"addClass":"removeClass"](d).attr("aria-disabled", g),b.$container.find(b.cssNext+","+b.cssLast)[e?"addClass":"removeClass"](d).attr("aria-disabled",e))},t=function(b,a,d){var e,g,f,l,c=b.config;l=c.$table.hasClass("hasFilters");f=[];e=a.size||10;f=[c.widgetOptions&&c.widgetOptions.filter_filteredRow||"filtered",c.selectorRemove.replace(/^(\w+\.)/g,"")];a.countChildRows&&f.push(c.cssChildRow);f.join("|");l&&!a.ajaxUrl?h.isEmptyObject(c.cache)?a.filteredRows=a.totalRows=c.$tbodies.eq(0).children("tr").not(a.countChildRows?"":"."+c.cssChildRow).length: (a.filteredRows=0,h.each(c.cache[0].normalized,function(d,b){a.filteredRows+=a.regexRows.test(b[c.columns].$row[0].className)?0:1})):l||(a.filteredRows=a.totalRows);a.totalPages=Math.ceil(a.totalRows/e);c.totalRows=a.totalRows;c.filteredRows=a.filteredRows;a.filteredPages=Math.ceil(a.filteredRows/e)||0;if(0<=Math.min(a.totalPages,a.filteredPages)&&(f=a.size*a.page>a.filteredRows,a.startRow=f?1:0===a.filteredRows?0:a.size*a.page+1,a.page=f?0:a.page,a.endRow=Math.min(a.filteredRows,a.totalRows,a.size* (a.page+1)),l=a.$container.find(a.cssPageDisplay),f=(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){var b,d;b=c.replace(/[{}\s]/g,"");c=b.split(":");d=a.ajaxData;var e=/(rows?|pages?)$/i.test(b)?0:"";return/(startRow|page)/.test(c[0])&&"input"===c[1]?(b=(""+("page"===c[0]?a.totalPages:a.totalRows)).length,d="page"===c[0]?a.page+1:a.startRow, '<input type="text" class="ts-'+c[0]+'" style="max-width:'+b+'em" value="'+d+'"/>'):1<c.length&&d&&d[c[0]]?d[c[0]][c[1]]:a[b]||(d?d[b]:e)||e}),l.length)){l["INPUT"===l[0].tagName?"val":"html"](f);if(a.$goto.length){f="";g=Math.min(a.totalPages,a.filteredPages);for(e=1;e<=g;e++)f+="<option>"+e+"</option>";a.$goto.html(f).val(a.page+1)}l.find(".ts-startRow, .ts-page").unbind("change").bind("change",function(){var b=h(this).val(),b=h(this).hasClass("ts-startRow")?Math.floor(b/a.size)+1:b;c.$table.trigger("pageSet.pager", [b])})}p(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}))},u=function(b,a){var d,e=b.config,g=e.$tbodies.eq(0);a.fixedHeight&&(g.find("tr.pagerSavedHeightSpacer").remove(),d=h.data(b,"pagerSavedHeight"))&&(d-=g.height(),5<d&&h.data(b,"pagerLastSize")===a.size&&g.children("tr:visible").length<a.size&&g.append('<tr class="pagerSavedHeightSpacer '+e.selectorRemove.replace(/^(\w+\.)/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());u(b,a);h.data(b,"pagerLastSize",a.size)},v=function(b,a){if(!a.ajaxUrl){var d,e=0,g=b.config,f=g.$tbodies.eq(0).children("tr"),h=f.length,c=a.page*a.size,m=c+a.size,n=g.widgetOptions&&g.widgetOptions.filter_filteredRow||"filtered",s=0;for(d=0;d<h;d++)f[d].className.match(n)||(s===c&&f[d].className.match(g.cssChildRow)?f[d].style.display="none":(f[d].style.display=s>=c&& s<m?"":"none",s+