/*! * tablesorter (FORK) pager plugin * updated 2018-03-26 (v2.30.2) */ !function(e){"use strict";var t=e.tablesorter;e.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(e,t){return t},ajaxError:null,ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,pageReset:0,size:10,maxOptionSize:20,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 a="filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete pageSize pageSet pageAndSize pagerUpdate refreshComplete ",i=this,s=function(e,t,a){var i,s="addClass",r="removeClass",o=t.cssDisabled,n=!!a,l=n||0===t.page,g=z(e,t),c=n||t.page===g-1||0===g;t.updateArrows&&((i=t.$container.find(t.cssFirst+","+t.cssPrev))[l?s:r](o),i.each(function(){this.ariaDisabled=l}),(i=t.$container.find(t.cssNext+","+t.cssLast))[c?s:r](o),i.each(function(){this.ariaDisabled=c}))},r=function(e,a){var i,s,r,o=e.config,n=o.$table.hasClass("hasFilters");if(n&&!a.ajax)if(t.isEmptyObject(o.cache))a.filteredRows=a.totalRows=o.$tbodies.eq(0).children("tr").not(a.countChildRows?"":"."+o.cssChildRow).length;else for(a.filteredRows=0,r=(i=o.cache[0].normalized).length,s=0;s=0){if(c=P*i.page>i.filteredRows&&o,i.page=c?i.pageReset||0:i.page,i.startRow=c?P*i.page+1:0===i.filteredRows?0:P*i.page+1,i.endRow=Math.min(i.filteredRows,i.totalRows,P*(i.page+1)),d=i.$container.find(i.cssPageDisplay),"function"==typeof i.output?g=i.output(a,i):(w=d.attr("data-pager-output"+(i.filteredRows'):r.length>1&&o&&o[r[0]]?o[r[0]][r[1]]:i[s]||(o?o[s]:n)||n})),(p=i.$container.find(i.cssGoto)).length){for(c="",u=(h=n(a,i)).length,f=0;f'+h[f]+"";p.html(c).val(i.page+1)}d.length&&(d["INPUT"===d[0].nodeName?"val":"html"](g),d.find(".ts-startRow, .ts-page").unbind("change"+R).bind("change"+R,function(){var t=e(this).val(),a=e(this).hasClass("ts-startRow")?Math.floor(t/P)+1:t;b.$table.triggerHandler("pageSet"+R,[a])}))}s(a,i),l(a,i),i.initialized&&!1!==o&&(t.debug(b,"pager")&&console.log("Pager >> Triggering pagerComplete"),b.$table.triggerHandler("pagerComplete",i),i.savePages&&t.storage&&t.storage(a,i.storageKey,{page:i.page,size:P===i.totalRows?"all":P}))}},n=function(t,a){var i,s,r,o,n,l,g=z(t,a)||1,c=5*Math.ceil(g/a.maxOptionSize/5),d=g>a.maxOptionSize,p=a.page+1,f=c,u=g-c,h=[1];for(i=d?c:1;i<=g;)h[h.length]=i,i+=d?c:1;if(h[h.length]=g,d){for(r=[],(f=p-(s=Math.max(Math.floor(a.maxOptionSize/c)-1,5)))<1&&(f=1),(u=p+s)>g&&(u=g),i=f;i<=u;i++)r[r.length]=i;(n=(h=e.grep(h,function(t,a){return e.inArray(t,h)===a})).length)-(l=r.length)>c/2&&n+l>a.maxOptionSize&&(o=Math.floor(n/2)-Math.floor(l/2),Array.prototype.splice.apply(h,[o,l])),h=h.concat(r)}return h=e.grep(h,function(t,a){return e.inArray(t,h)===a}).sort(function(e,t){return e-t})},l=function(t,a){var i,s,r,o=t.config,n=o.$tbodies.eq(0);n.find("tr.pagerSavedHeightSpacer").remove(),a.fixedHeight&&!a.isDisabled&&(s=e.data(t,"pagerSavedHeight"))&&(r=0,e(t).css("border-spacing").split(" ").length>1&&(r=e(t).css("border-spacing").split(" ")[1].replace(/[^-\d\.]/g,"")),(i=s-n.height()+r*a.size-r)>5&&e.data(t,"pagerLastSize")===a.size&&n.children("tr:visible").length<("all"===a.size?a.totalRows:a.size)&&n.append(''))},g=function(t,a){var i,s=t.config,r=s.$tbodies.eq(0);r.find("tr.pagerSavedHeightSpacer").remove(),r.children("tr:visible").length||r.append(' '),i=r.children("tr").eq(0).height()*("all"===a.size?a.totalRows:a.size),e.data(t,"pagerSavedHeight",i),l(t,a),e.data(t,"pagerLastSize",a.size)},c=function(e,a){if(!a.ajaxUrl){var i,s=0,r=e.config,o=r.$tbodies.eq(0).children("tr"),n=o.length,l="all"===a.size?a.totalRows:a.size,g=a.page*l,c=g+l,d=0,p=0;for(a.cacheIndex=[],i=0;i=g&&p=g&&p0&&o[s].className.match(t.css.cssHasChild))for(;++s> Ajax Error",r,n,l),t.showError(i,r,n,l),y.$tbodies.eq(0).children("tr").detach(),s.totalRows=0;else{if(e.isArray(I)?(P=I[(d=isNaN(I[0])&&!isNaN(I[1]))?1:0],s.totalRows=isNaN(P)?s.totalRows||0:P,y.totalRows=y.filteredRows=s.filteredRows=s.totalRows,z=0===s.totalRows?[]:I[d?0:1]||[],R=I[2]):(s.ajaxData=I,y.totalRows=s.totalRows=I.total,y.filteredRows=s.filteredRows=void 0!==I.filteredRows?I.filteredRows:I.total,R=I.headers,z=I.rows||[]),x=z&&z.length,z instanceof e)s.processAjaxOnInit&&(y.$tbodies.eq(0).empty(),y.$tbodies.eq(0).append(z));else if(x){for(g=0;g",c=0;c"+z[g][c]+"";$+=""}s.processAjaxOnInit&&y.$tbodies.eq(0).html($)}if(s.processAjaxOnInit=!0,R)for(u=(p=C.hasClass("hasStickyHeaders"))?y.widgetOptions.$sticky.children("thead:first").children("tr:not(."+y.cssIgnoreRow+")").children():"",f=C.find("tfoot tr:first").children(),v=(h=y.$headers.filter("th ")).length,c=0;c> Triggering pagerChange"),C.triggerHandler("pagerChange",s),t.applyWidget(i),o(i,s,!0)},0)})}s.initialized||S(i,s)},f=function(a,i){var s,r=u(a,i),o=e(document),n=a.config,l=n.namespace+"pager";""!==r&&(n.showProcessing&&t.isProcessing(a,!0),o.bind("ajaxError"+l,function(e,t,s,r){p(null,a,i,t,s,r),o.unbind("ajaxError"+l)}),s=++i.ajaxCounter,i.last.ajaxUrl=r,i.ajaxObject.url=r,i.ajaxObject.success=function(e,t,r){s> Ajax initialized",i.ajaxObject),e.ajax(i.ajaxObject))},u=function(a,i){var s,r,o=a.config,n=i.ajaxUrl?i.ajaxUrl.replace(/\{page([\-+]\d+)?\}/,function(e,t){return i.page+(t?parseInt(t,10):0)}).replace(/\{size\}/g,i.size):"",l=o.sortList,g=i.currentFilters||e(a).data("lastSearch")||[],c=n.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),d=n.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),p=[];if(c){for(c=c[1],r=l.length,s=0;s> Ajax url = "+n),n},h=function(a,i,s){var r,n,l,g,d=e(a),p=a.config,f=t.debug(p,"pager"),u=p.$table.hasClass("hasFilters"),h=i&&i.length||0,w="all"===s.size?s.totalRows:s.size,b=s.page*w;if(h<1)f&&console.warn("Pager >> No rows for pager to render");else{if(s.page>=s.totalPages&&m(a,s),s.cacheIndex=[],s.isDisabled=!1,s.initialized&&(f&&console.log("Pager >> Triggering pagerChange"),d.triggerHandler("pagerChange",s)),s.removeRows){for(t.clearTableBody(a),r=t.processTbody(a,p.$tbodies.eq(0),!0),n=u?0:b,l=u?0:b,g=0;gb&&g<=w&&(g++,s.cacheIndex[s.cacheIndex.length]=n,r.append(i[n])),n++;t.processTbody(a,r,!1)}else c(a,s);o(a,s),a.isUpdating&&(f&&console.log("Pager >> Triggering updateComplete"),d.triggerHandler("updateComplete",[a,!0]))}},w=function(a,i){var r,o,n;for(i.ajax?s(a,i,!0):(e.data(a,"pagerLastPage",i.page),e.data(a,"pagerLastSize",i.size),i.page=0,i.size=i.totalRows,i.totalPages=1,e(a).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),h(a,a.config.rowsCopy,i),i.isDisabled=!0,t.applyWidget(a),t.debug(a.config,"pager")&&console.log("Pager >> Disabled")),n=(o=i.$container.find(i.cssGoto+","+i.cssPageSize+", .ts-startRow, .ts-page")).length,r=0;r> Changing to page "+i.page),i.last={page:i.page,size:i.size,sortList:(n.sortList||[]).join(","),totalRows:i.totalRows,currentFilters:i.currentFilters||[],ajaxUrl:i.ajaxObject.url||"",optAjaxUrl:i.ajaxUrl||""},i.ajax?i.processAjaxOnInit||t.isEmptyObject(i.initialRows)?f(a,i):(i.processAjaxOnInit=!0,o=i.initialRows,i.totalRows=void 0!==o.total?o.total:l?console.error("Pager >> No initial total page set!")||0:0,i.filteredRows=void 0!==o.filtered?o.filtered:l?console.error("Pager >> No initial filtered page set!")||0:0,S(a,i)):i.ajax||h(a,n.rowsCopy,i),e.data(a,"pagerLastPage",i.page),i.initialized&&!1!==s&&(l&&console.log("Pager >> Triggering pageMoved"),g.triggerHandler("pageMoved",i),t.applyWidget(a),a.isUpdating&&(l&&console.log("Pager >> Triggering updateComplete"),g.triggerHandler("updateComplete",[a,!0])))))}},z=function(e,a){return t.hasWidget(e,"filter")?Math.min(a.totalPages,a.filteredPages):a.totalPages},x=function(e,t){var a=z(e,t)-1;return t.page=parseInt(t.page,10),(t.page<0||isNaN(t.page))&&(t.page=0),t.page>a&&a>=0&&(t.page=a),t.page},j=function(e,t,a){var i=parseInt(t,10)||e.size||e.settings.size||10;return e.initialized&&(/all/i.test(i+" "+t)||i===e.totalRows)?e.$container.find(e.cssPageSize+' option[value="all"]').length?"all":e.totalRows:"get"===a?i:e.size},P=function(t,a,i){i.size=j(i,a,"get"),i.$container.find(i.cssPageSize).val(i.size),e.data(t,"pagerLastPage",x(t,i)),e.data(t,"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)},v=function(e,t){t.page=0,R(e,t)},m=function(e,t){t.page=z(e,t)-1,R(e,t)},y=function(e,t){t.page++;var a=z(e,t)-1;t.page>=a&&(t.page=a),R(e,t)},C=function(e,t){--t.page<=0&&(t.page=0),R(e,t)},S=function(a,i){i.initialized=!0,i.initializing=!1,t.debug(a.config,"pager")&&console.log("Pager >> Triggering pagerInitialized"),e(a).triggerHandler("pagerInitialized",i),t.applyWidget(a),o(a,i)},$=function(t,a){t.config.pager=e.extend(!0,{},e.tablesorterPager.defaults,a.settings),A(t,a.settings)},I=function(e,a){var i=e.config,s=i.namespace+"pager",r=[a.cssFirst,a.cssPrev,a.cssNext,a.cssLast,a.cssGoto,a.cssPageSize].join(",");w(e,a),a.$container.hide().find(r).unbind(s),i.appender=null,i.$table.unbind(s),t.storage&&t.storage(e,a.storageKey,""),delete i.pager,delete i.rowsCopy},N=function(a,i,s){var r,o,n,l=a.config;i.$container.find(i.cssGoto+","+i.cssPageSize+",.ts-startRow, .ts-page").removeClass(i.cssDisabled).removeAttr("disabled").each(function(){this.ariaDisabled=!1}),i.isDisabled=!1,i.page=e.data(a,"pagerLastPage")||i.page||0,o=(n=i.$container.find(i.cssPageSize)).find("option[selected]").val(),i.size=e.data(a,"pagerLastSize")||j(i,o,"get"),i.totalPages="all"===i.size?1:Math.ceil(z(a,i)/i.size),P(a,i.size,i),a.id&&!l.$table.attr("aria-describedby")&&((r=(n=i.$container.find(i.cssPageDisplay)).attr("id"))||(r=a.id+"_pager_info",n.attr("id",r)),l.$table.attr("aria-describedby",r)),g(a,i),s&&(t.update(l),P(a,i.size,i),R(a,i),d(a,i),t.debug(l,"pager")&&console.log("Pager >> Enabled"))},A=function(s,r){var n,l,p,f,u=s.config,h=u.widgetOptions,z=t.debug(u,"pager"),x=u.pager=e.extend(!0,{},e.tablesorterPager.defaults,r),S=u.$table,A=u.namespace+"pager",F=x.$container=e(x.container).addClass("tablesorter-pager").show();x.settings=e.extend(!0,{},e.tablesorterPager.defaults,r),z&&console.log("Pager >> Initializing"),x.oldAjaxSuccess=x.oldAjaxSuccess||x.ajaxObject.success,u.appender=i.appender,x.initializing=!0,x.savePages&&t.storage&&(n=t.storage(s,x.storageKey)||{},x.page=isNaN(n.page)?x.page:n.page,x.size="all"===n.size?n.size:(isNaN(n.size)?x.size:n.size)||x.setSize||10,P(s,x.size,x)),x.regexRows=new RegExp("("+(h.filter_filteredRow||"filtered")+"|"+u.selectorRemove.slice(1)+"|"+u.cssChildRow+")"),x.regexFiltered=new RegExp(h.filter_filteredRow||"filtered"),S.unbind(a.split(" ").join(A+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(A+" "),function(a,i){x.currentFilters=e.isArray(i)?i:u.$table.data("lastSearch");var r;if(x.ajax&&"filterInit"===a.type)return R(s,x,!1);r=t.filter.equalFilters?t.filter.equalFilters(u,u.lastSearch,x.currentFilters):(u.lastSearch||[]).join("")!==(x.currentFilters||[]).join(""),"filterStart"!==a.type||!1===x.pageReset||r||(x.page=x.pageReset)}).bind("filterEnd sortEnd ".split(" ").join(A+" "),function(){x.currentFilters=u.$table.data("lastSearch"),(x.initialized||x.initializing)&&(u.delayInit&&u.rowsCopy&&0===u.rowsCopy.length&&b(s),o(s,x,!1),R(s,x,!1),t.applyWidget(s))}).bind("disablePager"+A,function(e){e.stopPropagation(),w(s,x)}).bind("enablePager"+A,function(e){e.stopPropagation(),N(s,x,!0)}).bind("destroyPager"+A,function(e){e.stopPropagation(),I(s,x)}).bind("resetToLoadState"+A,function(e){e.stopPropagation(),$(s,x)}).bind("updateComplete"+A,function(e,t,a){if(e.stopPropagation(),t&&!a&&!x.ajax){var i=u.$tbodies.eq(0).children("tr").not(u.selectorRemove);x.totalRows=i.length-(x.countChildRows?0:i.filter("."+u.cssChildRow).length),x.totalPages="all"===x.size?1:Math.ceil(x.totalRows/x.size),i.length&&u.rowsCopy&&0===u.rowsCopy.length&&b(t),x.page>=x.totalPages&&m(t,x),c(t,x),g(t,x),o(t,x,!0)}}).bind("pageSize refreshComplete ".split(" ").join(A+" "),function(e,t){e.stopPropagation(),P(s,j(x,t,"get"),x),R(s,x),c(s,x),o(s,x,!1)}).bind("pageSet pagerUpdate ".split(" ").join(A+" "),function(e,t){e.stopPropagation(),"pagerUpdate"===e.type&&(t=void 0===t?x.page+1:t,x.last.page=!0),x.page=(parseInt(t,10)||1)-1,R(s,x,!0),o(s,x,!1)}).bind("pageAndSize"+A,function(e,t,a){e.stopPropagation(),x.page=(parseInt(t,10)||1)-1,P(s,j(x,a,"get"),x),R(s,x,!0),c(s,x),o(s,x,!1)}),l=[x.cssFirst,x.cssPrev,x.cssNext,x.cssLast],p=[v,C,y,m],z&&!F.length&&console.warn('Pager >> "container" not found'),F.find(l.join(",")).attr("tabindex",0).unbind("click"+A).bind("click"+A,function(t){t.stopPropagation();var a,i=e(this),r=l.length;if(!i.hasClass(x.cssDisabled))for(a=0;a> "goto" selector not found'),(f=F.find(x.cssPageSize)).length?(f.find("option").removeAttr("selected"),f.unbind("change"+A).bind("change"+A,function(){if(!e(this).hasClass(x.cssDisabled)){var t=e(this).val();P(s,t,x),R(s,x),g(s,x)}return!1})):z&&console.warn('Pager >> "size" selector not found'),x.initialized=!1,S.triggerHandler("pagerBeforeInitialized",x),N(s,x,!1),"string"==typeof x.ajaxUrl?(x.ajax=!0,u.widgetOptions.filter_serversideFiltering=!0,u.serverSideSorting=!0,R(s,x)):(x.ajax=!1,t.appendCache(u,!0),d(s,x)),x.ajax||x.initialized||(x.initializing=!1,x.initialized=!0,P(s,x.size,x),R(s,x),z&&console.log("Pager >> Triggering pagerInitialized"),u.$table.triggerHandler("pagerInitialized",x),u.widgetOptions.filter_initialized&&t.hasWidget(s,"filter")||o(s,x,!1)),u.widgetInit.pager=!0};i.appender=function(t,a){var i=t.config,s=i.pager;s.ajax||(i.rowsCopy=a,s.totalRows=s.countChildRows?i.$tbodies.eq(0).children("tr").length:a.length,s.size=e.data(t,"pagerLastSize")||s.size||s.settings.size||10,s.totalPages="all"===s.size?1:Math.ceil(s.totalRows/s.size),h(t,a,s),o(t,s,!1))},i.construct=function(e){return this.each(function(){this.config&&this.hasInitialized&&A(this,e)})}}}),t.showError=function(t,a,i,s){var r=e(t),o=r[0].config,n=o&&o.widgetOptions,l=o.pager&&o.pager.cssErrorRow||n&&n.pager_css&&n.pager_css.errorRow||"tablesorter-errorRow",g=typeof a,c=!0,d="",p=function(){o.$table.find("thead").find(o.selectorRemove).remove()};if(r.length){if("function"==typeof o.pager.ajaxError){if(!1===(c=o.pager.ajaxError(o,a,i,s)))return p();d=c}else if("function"==typeof n.pager_ajaxError){if(!1===(c=n.pager_ajaxError(o,a,i,s)))return p();d=c}if(""===d)if("object"===g)d=0===a.status?"Not connected, verify Network":404===a.status?"Requested page not found [404]":500===a.status?"Internal Server Error [500]":"parsererror"===s?"Requested JSON parse failed":"timeout"===s?"Time out error":"abort"===s?"Ajax Request aborted":"Uncaught error: "+a.statusText+" ["+a.status+"]";else{if("string"!==g)return p();d=a}e(/tr\>/.test(d)?d:''+d+"").click(function(){e(this).remove()}).appendTo(o.$table.find("thead:first")).addClass(l+" "+o.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})}else console.error("tablesorter showError: no table parameter passed")},e.fn.extend({tablesorterPager:e.tablesorterPager.construct})}(jQuery);