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

3 lines
15 KiB
JavaScript
Raw Normal View History

2014-09-16 00:44:03 +00:00
/* tablesorter pager plugin updated 9/15/2014 (v2.17.8) */
;(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,f=!!a,g=f||0===b.page,e=Math.min(b.totalPages,b.filteredPages),f=f||b.page===e-1||0===e;b.updateArrows&&(b.$container.find(b.cssFirst+","+b.cssPrev)[g?"addClass":"removeClass"](d).attr("aria-disabled", g),b.$container.find(b.cssNext+","+b.cssLast)[f?"addClass":"removeClass"](d).attr("aria-disabled",f))},t=function(b,a,d){var f,g,e,l,c=b.config;l=c.$table.hasClass("hasFilters");e=[];f=a.size||10;e=[c.widgetOptions&&c.widgetOptions.filter_filteredRow||"filtered",c.selectorRemove.replace(/^(\w+\.)/g,"")];a.countChildRows&&e.push(c.cssChildRow);e.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(b,d){a.filteredRows+=a.regexRows.test(d[c.columns].$row[0].className)?0:1})):l||(a.filteredRows=a.totalRows);a.totalPages=Math.ceil(a.totalRows/f);c.totalRows=a.totalRows;c.filteredRows=a.filteredRows;a.filteredPages=Math.ceil(a.filteredRows/f)||0;if(0<=Math.min(a.totalPages,a.filteredPages)&&(e=a.size*a.page>a.filteredRows,a.startRow=e?1:0===a.filteredRows?0:a.size*a.page+1,a.page=e?0:a.page,a.endRow=Math.min(a.filteredRows,a.totalRows,a.size* (a.page+1)),l=a.$container.find(a.cssPageDisplay),e=(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"](e);if(a.$goto.length){e="";g=Math.min(a.totalPages,a.filteredPages);for(f=1;f<=g;f++)e+="<option>"+f+"</option>";a.$goto[0].innerHTML=e;a.$goto[0].value=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,f=b.config,g=f.$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 '+f.selectorRemove.replace(/^(\w+\.)/g, "")+'" style="height:'+d+'px;"></tr>'))},A=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,f=0,g=b.config,e=g.$tbodies.eq(0).children("tr"),h=e.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++)e[d].className.match(n)||(s===c&&e[d].className.match(g.cssChildRow)?e[d].style.display= "none":(e[d].style.display=s>=