tablesorter/dist/js/widgets/widget-pager.min.js
Rob Garrison 5e4ab3b843 2.30.2
2018-04-26 15:25:54 -05:00

2 lines
22 KiB
JavaScript

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