tablesorter/dist/js/widgets/widget-pager.min.js
2016-05-01 15:33:35 -05:00

2 lines
22 KiB
JavaScript

/*! Widget: Pager - updated 5/1/2016 (v2.26.0) */
!function(a){"use strict";var b,c=a.tablesorter;c.addWidget({id:"pager",priority:55,options:{pager_output:"{startRow} to {endRow} of {totalRows} rows",pager_updateArrows:!0,pager_startPage:0,pager_pageReset:0,pager_size:10,pager_maxOptionSize:20,pager_savePages:!0,pager_storageKey:"tablesorter-pager",pager_fixedHeight:!1,pager_countChildRows:!1,pager_removeRows:!1,pager_ajaxUrl:null,pager_customAjaxUrl:function(a,b){return b},pager_ajaxError:null,pager_ajaxObject:{dataType:"json"},pager_processAjaxOnInit:!0,pager_ajaxProcessing:function(a){return[0,[],null]},pager_css:{container:"tablesorter-pager",errorRow:"tablesorter-errorRow",disabled:"disabled"},pager_selectors:{container:".pager",first:".first",prev:".prev",next:".next",last:".last",gotoPage:".gotoPage",pageDisplay:".pagedisplay",pageSize:".pagesize"}},init:function(a){b.init(a)},format:function(a,c){return c.pager&&c.pager.initialized?void b.moveToPage(c,c.pager,!1):b.initComplete(c)},remove:function(a,c,d,e){b.destroyPager(c,e)}}),b=c.pager={init:function(d){if(!(d.hasInitialized&&d.config.pager&&d.config.pager.initialized)){var e,f=d.config,g=f.widgetOptions,h=g.pager_selectors,i=f.pager=a.extend({totalPages:0,filteredRows:0,filteredPages:0,currentFilters:[],page:g.pager_startPage,startRow:0,endRow:0,ajaxCounter:0,$size:null,last:{},setSize:g.pager_size,setPage:g.pager_startPage},f.pager);i.isInitializing||(i.isInitializing=!0,f.debug&&console.log("Pager: Initializing"),i.size=a.data(d,"pagerLastSize")||g.pager_size,i.$container=a(h.container).addClass(g.pager_css.container).show(),i.$goto=i.$container.find(h.gotoPage),i.$size=i.$container.find(h.pageSize),i.totalRows=f.$tbodies.eq(0).children("tr").not(g.pager_countChildRows?"":"."+f.cssChildRow).length,i.oldAjaxSuccess=i.oldAjaxSuccess||g.pager_ajaxObject.success,f.appender=b.appender,i.initializing=!0,g.pager_savePages&&c.storage&&(e=c.storage(d,g.pager_storageKey)||{},i.page=(isNaN(e.page)?i.page:e.page)||i.setPage||0,i.size="all"===e.size?e.size:(isNaN(e.size)?i.size:e.size)||i.setSize||10,a.data(d,"pagerLastSize",i.size),i.$size.val(i.size)),i.regexRows=new RegExp("("+(g.filter_filteredRow||"filtered")+"|"+f.selectorRemove.slice(1)+"|"+f.cssChildRow+")"),i.initialized=!1,f.$table.triggerHandler("pagerBeforeInitialized",f),b.enablePager(f,!1),i.ajaxObject=g.pager_ajaxObject,i.ajaxObject.url=g.pager_ajaxUrl,"string"==typeof g.pager_ajaxUrl?(i.ajax=!0,g.filter_serversideFiltering=!0,f.serverSideSorting=!0,b.moveToPage(f,i)):(i.ajax=!1,c.appendCache(f,!0)))}},initComplete:function(a){var d=a.pager;b.bindEvents(a),b.setPageSize(a,0),d.ajax||b.hideRowsSetup(a),d.initialized=!0,d.initializing=!1,d.isInitializing=!1,a.debug&&console.log("Pager: Triggering pagerInitialized"),a.$table.triggerHandler("pagerInitialized",a),a.widgetOptions.filter_initialized&&c.hasWidget(a.table,"filter")||b.updatePageDisplay(a,!d.ajax)},bindEvents:function(d){var e,f,g=d.pager,h=d.widgetOptions,i=d.namespace+"pager",j=h.pager_selectors;d.$table.off(i).on("filterInit filterStart ".split(" ").join(i+" "),function(b,c){g.currentFilters=a.isArray(c)?c:d.$table.data("lastSearch"),"filterStart"===b.type&&h.pager_pageReset!==!1&&(d.lastCombinedFilter||"")!==(g.currentFilters||[]).join("")&&(g.page=h.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(i+" "),function(){g.currentFilters=d.$table.data("lastSearch"),(g.initialized||g.initializing)&&(d.delayInit&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),b.updatePageDisplay(d,!1),c.applyWidget(d.table))}).on("disablePager"+i,function(a){a.stopPropagation(),b.showAllRows(d)}).on("enablePager"+i,function(a){a.stopPropagation(),b.enablePager(d,!0)}).on("destroyPager"+i,function(a,b){a.stopPropagation(),c.removeWidget(d.table,"pager",!1)}).on("updateComplete"+i,function(a,e,f){if(a.stopPropagation(),e&&!f&&!g.ajax){var i=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);g.totalRows=i.length-(h.pager_countChildRows?0:i.filter("."+d.cssChildRow).length),g.totalPages="all"===g.size?1:Math.ceil(g.totalRows/g.size),i.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),g.page>=g.totalPages&&b.moveToLastPage(d,g),b.hideRows(d),b.changeHeight(d),b.updatePageDisplay(d,!1),c.applyWidget(e),b.updatePageDisplay(d)}}).on("pageSize refreshComplete ".split(" ").join(i+" "),function(a,c){a.stopPropagation(),b.setPageSize(d,b.parsePageSize(d,c,"get")),b.hideRows(d),b.updatePageDisplay(d,!1)}).on("pageSet pagerUpdate ".split(" ").join(i+" "),function(a,c){a.stopPropagation(),"pagerUpdate"===a.type&&(c="undefined"==typeof c?g.page+1:c,g.last.page=!0),g.page=(parseInt(c,10)||1)-1,b.moveToPage(d,g,!0),b.updatePageDisplay(d,!1)}).on("pageAndSize"+i,function(a,c,e){a.stopPropagation(),g.page=(parseInt(c,10)||1)-1,b.setPageSize(d,b.parsePageSize(d,e,"get")),b.moveToPage(d,g,!0),b.hideRows(d),b.updatePageDisplay(d,!1)}),e=[j.first,j.prev,j.next,j.last],f=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],d.debug&&!g.$container.length&&console.warn("Pager: >> Container not found"),g.$container.find(e.join(",")).attr("tabindex",0).off("click"+i).on("click"+i,function(c){c.stopPropagation();var i,j=a(this),k=e.length;if(!j.hasClass(h.pager_css.disabled))for(i=0;k>i;i++)if(j.is(e[i])){b[f[i]](d,g);break}}),g.$goto.length?g.$goto.off("change"+i).on("change"+i,function(){g.page=a(this).val()-1,b.moveToPage(d,g,!0),b.updatePageDisplay(d,!1)}):d.debug&&console.warn("Pager: >> Goto selector not found"),g.$size.length?(g.$size.find("option").removeAttr("selected"),g.$size.off("change"+i).on("change"+i,function(){if(!a(this).hasClass(h.pager_css.disabled)){var c=a(this).val();g.$size.val(c),b.setPageSize(d,c),b.changeHeight(d)}return!1})):d.debug&&console.warn("Pager: >> Size selector not found")},pagerArrows:function(a,c){var d=a.pager,e=!!c,f=e||0===d.page,g=b.getTotalPages(a,d),h=e||d.page===g-1||0===g,i=a.widgetOptions,j=i.pager_selectors;i.pager_updateArrows&&(d.$container.find(j.first+","+j.prev).toggleClass(i.pager_css.disabled,f).attr("aria-disabled",f),d.$container.find(j.next+","+j.last).toggleClass(i.pager_css.disabled,h).attr("aria-disabled",h))},calcFilters:function(b){var c,d,e,f=b.widgetOptions,g=b.pager,h=b.$table.hasClass("hasFilters");if(h&&!f.pager_ajaxUrl)if(a.isEmptyObject(b.cache))g.filteredRows=g.totalRows=b.$tbodies.eq(0).children("tr").not(f.pager_countChildRows?"":"."+b.cssChildRow).length;else for(g.filteredRows=0,c=b.cache[0].normalized,e=c.length,d=0;e>d;d++)g.filteredRows+=g.regexRows.test(c[d][b.columns].$row[0].className)?0:1;else h||(g.filteredRows=g.totalRows)},updatePageDisplay:function(d,e){if(!d.pager||!d.pager.initializing){var f,g,h,i,j,k,l=d.table,m=d.widgetOptions,n=d.pager,o=d.namespace+"pager",p=b.parsePageSize(d,n.size,"get");if("all"===p&&(p=n.totalRows),m.pager_countChildRows&&(g[g.length]=d.cssChildRow),n.$size.add(n.$goto).removeClass(m.pager_css.disabled).removeAttr("disabled").attr("aria-disabled","false"),n.totalPages=Math.ceil(n.totalRows/p),d.totalRows=n.totalRows,b.parsePageNumber(d,n),b.calcFilters(d),d.filteredRows=n.filteredRows,n.filteredPages=Math.ceil(n.filteredRows/p)||0,b.getTotalPages(d,n)>=0){if(g=p*n.page>n.filteredRows&&e,n.page=g?m.pager_pageReset||0:n.page,n.startRow=g?p*n.page+1:0===n.filteredRows?0:p*n.page+1,n.endRow=Math.min(n.filteredRows,n.totalRows,p*(n.page+1)),h=n.$container.find(m.pager_selectors.pageDisplay),f=(n.ajaxData&&n.ajaxData.output?n.ajaxData.output||m.pager_output:m.pager_output).replace(/\{page([\-+]\d+)?\}/gi,function(a,b){return n.totalPages?n.page+(b?parseInt(b,10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(a){var b,c,d=a.replace(/[{}\s]/g,""),e=d.split(":"),f=n.ajaxData,g=/(rows?|pages?)$/i.test(d)?0:"";return/(startRow|page)/.test(e[0])&&"input"===e[1]?(b=(""+("page"===e[0]?n.totalPages:n.totalRows)).length,c="page"===e[0]?n.page+1:n.startRow,'<input type="text" class="ts-'+e[0]+'" style="max-width:'+b+'em" value="'+c+'"/>'):e.length>1&&f&&f[e[0]]?f[e[0]][e[1]]:n[d]||(f?f[d]:g)||g}),n.$goto.length){for(g="",i=b.buildPageSelect(d,n),k=i.length,j=0;k>j;j++)g+='<option value="'+i[j]+'">'+i[j]+"</option>";n.$goto.html(g).val(n.page+1)}h.length&&(h["INPUT"===h[0].nodeName?"val":"html"](f),h.find(".ts-startRow, .ts-page").off("change"+o).on("change"+o,function(){var b=a(this).val(),c=a(this).hasClass("ts-startRow")?Math.floor(b/p)+1:b;d.$table.triggerHandler("pageSet"+o,[c])}))}b.pagerArrows(d),b.fixHeight(d),n.initialized&&e!==!1&&(d.debug&&console.log("Pager: Triggering pagerComplete"),d.$table.triggerHandler("pagerComplete",d),m.pager_savePages&&c.storage&&c.storage(l,m.pager_storageKey,{page:n.page,size:p===n.totalRows?"all":p}))}},buildPageSelect:function(c,d){var e,f,g,h,i,j,k=c.widgetOptions,l=b.getTotalPages(c,d)||1,m=5*Math.ceil(l/k.pager_maxOptionSize/5),n=l>k.pager_maxOptionSize,o=d.page+1,p=m,q=l-m,r=[1],s=n?m:1;for(e=s;l>=e;)r[r.length]=e,e+=n?m:1;if(r[r.length]=l,n){for(g=[],f=Math.max(Math.floor(k.pager_maxOptionSize/m)-1,5),p=o-f,1>p&&(p=1),q=o+f,q>l&&(q=l),e=p;q>=e;e++)g[g.length]=e;r=a.grep(r,function(b,c){return a.inArray(b,r)===c}),i=r.length,j=g.length,i-j>m/2&&i+j>k.pager_maxOptionSize&&(h=Math.floor(i/2)-Math.floor(j/2),Array.prototype.splice.apply(r,[h,j])),r=r.concat(g)}return r=a.grep(r,function(b,c){return a.inArray(b,r)===c}).sort(function(a,b){return a-b})},fixHeight:function(b){var c,d,e=b.table,f=b.pager,g=b.widgetOptions,h=b.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),g.pager_fixedHeight&&!f.isDisabled&&(d=a.data(e,"pagerSavedHeight"),d&&(c=d-h.height(),c>5&&a.data(e,"pagerLastSize")===f.size&&h.children("tr:visible").length<("all"===f.size?f.totalRows:f.size)&&h.append('<tr class="pagerSavedHeightSpacer '+b.selectorRemove.slice(1)+'" style="height:'+c+'px;"></tr>')))},changeHeight:function(c){var d,e=c.table,f=c.pager,g="all"===f.size?f.totalRows:f.size,h=c.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),h.children("tr:visible").length||h.append('<tr class="pagerSavedHeightSpacer '+c.selectorRemove.slice(1)+'"><td>&nbsp</td></tr>'),d=h.children("tr").eq(0).height()*g,a.data(e,"pagerSavedHeight",d),b.fixHeight(c),a.data(e,"pagerLastSize",f.size)},hideRows:function(a){if(!a.widgetOptions.pager_ajaxUrl){var b,d,e,f,g,h=(a.table,a.pager),i=a.widgetOptions,j=a.$tbodies.length,k="all"===h.size?h.totalRows:h.size,l=h.page*k,m=l+k,n=i&&i.filter_filteredRow||"filtered",o=0,p=0;for(h.cacheIndex=[],b=0;j>b;b++){for(e=a.$tbodies.eq(b).children("tr"),f=e.length,g=0,o=0,p=0,d=0;f>d;d++)e[d].className.match(n)||(p===l&&e[d].className.match(a.cssChildRow)?e[d].style.display="none":(e[d].style.display=p>=l&&m>p?"":"none",o!==p&&p>=l&&m>p&&(h.cacheIndex[h.cacheIndex.length]=d,o=p),p+=e[d].className.match(a.cssChildRow+"|"+a.selectorRemove.slice(1))&&!i.pager_countChildRows?0:1,p===m&&"none"!==e[d].style.display&&e[d].className.match(c.css.cssHasChild)&&(g=d)));if(g>0&&e[g].className.match(c.css.cssHasChild))for(;++g<f&&e[g].className.match(a.cssChildRow);)e[g].style.display=""}}},hideRowsSetup:function(c){var d=c.pager,e=c.namespace+"pager",f=d.$size.val();d.size=b.parsePageSize(c,f,"get"),d.$size.val(d.size),a.data(c.table,"pagerLastSize",d.size),b.pagerArrows(c),c.widgetOptions.pager_removeRows||(b.hideRows(c),c.$table.on("sortEnd filterEnd ".split(" ").join(e+" "),function(){b.hideRows(c)}))},renderAjax:function(d,e,f,g,h){var i=e.table,j=e.pager,k=e.widgetOptions;if(a.isFunction(k.pager_ajaxProcessing)){e.$tbodies.eq(0).empty();var l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=e.$table,B="",C=k.pager_ajaxProcessing(d,i,f)||[0,[]],D=A.find("thead th").length;if(c.showError(i),h)e.debug&&console.error("Pager: >> Ajax Error",f,g,h),c.showError(i,f,g,h),e.$tbodies.eq(0).children("tr").detach(),j.totalRows=0;else{if(a.isArray(C)?(n=isNaN(C[0])&&!isNaN(C[1]),x=C[n?1:0],j.totalRows=isNaN(x)?j.totalRows||0:x,e.totalRows=e.filteredRows=j.filteredRows=j.totalRows,v=0===j.totalRows?[]:C[n?0:1]||[],u=C[2]):(j.ajaxData=C,e.totalRows=j.totalRows=C.total,e.filteredRows=j.filteredRows="undefined"!=typeof C.filteredRows?C.filteredRows:C.total,u=C.headers,v=C.rows||[]),w=v&&v.length,v instanceof jQuery)k.pager_processAjaxOnInit&&(e.$tbodies.eq(0).empty(),e.$tbodies.eq(0).append(v));else if(w){for(l=0;w>l;l++){for(B+="<tr>",m=0;m<v[l].length;m++)B+=/^\s*<td/.test(v[l][m])?a.trim(v[l][m]):"<td>"+v[l][m]+"</td>";B+="</tr>"}k.pager_processAjaxOnInit&&e.$tbodies.eq(0).html(B)}if(k.pager_processAjaxOnInit=!0,u&&u.length===D)for(o=A.hasClass("hasStickyHeaders"),q=o?k.$sticky.children("thead:first").children("tr").children():"",p=A.find("tfoot tr:first").children(),r=e.$headers.filter("th"),y=r.length,m=0;y>m;m++)s=r.eq(m),s.find("."+c.css.icon).length?(t=s.find("."+c.css.icon).clone(!0),s.find(".tablesorter-header-inner").html(u[m]).append(t),o&&q.length&&(t=q.eq(m).find("."+c.css.icon).clone(!0),q.eq(m).find(".tablesorter-header-inner").html(u[m]).append(t))):(s.find(".tablesorter-header-inner").html(u[m]),o&&q.length&&q.eq(m).find(".tablesorter-header-inner").html(u[m])),p.eq(m).html(u[m])}e.showProcessing&&c.isProcessing(i),z=b.parsePageSize(e,j.size,"get"),j.totalPages="all"===z?1:Math.ceil(j.totalRows/z),j.last.totalRows=j.totalRows,j.last.currentFilters=j.currentFilters,j.last.sortList=(e.sortList||[]).join(","),j.initializing=!1,b.updatePageDisplay(e,!1),c.updateCache(e,function(){j.initialized&&setTimeout(function(){e.debug&&console.log("Pager: Triggering pagerChange"),A.triggerHandler("pagerChange",j),c.applyWidget(i),b.updatePageDisplay(e)},0)})}j.initialized||c.applyWidget(i)},getAjax:function(d){var e,f=b.getAjaxUrl(d),g=a(document),h=d.namespace+"pager",i=d.pager;""!==f&&(d.showProcessing&&c.isProcessing(d.table,!0),g.on("ajaxError"+h,function(a,c,e,f){b.renderAjax(null,d,c,e,f),g.off("ajaxError"+h)}),e=++i.ajaxCounter,i.last.ajaxUrl=f,i.ajaxObject.url=f,i.ajaxObject.success=function(a,c,f){e<i.ajaxCounter||(b.renderAjax(a,d,f),g.off("ajaxError"+h),"function"==typeof i.oldAjaxSuccess&&i.oldAjaxSuccess(a))},d.debug&&console.log("Pager: Ajax initialized",i.ajaxObject),a.ajax(i.ajaxObject))},getAjaxUrl:function(b){var c,d,e=b.pager,f=b.widgetOptions,g=f.pager_ajaxUrl?f.pager_ajaxUrl.replace(/\{page([\-+]\d+)?\}/,function(a,b){return e.page+(b?parseInt(b,10):0)}).replace(/\{size\}/g,e.size):"",h=b.sortList,i=e.currentFilters||b.$table.data("lastSearch")||[],j=g.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),k=g.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),l=[];if(j){for(j=j[1],d=h.length,c=0;d>c;c++)l[l.length]=j+"["+h[c][0]+"]="+h[c][1];g=g.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):j),l=[]}if(k){for(k=k[1],d=i.length,c=0;d>c;c++)i[c]&&(l[l.length]=k+"["+c+"]="+encodeURIComponent(i[c]));g=g.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):k),e.currentFilters=i}return a.isFunction(f.pager_customAjaxUrl)&&(g=f.pager_customAjaxUrl(b.table,g)),b.debug&&console.log("Pager: Ajax url = "+g),g},renderTable:function(a,d){var e,f,g,h,i=a.table,j=a.pager,k=a.widgetOptions,l=a.$table.hasClass("hasFilters"),m=d&&d.length||0,n="all"===j.size?j.totalRows:j.size,o=j.page*n;if(1>m)return void(a.debug&&console.warn("Pager: >> No rows for pager to render"));if(j.page>=j.totalPages)return b.moveToLastPage(a,j);if(j.cacheIndex=[],j.isDisabled=!1,j.initialized&&(a.debug&&console.log("Pager: Triggering pagerChange"),a.$table.triggerHandler("pagerChange",a)),k.pager_removeRows){for(c.clearTableBody(i),e=c.processTbody(i,a.$tbodies.eq(0),!0),f=l?0:o,g=l?0:o,h=0;n>h&&f<d.length;)l&&/filtered/.test(d[f][0].className)||(g++,g>o&&n>=h&&(h++,j.cacheIndex[j.cacheIndex.length]=f,e.append(d[f]))),f++;c.processTbody(i,e,!1)}else b.hideRows(a);b.updatePageDisplay(a),k.pager_startPage=j.page,k.pager_size=j.size,i.isUpdating&&(a.debug&&console.log("Pager: Triggering updateComplete"),a.$table.triggerHandler("updateComplete",[i,!0]))},showAllRows:function(d){var e,f,g,h=d.table,i=d.pager,j=d.widgetOptions;for(i.ajax?b.pagerArrows(d,!0):(a.data(h,"pagerLastPage",i.page),a.data(h,"pagerLastSize",i.size),i.page=0,i.size="all",i.totalPages=1,d.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(d,d.rowsCopy),i.isDisabled=!0,c.applyWidget(h),d.debug&&console.log("Pager: Disabled")),f=i.$size.add(i.$goto).add(i.$container.find(".ts-startRow, .ts-page ")),g=f.length,e=0;g>e;e++)f.eq(e).attr("aria-disabled","true").addClass(j.pager_css.disabled)[0].disabled=!0},updateCache:function(d){var e=d.pager;c.updateCache(d,function(){if(!a.isEmptyObject(d.cache)){var c,f=[],g=d.cache[0].normalized;for(e.totalRows=g.length,c=0;c<e.totalRows;c++)f[f.length]=g[c][d.columns].$row;d.rowsCopy=f,b.moveToPage(d,e,!0),e.last.currentFilters=[" "]}})},moveToPage:function(d,e,f){if(!e.isDisabled){if(f!==!1&&e.initialized&&a.isEmptyObject(d.cache))return b.updateCache(d);var g,h=d.table,i=d.widgetOptions,j=e.last;e.ajax&&!i.filter_initialized&&c.hasWidget(h,"filter")||(b.parsePageNumber(d,e),b.calcFilters(d),j.currentFilters=""===(j.currentFilters||[]).join("")?[]:j.currentFilters,e.currentFilters=""===(e.currentFilters||[]).join("")?[]:e.currentFilters,j.page===e.page&&j.size===e.size&&j.totalRows===e.totalRows&&(j.currentFilters||[]).join(",")===(e.currentFilters||[]).join(",")&&(j.ajaxUrl||"")===(e.ajaxObject.url||"")&&(j.optAjaxUrl||"")===(i.pager_ajaxUrl||"")&&j.sortList===(d.sortList||[]).join(",")||(d.debug&&console.log("Pager: Changing to page "+e.page),e.last={page:e.page,size:e.size,sortList:(d.sortList||[]).join(","),totalRows:e.totalRows,currentFilters:e.currentFilters||[],ajaxUrl:e.ajaxObject.url||"",optAjaxUrl:i.pager_ajaxUrl},e.ajax?i.pager_processAjaxOnInit||a.isEmptyObject(i.pager_initialRows)?b.getAjax(d):(i.pager_processAjaxOnInit=!0,g=i.pager_initialRows,e.totalRows="undefined"!=typeof g.total?g.total:d.debug?console.error("Pager: no initial total page set!")||0:0,e.filteredRows="undefined"!=typeof g.filtered?g.filtered:d.debug?console.error("Pager: no initial filtered page set!")||0:0,b.updatePageDisplay(d,!1)):e.ajax||b.renderTable(d,d.rowsCopy),a.data(h,"pagerLastPage",e.page),e.initialized&&f!==!1&&(d.debug&&console.log("Pager: Triggering pageMoved"),d.$table.triggerHandler("pageMoved",d),c.applyWidget(h),!e.ajax&&h.isUpdating&&(d.debug&&console.log("Pager: Triggering updateComplete"),d.$table.triggerHandler("updateComplete",[h,!0])))))}},getTotalPages:function(a,b){return c.hasWidget(a.table,"filter")?Math.min(b.totalPages,b.filteredPages):b.totalPages},parsePageSize:function(a,b,c){var d=a.pager,e=parseInt(b,10)||d.size||a.widgetOptions.pager_size||10;return/all/i.test(b)||e===d.totalRows?"all":"get"===c?e:d.size},parsePageNumber:function(a,c){var d=b.getTotalPages(a,c)-1;return c.page=parseInt(c.page,10),(c.page<0||isNaN(c.page))&&(c.page=0),c.page>d&&d>=0&&(c.page=d),c.page},setPageSize:function(c,d){var e=c.pager,f=c.table;e.size=b.parsePageSize(c,d,"get"),e.$size.val(b.parsePageSize(c,e.size,"set")),a.data(f,"pagerLastPage",b.parsePageNumber(c,e)),a.data(f,"pagerLastSize",e.size),e.totalPages="all"===e.size?1:Math.ceil(e.totalRows/e.size),e.filteredPages="all"===e.size?1:Math.ceil(e.filteredRows/e.size),b.moveToPage(c,e,!0)},moveToFirstPage:function(a,c){c.page=0,b.moveToPage(a,c,!0)},moveToLastPage:function(a,c){c.page=b.getTotalPages(a,c)-1,b.moveToPage(a,c,!0)},moveToNextPage:function(a,c){c.page++;var d=b.getTotalPages(a,c)-1;c.page>=d&&(c.page=d),b.moveToPage(a,c,!0)},moveToPrevPage:function(a,c){c.page--,c.page<=0&&(c.page=0),b.moveToPage(a,c,!0)},destroyPager:function(a,d){var e=a.table,f=a.pager,g=a.widgetOptions.pager_selectors||{},h=[g.first,g.prev,g.next,g.last,g.gotoPage,g.pageSize].join(","),i=a.namespace+"pager";if(f){if(f.initialized=!1,a.$table.off(i),f.$container.hide().find(h).off(i),d)return;a.appender=null,b.showAllRows(a),c.storage&&c.storage(e,a.widgetOptions.pager_storageKey,""),f.$container=null,f.$goto=null,f.$size=null,a.pager=null,a.rowsCopy=null}},enablePager:function(d,e){var f,g,h=d.table,i=d.pager;i.isDisabled=!1,i.page=a.data(h,"pagerLastPage")||i.page||0,g=i.$size.find("option[selected]").val(),i.size=a.data(h,"pagerLastSize")||b.parsePageSize(d,g,"get"),i.$size.val(i.size),i.totalPages="all"===i.size?1:Math.ceil(b.getTotalPages(d,i)/i.size),d.$table.removeClass("pagerDisabled"),h.id&&(f=h.id+"_pager_info",i.$container.find(d.widgetOptions.pager_selectors.pageDisplay).attr("id",f),d.$table.attr("aria-describedby",f)),b.changeHeight(d),e&&(c.update(d),b.setPageSize(d,i.size),b.hideRowsSetup(d),d.debug&&console.log("Pager: Enabled"))},appender:function(c,d){var e=c.config,f=e.widgetOptions,g=e.pager;g.ajax?b.moveToPage(e,g,!0):(e.rowsCopy=d,g.totalRows=f.pager_countChildRows?e.$tbodies.eq(0).children("tr").length:d.length,g.size=a.data(c,"pagerLastSize")||g.size||f.pager_size||g.setSize||10,g.totalPages="all"===g.size?1:Math.ceil(g.totalRows/g.size),b.moveToPage(e,g),b.updatePageDisplay(e,!1))}},c.showError=function(b,c,d,e){var f,g=a(b),h=g[0].config,i=h&&h.widgetOptions,j=h.pager&&h.pager.cssErrorRow||i&&i.pager_css&&i.pager_css.errorRow||"tablesorter-errorRow",k=typeof c,l=!0,m="",n=function(){h.$table.find("thead").find("."+j).remove()};if(!g.length)return void console.error("tablesorter showError: no table parameter passed");if("function"==typeof h.pager.ajaxError){if(l=h.pager.ajaxError(h,c,d,e),l===!1)return n();m=l}else if("function"==typeof i.pager_ajaxError){if(l=i.pager_ajaxError(h,c,d,e),l===!1)return n();m=l}if(""===m)if("object"===k)m=0===c.status?"Not connected, verify Network":404===c.status?"Requested page not found [404]":500===c.status?"Internal Server Error [500]":"parsererror"===e?"Requested JSON parse failed":"timeout"===e?"Time out error":"abort"===e?"Ajax Request aborted":"Uncaught error: "+c.statusText+" ["+c.status+"]";else{if("string"!==k)return n();m=c}f=a(/tr\>/.test(m)?m:'<tr><td colspan="'+h.columns+'">'+m+"</td></tr>").click(function(){a(this).remove()}).appendTo(h.$table.find("thead:first")).addClass(j+" "+h.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})}}(jQuery);