/* tablesorter pager plugin updated 11/3/2014 (v2.18.1) */ ;(function(h){var k=h.tablesorter;h.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(c,a){return a},ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(c){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 w=this,u=function(c,a){var b=c.cssDisabled,e=!!a,f=e||0===c.page,g=Math.min(c.totalPages,c.filteredPages),e=e||c.page===g-1||0===g;c.updateArrows&&(c.$container.find(c.cssFirst+","+c.cssPrev)[f?"addClass":"removeClass"](b).attr("aria-disabled", f),c.$container.find(c.cssNext+","+c.cssLast)[e?"addClass":"removeClass"](b).attr("aria-disabled",e))},p=function(c,a){var b=c.config,e=b.$table.hasClass("hasFilters");e&&!a.ajaxUrl?h.isEmptyObject(b.cache)?a.filteredRows=a.totalRows=b.$tbodies.eq(0).children("tr").not(a.countChildRows?"":"."+b.cssChildRow).length:(a.filteredRows=0,h.each(b.cache[0].normalized,function(c,e){a.filteredRows+=a.regexRows.test(e[b.columns].$row[0].className)?0:1})):e||(a.filteredRows=a.totalRows)},s=function(c,a,b){if(!a.initializing){var e, f,g,l=c.config;e=a.size||10;a.countChildRows&&f.push(l.cssChildRow);a.totalPages=Math.ceil(a.totalRows/e);l.totalRows=a.totalRows;p(c,a);l.filteredRows=a.filteredRows;a.filteredPages=Math.ceil(a.filteredRows/e)||0;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)),g=a.$container.find(a.cssPageDisplay),e=(a.ajaxData&&a.ajaxData.output?a.ajaxData.output|| a.output:a.output).replace(/\{page([\-+]\d+)?\}/gi,function(d,b){return a.totalPages?a.page+(b?parseInt(b,10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(d){var b,c;b=d.replace(/[{}\s]/g,"");d=b.split(":");c=a.ajaxData;var e=/(rows?|pages?)$/i.test(b)?0:"";return/(startRow|page)/.test(d[0])&&"input"===d[1]?(b=(""+("page"===d[0]?a.totalPages:a.totalRows)).length,c="page"===d[0]?a.page+1:a.startRow,''):1'+b+""}),a.$goto.html(f).val(a.page+1)),g.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;l.$table.trigger("pageSet.pager",[b])})));u(a);C(c,a);a.initialized&&!1!==b&&(l.$table.trigger("pagerComplete",a),a.savePages&& k.storage&&k.storage(c,a.storageKey,{page:a.page,size:a.size}))}},H=function(c){var a,b,e,f,g;g=Math.min(c.totalPages,c.filteredPages)||1;var l=5*Math.ceil(g/c.maxOptionSize/5);e=g>c.maxOptionSize;f=c.page+1;a=l;b=g-l;var d=[1];for(a=e?l:1;a<=g;)d.push(a),a+=e?l:1;d.push(g);if(e){e=[];b=Math.max(Math.floor(c.maxOptionSize/l)-1,5);a=f-b;1>a&&(a=1);b=f+b;for(b>g&&(b=g);a<=b;a++)e.push(a);d=h.grep(d,function(a,b){return h.inArray(a,d)===b});f=d.length;g=e.length;f-g>l/2&&f+g>c.maxOptionSize&&(c=Math.floor(f/ 2)-Math.floor(g/2),Array.prototype.splice.apply(d,[c,g]));d=d.concat(e)}return d=h.grep(d,function(a,b){return h.inArray(a,d)===b}).sort(function(a,b){return a-b})},C=function(c,a){var b,e=c.config,f=e.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove();a.fixedHeight&&!a.isDisabled&&(b=h.data(c,"pagerSavedHeight"))&&(b-=f.height(),5'))},x=function(c,a){var b;b=c.config;var e=b.$tbodies.eq(0);e.find("tr.pagerSavedHeightSpacer").remove();e.children("tr:visible").length||e.append(' ');b=e.children("tr").eq(0).height()*a.size;h.data(c,"pagerSavedHeight",b);C(c,a);h.data(c,"pagerLastSize",a.size)},v=function(c,a){if(!a.ajaxUrl){var b,e=0,f=c.config,g=f.$tbodies.eq(0).children("tr"),h=g.length,d=a.page*a.size,m=d+a.size,t=f.widgetOptions&& f.widgetOptions.filter_filteredRow||"filtered",r=0;for(b=0;b=d&&r";for(f=0;f"+e[g][f]+"";n+=""}b.processAjaxOnInit&&q.$tbodies.eq(0).html(n)}b.processAjaxOnInit=!0;t&&t.length===c&&(m=(l=p.hasClass("hasStickyHeaders"))? q.widgetOptions.$sticky.children("thead:first").children("tr").children():"",d=p.find("tfoot tr:first").children(),q.$headers.filter("th").each(function(a){var b=h(this),c;b.find("."+k.css.icon).length?(c=b.find("."+k.css.icon).clone(!0),b.find(".tablesorter-header-inner").html(t[a]).append(c),l&&m.length&&(c=m.eq(a).find("."+k.css.icon).clone(!0),m.eq(a).find(".tablesorter-header-inner").html(t[a]).append(c))):(b.find(".tablesorter-header-inner").html(t[a]),l&&m.length&&m.eq(a).find(".tablesorter-header-inner").html(t[a])); d.eq(a).html(t[a])}))}q.showProcessing&&k.isProcessing(a);b.totalPages=Math.ceil(b.totalRows/(b.size||10));b.last.totalRows=b.totalRows;b.last.currentFilters=b.currentFilters;b.last.sortList=(q.sortList||[]).join(",");s(a,b,!0);p.trigger("updateCache",[function(){b.initialized&&setTimeout(function(){p.trigger("applyWidgets").trigger("pagerChange",b)},0)}])}b.initialized||(b.initialized=!0,b.initializing=!1,h(a).trigger("applyWidgets").trigger("pagerInitialized",b),s(a,b))},J=function(c,a){var b=I(c, a),e=h(document),f,g=c.config;""!==b&&(g.showProcessing&&k.isProcessing(c,!0),e.bind("ajaxError.pager",function(b,d,f,g){E(null,c,a,d,g);e.unbind("ajaxError.pager")}),f=++a.ajaxCounter,a.last.ajaxUrl=b,a.ajaxObject.url=b,a.ajaxObject.success=function(b,d,g){f(a&&a.length||0))e.debug&&k.log("Pager: no rows for pager to render");else{b.page>=b.totalPages&&y(c,b);b.isDisabled=!1;b.initialized&&d.trigger("pagerChange",b);if(b.removeRows){k.clearTableBody(c);e=k.processTbody(c,e.$tbodies.eq(0), !0);f=m?0:p;g=m?0:p;for(l=0;lp&&l<=r&&(l++,e.append(a[f]))),f++;k.processTbody(c,e,!1)}else v(c,b);s(c,b);c.isUpdating&&d.trigger("updateComplete",[c,!0])}},F=function(c,a){a.ajax?u(a,!0):(a.isDisabled=!0,h.data(c,"pagerLastPage",a.page),h.data(c,"pagerLastSize",a.size),a.page=0,a.size=a.totalRows,a.totalPages=1,h(c).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),z(c,c.config.rowsCopy, a),h(c).trigger("applyWidgets"),c.config.debug&&k.log("pager disabled"));a.$size.add(a.$goto).add(a.$container.find(".ts-startRow, .ts-page")).each(function(){h(this).attr("aria-disabled","true").addClass(a.cssDisabled)[0].disabled=!0})},A=function(c){var a=c.config,b=a.pager;a.$table.trigger("updateCache",[function(){var e,f=[],g=c.config.cache[0].normalized;b.totalRows=g.length;for(e=0;ea.page&&(a.page=0),a.page>e-1&&0!==e&&(a.page=e-1),l.currentFilters=""===(l.currentFilters||[]).join("")?[]:l.currentFilters,a.currentFilters=""===(a.currentFilters||[]).join("")?[]:a.currentFilters,l.page!==a.page||l.size!==a.size||l.totalRows!==a.totalRows||(l.currentFilters||[]).join(",")!== (a.currentFilters||[]).join(",")||(l.ajaxUrl||"")!==(a.ajaxObject.url||"")||(l.optAjaxUrl||"")!==(a.ajaxUrl||"")||l.sortList!==(f.sortList||[]).join(","))f.debug&&k.log("Pager changing to page "+a.page),a.last={page:a.page,size:a.size,sortList:(f.sortList||[]).join(","),totalRows:a.totalRows,currentFilters:a.currentFilters||[],ajaxUrl:a.ajaxObject.url||"",optAjaxUrl:a.ajaxUrl||""},a.ajax?J(c,a):a.ajax||z(c,f.rowsCopy,a),h.data(c,"pagerLastPage",a.page),a.initialized&&!1!==b&&(g.trigger("pageMoved", a).trigger("applyWidgets"),c.isUpdating&&g.trigger("updateComplete",[c,!0]))}},B=function(c,a,b){b.size=a||b.size||10;b.$size.val(b.size);h.data(c,"pagerLastPage",b.page);h.data(c,"pagerLastSize",b.size);b.totalPages=Math.ceil(b.totalRows/b.size);b.filteredPages=Math.ceil(b.filteredRows/b.size);n(c,b)},K=function(c,a){a.page=0;n(c,a)},y=function(c,a){a.page=Math.min(a.totalPages,a.filteredPages)-1;n(c,a)},L=function(c,a){a.page++;a.page>=Math.min(a.totalPages,a.filteredPages)-1&&(a.page=Math.min(a.totalPages, a.filteredPages)-1);n(c,a)},M=function(c,a){a.page--;0>=a.page&&(a.page=0);n(c,a)},G=function(c,a,b){var e,f=c.config;a.$size.add(a.$goto).add(a.$container.find(".ts-startRow, .ts-page")).removeClass(a.cssDisabled).removeAttr("disabled").attr("aria-disabled","false");a.isDisabled=!1;a.page=h.data(c,"pagerLastPage")||a.page||0;a.size=h.data(c,"pagerLastSize")||parseInt(a.$size.find("option[selected]").val(),10)||a.size||10;a.$size.val(a.size);a.totalPages=Math.ceil(Math.min(a.totalRows,a.filteredRows)/ a.size);c.id&&(e=c.id+"_pager_info",a.$container.find(a.cssPageDisplay).attr("id",e),f.$table.attr("aria-describedby",e));x(c,a);b&&(f.$table.trigger("updateRows"),B(c,a.size,a),D(c,a),f.debug&&k.log("pager enabled"))};w.appender=function(c,a){var b=c.config,e=b.pager;e.ajax||(b.rowsCopy=a,e.totalRows=e.countChildRows?b.$tbodies.eq(0).children("tr").length:a.length,e.size=h.data(c,"pagerLastSize")||e.size||10,e.totalPages=Math.ceil(e.totalRows/e.size),z(c,a,e),s(c,e,!1))};w.construct=function(c){return this.each(function(){if(this.config&& this.hasInitialized){var a,b,e,f=this,g=f.config,l=g.widgetOptions,d=g.pager=h.extend(!0,{},h.tablesorterPager.defaults,c),m=g.$table,p=d.$container=h(d.container).addClass("tablesorter-pager").show();g.debug&&k.log("Pager initializing");d.oldAjaxSuccess=d.oldAjaxSuccess||d.ajaxObject.success;g.appender=w.appender;d.initializing=!0;d.savePages&&k.storage&&(a=k.storage(f,d.storageKey)||{},d.page=isNaN(a.page)?d.page:a.page,d.size=(isNaN(a.size)?d.size:a.size)||10,h.data(f,"pagerLastSize",d.size)); d.regexRows=new RegExp("("+(l.filter_filteredRow||"filtered")+"|"+g.selectorRemove.slice(1)+"|"+g.cssChildRow+")");m.unbind("filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet ".split(" ").join(".pager ")).bind("filterInit.pager filterStart.pager",function(){d.currentFilters=g.$table.data("lastSearch");!1!==d.pageReset&&(g.lastCombinedFilter||"")!==(d.currentFilters||[]).join("")&&(d.page=d.pageReset)}).bind("filterEnd.pager sortEnd.pager",function(){d.currentFilters= g.$table.data("lastSearch");if(d.initialized||d.initializing)g.delayInit&&g.rowsCopy&&0===g.rowsCopy.length&&A(f),n(f,d,!1),g.$table.trigger("applyWidgets"),s(f,d,!1)}).bind("disable.pager",function(a){a.stopPropagation();F(f,d)}).bind("enable.pager",function(a){a.stopPropagation();G(f,d,!0)}).bind("destroy.pager",function(a){a.stopPropagation();F(f,d);d.$container.hide();f.config.appender=null;d.initialized=!1;delete f.config.rowsCopy;h(f).unbind("filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet ".split(" ").join(".pager ")); k.storage&&k.storage(f,d.storageKey,"")}).bind("updateComplete.pager",function(a,b,c){a.stopPropagation();b&&!c&&(a=g.$tbodies.eq(0).children("tr").not(g.selectorRemove),d.totalRows=a.length-(d.countChildRows?0:a.filter("."+g.cssChildRow).length),d.totalPages=Math.ceil(d.totalRows/d.size),a.length&&g.rowsCopy&&0===g.rowsCopy.length&&A(b),d.page>=d.totalPages&&y(b,d),v(b,d),x(b,d),s(b,d,!0))}).bind("pageSize.pager",function(a,b){a.stopPropagation();B(f,parseInt(b,10)||10,d);v(f,d);s(f,d,!1);d.$size.length&& d.$size.val(d.size)}).bind("pageSet.pager",function(a,b){a.stopPropagation();d.page=(parseInt(b,10)||1)-1;d.$goto.length&&d.$goto.val(d.size);n(f,d,!0);s(f,d,!1)});b=[d.cssFirst,d.cssPrev,d.cssNext,d.cssLast];e=[K,M,L,y];p.find(b.join(",")).attr("tabindex",0).unbind("click.pager").bind("click.pager",function(a){a.stopPropagation();var c=h(this),g=b.length;if(!c.hasClass(d.cssDisabled))for(a=0;a/.test(u)?h(u):h(''+u+"")).click(function(){h(this).remove()}).appendTo(k.$table.find("thead:first")).addClass(s+" "+k.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"}))})};h.fn.extend({tablesorterPager:h.tablesorterPager.construct})})(jQuery);