diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 1c1bd325..a50a5f5a 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -126,13 +126,13 @@ $this = this, // hide arrows at extremes - pagerArrows = function(p, disable) { + pagerArrows = function( table, p, disable ) { var a = 'addClass', r = 'removeClass', d = p.cssDisabled, dis = !!disable, first = ( dis || p.page === 0 ), - tp = Math.min( p.totalPages, p.filteredPages ), + tp = getTotalPages( table, p ), last = ( dis || (p.page === tp - 1) || tp === 0 ); if ( p.updateArrows ) { p.$container.find(p.cssFirst + ',' + p.cssPrev)[ first ? a : r ](d).attr('aria-disabled', first); @@ -174,7 +174,7 @@ calcFilters(table, p); c.filteredRows = p.filteredRows; p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0; - if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) { + if ( getTotalPages( table, p ) >= 0 ) { t = (p.size * p.page > p.filteredRows) && completed; p.page = (t) ? p.pageReset || 0 : p.page; p.startRow = (t) ? p.size * p.page + 1 : (p.filteredRows === 0 ? 0 : p.size * p.page + 1); @@ -203,7 +203,7 @@ }); if ( p.$goto.length ) { t = ''; - options = buildPageSelect(p); + options = buildPageSelect( table, p ); len = options.length; for (indx = 0; indx < len; indx++) { t += ''; @@ -221,7 +221,7 @@ }); } } - pagerArrows(p); + pagerArrows( table, p ); fixHeight(table, p); if (p.initialized && completed !== false) { if (c.debug) { @@ -238,11 +238,11 @@ } }, - buildPageSelect = function(p) { + buildPageSelect = function( table, p ) { // Filter the options page number link array if it's larger than 'maxOptionSize' // as large page set links will slow the browser on large dom inserts var i, central_focus_size, focus_option_pages, insert_index, option_length, focus_length, - pg = Math.min( p.totalPages, p.filteredPages ) || 1, + pg = getTotalPages( table, p ) || 1, // make skip set size multiples of 5 skip_set_size = Math.ceil( ( pg / p.maxOptionSize ) / 5 ) * 5, large_collection = pg > p.maxOptionSize, @@ -373,7 +373,7 @@ p.size = parsePageSize( p, p.$size.val(), 'get' ); p.$size.val( parsePageSize( p, p.size, 'set' ) ); $.data(table, 'pagerLastSize', p.size); - pagerArrows(p); + pagerArrows( table, p ); if ( !p.removeRows ) { hideRows(table, p); $(table).bind('sortEnd filterEnd '.split(' ').join(table.config.namespace + 'pager '), function(){ @@ -661,7 +661,7 @@ showAllRows = function(table, p) { var index, $controls, len; if ( p.ajax ) { - pagerArrows(p, true); + pagerArrows( table, p, true ); } else { $.data(table, 'pagerLastPage', p.page); $.data(table, 'pagerLastSize', p.size); @@ -719,7 +719,6 @@ } // abort page move if the table has filters and has not been initialized if (p.ajax && ts.hasWidget(table, 'filter') && !c.widgetOptions.filter_initialized) { return; } - parsePageNumber( table, p ); calcFilters(table, p); // fixes issue where one currentFilter is [] and the other is ['','',''], @@ -768,22 +767,26 @@ } }, + getTotalPages = function( table, p ) { + return ts.hasWidget( table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages; + }, + // set to either set or get value parsePageSize = function( p, size, mode ) { var s = parseInt( size, 10 ) || p.size || p.settings.size || 10, // if select does not contain an "all" option, use size setAll = p.$size.find( 'option[value="all"]' ).length ? 'all' : p.totalRows; return /all/i.test( size ) || s === p.totalRows ? - // "get" to set `p.size` or "set" to set `p.$size.val()` + // "get" to get `p.size` or "set" to set `p.$size.val()` ( mode === 'get' ? p.totalRows : setAll ) : ( mode === 'get' ? s : p.size ); }, parsePageNumber = function( table, p ) { - var min = ( ts.hasWidget( table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages ) - 1; + var min = getTotalPages( table, p ) - 1; p.page = parseInt( p.page, 10 ); if ( p.page < 0 || isNaN( p.page ) ) { p.page = 0; } - if ( p.page > min && p.page !== 0 ) { p.page = min; } + if ( p.page > min && min !== 0 ) { p.page = min; } return p.page; }, @@ -803,14 +806,15 @@ }, moveToLastPage = function(table, p) { - p.page = ( Math.min( p.totalPages, p.filteredPages ) - 1 ); + p.page = getTotalPages( table, p ) - 1; moveToPage(table, p); }, moveToNextPage = function(table, p) { p.page++; - if ( p.page >= ( Math.min( p.totalPages, p.filteredPages ) - 1 ) ) { - p.page = ( Math.min( p.totalPages, p.filteredPages ) - 1 ); + var last = getTotalPages( table, p ) - 1; + if ( p.page >= last ) { + p.page = last; } moveToPage(table, p); }, @@ -855,7 +859,7 @@ size = p.$size.find('option[selected]').val(); p.size = $.data(table, 'pagerLastSize') || parsePageSize( p, p.size, 'get' ); p.$size.val( parsePageSize( p, p.size, 'set' ) ); // set page size - p.totalPages = Math.ceil( Math.min( p.totalRows, p.filteredRows ) / p.size ); + p.totalPages = Math.ceil( getTotalPages( table, p ) / p.size ); // if table id exists, include page display with aria info if ( table.id ) { info = table.id + '_pager_info'; diff --git a/dist/js/extras/jquery.tablesorter.pager.min.js b/dist/js/extras/jquery.tablesorter.pager.min.js index 2d5ca9ce..356cdf00 100644 --- a/dist/js/extras/jquery.tablesorter.pager.min.js +++ b/dist/js/extras/jquery.tablesorter.pager.min.js @@ -2,4 +2,4 @@ * tablesorter (FORK) pager plugin * updated 11/10/2015 (v2.24.5) */ -!function(a){"use strict";var b=a.tablesorter;a.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(a,b){return b},ajaxError:null,ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(a){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 c="filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete pageSize pageSet pageAndSize pagerUpdate refreshComplete ",d=this,e=function(a,b){var c="addClass",d="removeClass",e=a.cssDisabled,f=!!b,g=f||0===a.page,h=Math.min(a.totalPages,a.filteredPages),i=f||a.page===h-1||0===h;a.updateArrows&&(a.$container.find(a.cssFirst+","+a.cssPrev)[g?c:d](e).attr("aria-disabled",g),a.$container.find(a.cssNext+","+a.cssLast)[i?c:d](e).attr("aria-disabled",i))},f=function(a,c){var d,e,f,g=a.config,h=g.$table.hasClass("hasFilters");if(h&&!c.ajaxUrl)if(b.isEmptyObject(g.cache))c.filteredRows=c.totalRows=g.$tbodies.eq(0).children("tr").not(c.countChildRows?"":"."+g.cssChildRow).length;else for(c.filteredRows=0,d=g.cache[0].normalized,f=d.length,e=0;f>e;e++)c.filteredRows+=c.regexRows.test(d[e][g.columns].$row[0].className)?0:1;else h||(c.filteredRows=c.totalRows)},g=function(c,d,g){if(!d.initializing){var j,k,l,m,n,o,p=c.config,q=p.namespace+"pager",r=t(d,d.size,"get");if(d.countChildRows&&k.push(p.cssChildRow),d.totalPages=Math.ceil(d.totalRows/r),p.totalRows=d.totalRows,u(c,d),f(c,d),p.filteredRows=d.filteredRows,d.filteredPages=Math.ceil(d.filteredRows/r)||0,Math.min(d.totalPages,d.filteredPages)>=0){if(k=d.size*d.page>d.filteredRows&&g,d.page=k?d.pageReset||0:d.page,d.startRow=k?d.size*d.page+1:0===d.filteredRows?0:d.size*d.page+1,d.endRow=Math.min(d.filteredRows,d.totalRows,d.size*(d.page+1)),l=d.$container.find(d.cssPageDisplay),j=(d.ajaxData&&d.ajaxData.output?d.ajaxData.output||d.output:d.output).replace(/\{page([\-+]\d+)?\}/gi,function(a,b){return d.totalPages?d.page+(b?parseInt(b,10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(a){var b,c,e=a.replace(/[{}\s]/g,""),f=e.split(":"),g=d.ajaxData,h=/(rows?|pages?)$/i.test(e)?0:"";return/(startRow|page)/.test(f[0])&&"input"===f[1]?(b=(""+("page"===f[0]?d.totalPages:d.totalRows)).length,c="page"===f[0]?d.page+1:d.startRow,''):f.length>1&&g&&g[f[0]]?g[f[0]][f[1]]:d[e]||(g?g[e]:h)||h}),d.$goto.length){for(k="",o=h(d),n=o.length,m=0;n>m;m++)k+='";d.$goto.html(k).val(d.page+1)}l.length&&(l["INPUT"===l[0].nodeName?"val":"html"](j),l.find(".ts-startRow, .ts-page").unbind("change"+q).bind("change"+q,function(){var b=a(this).val(),c=a(this).hasClass("ts-startRow")?Math.floor(b/d.size)+1:b;p.$table.trigger("pageSet"+q,[c])}))}e(d),i(c,d),d.initialized&&g!==!1&&(p.debug&&console.log("Pager: Triggering pagerComplete"),p.$table.trigger("pagerComplete",d),d.savePages&&b.storage&&b.storage(c,d.storageKey,{page:d.page,size:d.size}))}},h=function(b){var c,d,e,f,g,h,i=Math.min(b.totalPages,b.filteredPages)||1,j=5*Math.ceil(i/b.maxOptionSize/5),k=i>b.maxOptionSize,l=b.page+1,m=j,n=i-j,o=[1],p=k?j:1;for(c=p;i>=c;)o.push(c),c+=k?j:1;if(o.push(i),k){for(e=[],d=Math.max(Math.floor(b.maxOptionSize/j)-1,5),m=l-d,1>m&&(m=1),n=l+d,n>i&&(n=i),c=m;n>=c;c++)e.push(c);o=a.grep(o,function(b,c){return a.inArray(b,o)===c}),g=o.length,h=e.length,g-h>j/2&&g+h>b.maxOptionSize&&(f=Math.floor(g/2)-Math.floor(h/2),Array.prototype.splice.apply(o,[f,h])),o=o.concat(e)}return o=a.grep(o,function(b,c){return a.inArray(b,o)===c}).sort(function(a,b){return a-b})},i=function(b,c){var d,e,f=b.config,g=f.$tbodies.eq(0);g.find("tr.pagerSavedHeightSpacer").remove(),c.fixedHeight&&!c.isDisabled&&(e=a.data(b,"pagerSavedHeight"),e&&(d=e-g.height(),d>5&&a.data(b,"pagerLastSize")===c.size&&g.children("tr:visible").length')))},j=function(b,c){var d,e=b.config,f=e.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove(),f.children("tr:visible").length||f.append(' '),d=f.children("tr").eq(0).height()*c.size,a.data(b,"pagerSavedHeight",d),i(b,c),a.data(b,"pagerLastSize",c.size)},k=function(a,c){if(!c.ajaxUrl){var d,e=0,f=a.config,g=f.$tbodies.eq(0).children("tr"),h=g.length,i=c.page*c.size,j=i+c.size,k=f.widgetOptions&&f.widgetOptions.filter_filteredRow||"filtered",l=0,m=0;for(c.cacheIndex=[],d=0;h>d;d++)g[d].className.match(k)||(m===i&&g[d].className.match(f.cssChildRow)?g[d].style.display="none":(g[d].style.display=m>=i&&j>m?"":"none",l!==m&&m>=i&&j>m&&(c.cacheIndex.push(d),l=m),m+=g[d].className.match(f.cssChildRow+"|"+f.selectorRemove.slice(1))&&!c.countChildRows?0:1,m===j&&"none"!==g[d].style.display&&g[d].className.match(b.css.cssHasChild)&&(e=d)));if(e>0&&g[e].className.match(b.css.cssHasChild))for(;++e> Ajax Error",f,h,i),b.showError(d,f,h,i),y.$tbodies.eq(0).children("tr").detach(),e.totalRows=0;else{if(a.isArray(B)?(l=isNaN(B[0])&&!isNaN(B[1]),w=B[l?1:0],e.totalRows=isNaN(w)?e.totalRows||0:w,y.totalRows=y.filteredRows=e.filteredRows=e.totalRows,u=0===e.totalRows?[]:B[l?0:1]||[],s=B[2]):(e.ajaxData=B,y.totalRows=e.totalRows=B.total,y.filteredRows=e.filteredRows="undefined"!=typeof B.filteredRows?B.filteredRows:B.total,s=B.headers,u=B.rows||[]),v=u&&u.length,u instanceof jQuery)e.processAjaxOnInit&&(y.$tbodies.eq(0).empty(),y.$tbodies.eq(0).append(u));else if(v){for(j=0;v>j;j++){for(A+="",k=0;k"+u[j][k]+"";A+=""}e.processAjaxOnInit&&y.$tbodies.eq(0).html(A)}if(e.processAjaxOnInit=!0,s&&s.length===C)for(m=z.hasClass("hasStickyHeaders"),o=m?y.widgetOptions.$sticky.children("thead:first").children("tr").children():"",n=z.find("tfoot tr:first").children(),p=y.$headers.filter("th "),x=p.length,k=0;x>k;k++)q=p.eq(k),q.find("."+b.css.icon).length?(r=q.find("."+b.css.icon).clone(!0),q.find(".tablesorter-header-inner").html(s[k]).append(r),m&&o.length&&(r=o.eq(k).find("."+b.css.icon).clone(!0),o.eq(k).find(".tablesorter-header-inner").html(s[k]).append(r))):(q.find(".tablesorter-header-inner").html(s[k]),m&&o.length&&o.eq(k).find(".tablesorter-header-inner").html(s[k])),n.eq(k).html(s[k])}y.showProcessing&&b.isProcessing(d),e.totalPages=Math.ceil(e.totalRows/t(e,e.size,"get")),e.last.totalRows=e.totalRows,e.last.currentFilters=e.currentFilters,e.last.sortList=(y.sortList||[]).join(","),g(d,e,!1),b.updateCache(y,function(){e.initialized&&setTimeout(function(){y.debug&&console.log("Pager: Triggering pagerChange"),z.trigger("pagerChange",e),b.applyWidget(d),g(d,e,!0)},0)})}e.initialized||(e.initialized=!0,e.initializing=!1,d.config.debug&&console.log("Pager: Triggering pagerInitialized"),a(d).trigger("pagerInitialized",e),b.applyWidget(d),g(d,e))},n=function(c,d){var e,f=o(c,d),g=a(document),h=c.config,i=h.namespace+"pager";""!==f&&(h.showProcessing&&b.isProcessing(c,!0),g.bind("ajaxError"+i,function(a,b,e,f){m(null,c,d,b,e,f),g.unbind("ajaxError"+i)}),e=++d.ajaxCounter,d.last.ajaxUrl=f,d.ajaxObject.url=f,d.ajaxObject.success=function(a,b,f){ed;d++)l.push(j+"["+h[d][0]+"]="+h[d][1]);g=g.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):j),l=[]}if(k){for(k=k[1],e=i.length,d=0;e>d;d++)i[d]&&l.push(k+"["+d+"]="+encodeURIComponent(i[d]));g=g.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):k),c.currentFilters=i}return"function"==typeof c.customAjaxUrl&&(g=c.customAjaxUrl(b,g)),f.debug&&console.log("Pager: Ajax url = "+g),g},p=function(c,d,e){var f,h,i,j,l=a(c),m=c.config,n=m.$table.hasClass("hasFilters"),o=d&&d.length||0,p=e.page*e.size,q=e.size;if(1>o)return void(m.debug&&console.warn("Pager: >> No rows for pager to render"));if(e.page>=e.totalPages&&x(c,e),e.cacheIndex=[],e.isDisabled=!1,e.initialized&&(m.debug&&console.log("Pager: Triggering pagerChange"),l.trigger("pagerChange",e)),e.removeRows){for(b.clearTableBody(c),f=b.processTbody(c,m.$tbodies.eq(0),!0),h=n?0:p,i=n?0:p,j=0;q>j&&hp&&q>=j&&(j++,e.cacheIndex.push(h),f.append(d[h]))),h++;b.processTbody(c,f,!1)}else k(c,e);g(c,e),c.isUpdating&&(m.debug&&console.log("Pager: Triggering updateComplete"),l.trigger("updateComplete",[c,!0]))},q=function(c,d){var f,g,h;for(d.ajax?e(d,!0):(a.data(c,"pagerLastPage",d.page),a.data(c,"pagerLastSize",d.size),d.page=0,d.size=d.totalRows,d.totalPages=1,a(c).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),p(c,c.config.rowsCopy,d),d.isDisabled=!0,b.applyWidget(c),c.config.debug&&console.log("Pager: Disabled")),g=d.$size.add(d.$goto).add(d.$container.find(".ts-startRow, .ts-page")),h=g.length,f=0;h>f;f++)g.eq(f).attr("aria-disabled","true").addClass(d.cssDisabled)[0].disabled=!0},r=function(a){var c=a.config,d=c.pager;b.updateCache(c,function(){var b,e=[],f=a.config.cache[0].normalized;for(d.totalRows=f.length,b=0;bd&&0!==c.page&&(c.page=d),c.page},v=function(b,c,d){d.size=t(d,c,"get"),d.$size.val(t(d,d.size,"set")),a.data(b,"pagerLastPage",u(b,d)),a.data(b,"pagerLastSize",d.size),d.totalPages=Math.ceil(d.totalRows/d.size),d.filteredPages=Math.ceil(d.filteredRows/d.size),s(b,d)},w=function(a,b){b.page=0,s(a,b)},x=function(a,b){b.page=Math.min(b.totalPages,b.filteredPages)-1,s(a,b)},y=function(a,b){b.page++,b.page>=Math.min(b.totalPages,b.filteredPages)-1&&(b.page=Math.min(b.totalPages,b.filteredPages)-1),s(a,b)},z=function(a,b){b.page--,b.page<=0&&(b.page=0),s(a,b)},A=function(a,c){var d=a.config,e=d.namespace+"pager",f=[c.cssFirst,c.cssPrev,c.cssNext,c.cssLast,c.cssGoto,c.cssPageSize].join(",");q(a,c),c.$container.hide().find(f).unbind(e),d.appender=null,d.$table.unbind(e),b.storage&&b.storage(a,c.storageKey,""),delete d.pager,delete d.rowsCopy},B=function(c,d,e){var f,g,h=c.config;d.$size.add(d.$goto).add(d.$container.find(".ts-startRow, .ts-page")).removeClass(d.cssDisabled).removeAttr("disabled").attr("aria-disabled","false"),d.isDisabled=!1,d.page=a.data(c,"pagerLastPage")||d.page||0,g=d.$size.find("option[selected]").val(),d.size=a.data(c,"pagerLastSize")||t(d,d.size,"get"),d.$size.val(t(d,d.size,"set")),d.totalPages=Math.ceil(Math.min(d.totalRows,d.filteredRows)/d.size),c.id&&(f=c.id+"_pager_info",d.$container.find(d.cssPageDisplay).attr("id",f),h.$table.attr("aria-describedby",f)),j(c,d),e&&(b.update(h),v(c,d.size,d),l(c,d),h.debug&&console.log("Pager: Enabled"))};d.appender=function(b,c){var d=b.config,e=d.pager;e.ajax||(d.rowsCopy=c,e.totalRows=e.countChildRows?d.$tbodies.eq(0).children("tr").length:c.length,e.size=a.data(b,"pagerLastSize")||e.size||e.settings.size||10,e.totalPages=Math.ceil(e.totalRows/e.size),p(b,c,e),g(b,e,!1))},d.construct=function(e){return this.each(function(){if(this.config&&this.hasInitialized){var f,h,i,m=this,n=m.config,o=n.widgetOptions,p=n.pager=a.extend(!0,{},a.tablesorterPager.defaults,e),u=n.$table,C=n.namespace+"pager",D=p.$container=a(p.container).addClass("tablesorter-pager").show();p.settings=a.extend(!0,{},a.tablesorterPager.defaults,e),n.debug&&console.log("Pager: Initializing"),p.oldAjaxSuccess=p.oldAjaxSuccess||p.ajaxObject.success,n.appender=d.appender,p.initializing=!0,p.savePages&&b.storage&&(f=b.storage(m,p.storageKey)||{},p.page=isNaN(f.page)?p.page:f.page,p.size=(isNaN(f.size)?p.size:f.size)||p.settings.size||10,a.data(m,"pagerLastSize",p.size)),p.regexRows=new RegExp("("+(o.filter_filteredRow||"filtered")+"|"+n.selectorRemove.slice(1)+"|"+n.cssChildRow+")"),u.unbind(c.split(" ").join(C+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(C+" "),function(b,c){p.currentFilters=a.isArray(c)?c:n.$table.data("lastSearch"),"filterStart"===b.type&&p.pageReset!==!1&&(n.lastCombinedFilter||"")!==(p.currentFilters||[]).join("")&&(p.page=p.pageReset)}).bind("filterEnd sortEnd ".split(" ").join(C+" "),function(){p.currentFilters=n.$table.data("lastSearch"),(p.initialized||p.initializing)&&(n.delayInit&&n.rowsCopy&&0===n.rowsCopy.length&&r(m),g(m,p,!1),s(m,p,!1),b.applyWidget(m))}).bind("disablePager"+C,function(a){a.stopPropagation(),q(m,p)}).bind("enablePager"+C,function(a){a.stopPropagation(),B(m,p,!0)}).bind("destroyPager"+C,function(a){a.stopPropagation(),A(m,p)}).bind("updateComplete"+C,function(a,b,c){if(a.stopPropagation(),b&&!c&&!p.ajax){var d=n.$tbodies.eq(0).children("tr").not(n.selectorRemove);p.totalRows=d.length-(p.countChildRows?0:d.filter("."+n.cssChildRow).length),p.totalPages=Math.ceil(p.totalRows/p.size),d.length&&n.rowsCopy&&0===n.rowsCopy.length&&r(b),p.page>=p.totalPages&&x(b,p),k(b,p),j(b,p),g(b,p,!0)}}).bind("pageSize refreshComplete ".split(" ").join(C+" "),function(a,b){a.stopPropagation(),v(m,t(p,b,"get"),p),k(m,p),g(m,p,!1)}).bind("pageSet pagerUpdate ".split(" ").join(C+" "),function(a,b){a.stopPropagation(),"pagerUpdate"===a.type&&(b="undefined"==typeof b?p.page+1:b,p.last.page=!0),p.page=(parseInt(b,10)||1)-1,s(m,p,!0),g(m,p,!1)}).bind("pageAndSize"+C,function(a,b,c){a.stopPropagation(),p.page=(parseInt(b,10)||1)-1,v(m,t(p,c,"get"),p),s(m,p,!0),k(m,p),g(m,p,!1)}),h=[p.cssFirst,p.cssPrev,p.cssNext,p.cssLast],i=[w,z,y,x],n.debug&&!D.length&&console.warn("Pager: >> Container not found"),D.find(h.join(",")).attr("tabindex",0).unbind("click"+C).bind("click"+C,function(b){b.stopPropagation();var c,d=a(this),e=h.length;if(!d.hasClass(p.cssDisabled))for(c=0;e>c;c++)if(d.is(h[c])){i[c](m,p);break}}),p.$goto=D.find(p.cssGoto),p.$goto.length?p.$goto.unbind("change"+C).bind("change"+C,function(){p.page=a(this).val()-1,s(m,p,!0),g(m,p,!1)}):n.debug&&console.warn("Pager: >> Goto selector not found"),p.$size=D.find(p.cssPageSize),p.$size.length?(p.$size.find("option").removeAttr("selected"),p.$size.unbind("change"+C).bind("change"+C,function(){if(!a(this).hasClass(p.cssDisabled)){var b=a(this).val();p.$size.val(b),v(m,b,p),j(m,p)}return!1})):n.debug&&console.warn("Pager: >> Size selector not found"),p.initialized=!1,u.trigger("pagerBeforeInitialized",p),B(m,p,!1),"string"==typeof p.ajaxUrl?(p.ajax=!0,n.widgetOptions.filter_serversideFiltering=!0,n.serverSideSorting=!0,s(m,p)):(p.ajax=!1,b.appendCache(n,!0),l(m,p)),p.ajax||p.initialized||(p.initializing=!1,p.initialized=!0,s(m,p),n.debug&&console.log("Pager: Triggering pagerInitialized"),n.$table.trigger("pagerInitialized",p),n.widgetOptions.filter_initialized&&b.hasWidget(m,"filter")||g(m,p,!1)),n.widgetInit.pager=!0}})}}}),b.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:''+m+"").click(function(){a(this).remove()}).appendTo(h.$table.find("thead:first")).addClass(j+" "+h.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})},a.fn.extend({tablesorterPager:a.tablesorterPager.construct})}(jQuery); \ No newline at end of file +!function(a){"use strict";var b=a.tablesorter;a.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(a,b){return b},ajaxError:null,ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(a){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 c="filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete pageSize pageSet pageAndSize pagerUpdate refreshComplete ",d=this,e=function(a,b,c){var d="addClass",e="removeClass",f=b.cssDisabled,g=!!c,h=g||0===b.page,i=t(a,b),j=g||b.page===i-1||0===i;b.updateArrows&&(b.$container.find(b.cssFirst+","+b.cssPrev)[h?d:e](f).attr("aria-disabled",h),b.$container.find(b.cssNext+","+b.cssLast)[j?d:e](f).attr("aria-disabled",j))},f=function(a,c){var d,e,f,g=a.config,h=g.$table.hasClass("hasFilters");if(h&&!c.ajaxUrl)if(b.isEmptyObject(g.cache))c.filteredRows=c.totalRows=g.$tbodies.eq(0).children("tr").not(c.countChildRows?"":"."+g.cssChildRow).length;else for(c.filteredRows=0,d=g.cache[0].normalized,f=d.length,e=0;f>e;e++)c.filteredRows+=c.regexRows.test(d[e][g.columns].$row[0].className)?0:1;else h||(c.filteredRows=c.totalRows)},g=function(c,d,g){if(!d.initializing){var j,k,l,m,n,o,p=c.config,q=p.namespace+"pager",r=u(d,d.size,"get");if(d.countChildRows&&k.push(p.cssChildRow),d.totalPages=Math.ceil(d.totalRows/r),p.totalRows=d.totalRows,v(c,d),f(c,d),p.filteredRows=d.filteredRows,d.filteredPages=Math.ceil(d.filteredRows/r)||0,t(c,d)>=0){if(k=d.size*d.page>d.filteredRows&&g,d.page=k?d.pageReset||0:d.page,d.startRow=k?d.size*d.page+1:0===d.filteredRows?0:d.size*d.page+1,d.endRow=Math.min(d.filteredRows,d.totalRows,d.size*(d.page+1)),l=d.$container.find(d.cssPageDisplay),j=(d.ajaxData&&d.ajaxData.output?d.ajaxData.output||d.output:d.output).replace(/\{page([\-+]\d+)?\}/gi,function(a,b){return d.totalPages?d.page+(b?parseInt(b,10):1):0}).replace(/\{\w+(\s*:\s*\w+)?\}/gi,function(a){var b,c,e=a.replace(/[{}\s]/g,""),f=e.split(":"),g=d.ajaxData,h=/(rows?|pages?)$/i.test(e)?0:"";return/(startRow|page)/.test(f[0])&&"input"===f[1]?(b=(""+("page"===f[0]?d.totalPages:d.totalRows)).length,c="page"===f[0]?d.page+1:d.startRow,''):f.length>1&&g&&g[f[0]]?g[f[0]][f[1]]:d[e]||(g?g[e]:h)||h}),d.$goto.length){for(k="",o=h(c,d),n=o.length,m=0;n>m;m++)k+='";d.$goto.html(k).val(d.page+1)}l.length&&(l["INPUT"===l[0].nodeName?"val":"html"](j),l.find(".ts-startRow, .ts-page").unbind("change"+q).bind("change"+q,function(){var b=a(this).val(),c=a(this).hasClass("ts-startRow")?Math.floor(b/d.size)+1:b;p.$table.trigger("pageSet"+q,[c])}))}e(c,d),i(c,d),d.initialized&&g!==!1&&(p.debug&&console.log("Pager: Triggering pagerComplete"),p.$table.trigger("pagerComplete",d),d.savePages&&b.storage&&b.storage(c,d.storageKey,{page:d.page,size:d.size}))}},h=function(b,c){var d,e,f,g,h,i,j=t(b,c)||1,k=5*Math.ceil(j/c.maxOptionSize/5),l=j>c.maxOptionSize,m=c.page+1,n=k,o=j-k,p=[1],q=l?k:1;for(d=q;j>=d;)p.push(d),d+=l?k:1;if(p.push(j),l){for(f=[],e=Math.max(Math.floor(c.maxOptionSize/k)-1,5),n=m-e,1>n&&(n=1),o=m+e,o>j&&(o=j),d=n;o>=d;d++)f.push(d);p=a.grep(p,function(b,c){return a.inArray(b,p)===c}),h=p.length,i=f.length,h-i>k/2&&h+i>c.maxOptionSize&&(g=Math.floor(h/2)-Math.floor(i/2),Array.prototype.splice.apply(p,[g,i])),p=p.concat(f)}return p=a.grep(p,function(b,c){return a.inArray(b,p)===c}).sort(function(a,b){return a-b})},i=function(b,c){var d,e,f=b.config,g=f.$tbodies.eq(0);g.find("tr.pagerSavedHeightSpacer").remove(),c.fixedHeight&&!c.isDisabled&&(e=a.data(b,"pagerSavedHeight"),e&&(d=e-g.height(),d>5&&a.data(b,"pagerLastSize")===c.size&&g.children("tr:visible").length')))},j=function(b,c){var d,e=b.config,f=e.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove(),f.children("tr:visible").length||f.append(' '),d=f.children("tr").eq(0).height()*c.size,a.data(b,"pagerSavedHeight",d),i(b,c),a.data(b,"pagerLastSize",c.size)},k=function(a,c){if(!c.ajaxUrl){var d,e=0,f=a.config,g=f.$tbodies.eq(0).children("tr"),h=g.length,i=c.page*c.size,j=i+c.size,k=f.widgetOptions&&f.widgetOptions.filter_filteredRow||"filtered",l=0,m=0;for(c.cacheIndex=[],d=0;h>d;d++)g[d].className.match(k)||(m===i&&g[d].className.match(f.cssChildRow)?g[d].style.display="none":(g[d].style.display=m>=i&&j>m?"":"none",l!==m&&m>=i&&j>m&&(c.cacheIndex.push(d),l=m),m+=g[d].className.match(f.cssChildRow+"|"+f.selectorRemove.slice(1))&&!c.countChildRows?0:1,m===j&&"none"!==g[d].style.display&&g[d].className.match(b.css.cssHasChild)&&(e=d)));if(e>0&&g[e].className.match(b.css.cssHasChild))for(;++e> Ajax Error",f,h,i),b.showError(d,f,h,i),y.$tbodies.eq(0).children("tr").detach(),e.totalRows=0;else{if(a.isArray(B)?(l=isNaN(B[0])&&!isNaN(B[1]),w=B[l?1:0],e.totalRows=isNaN(w)?e.totalRows||0:w,y.totalRows=y.filteredRows=e.filteredRows=e.totalRows,t=0===e.totalRows?[]:B[l?0:1]||[],s=B[2]):(e.ajaxData=B,y.totalRows=e.totalRows=B.total,y.filteredRows=e.filteredRows="undefined"!=typeof B.filteredRows?B.filteredRows:B.total,s=B.headers,t=B.rows||[]),v=t&&t.length,t instanceof jQuery)e.processAjaxOnInit&&(y.$tbodies.eq(0).empty(),y.$tbodies.eq(0).append(t));else if(v){for(j=0;v>j;j++){for(A+="",k=0;k"+t[j][k]+"";A+=""}e.processAjaxOnInit&&y.$tbodies.eq(0).html(A)}if(e.processAjaxOnInit=!0,s&&s.length===C)for(m=z.hasClass("hasStickyHeaders"),o=m?y.widgetOptions.$sticky.children("thead:first").children("tr").children():"",n=z.find("tfoot tr:first").children(),p=y.$headers.filter("th "),x=p.length,k=0;x>k;k++)q=p.eq(k),q.find("."+b.css.icon).length?(r=q.find("."+b.css.icon).clone(!0),q.find(".tablesorter-header-inner").html(s[k]).append(r),m&&o.length&&(r=o.eq(k).find("."+b.css.icon).clone(!0),o.eq(k).find(".tablesorter-header-inner").html(s[k]).append(r))):(q.find(".tablesorter-header-inner").html(s[k]),m&&o.length&&o.eq(k).find(".tablesorter-header-inner").html(s[k])),n.eq(k).html(s[k])}y.showProcessing&&b.isProcessing(d),e.totalPages=Math.ceil(e.totalRows/u(e,e.size,"get")),e.last.totalRows=e.totalRows,e.last.currentFilters=e.currentFilters,e.last.sortList=(y.sortList||[]).join(","),g(d,e,!1),b.updateCache(y,function(){e.initialized&&setTimeout(function(){y.debug&&console.log("Pager: Triggering pagerChange"),z.trigger("pagerChange",e),b.applyWidget(d),g(d,e,!0)},0)})}e.initialized||(e.initialized=!0,e.initializing=!1,d.config.debug&&console.log("Pager: Triggering pagerInitialized"),a(d).trigger("pagerInitialized",e),b.applyWidget(d),g(d,e))},n=function(c,d){var e,f=o(c,d),g=a(document),h=c.config,i=h.namespace+"pager";""!==f&&(h.showProcessing&&b.isProcessing(c,!0),g.bind("ajaxError"+i,function(a,b,e,f){m(null,c,d,b,e,f),g.unbind("ajaxError"+i)}),e=++d.ajaxCounter,d.last.ajaxUrl=f,d.ajaxObject.url=f,d.ajaxObject.success=function(a,b,f){ed;d++)l.push(j+"["+h[d][0]+"]="+h[d][1]);g=g.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):j),l=[]}if(k){for(k=k[1],e=i.length,d=0;e>d;d++)i[d]&&l.push(k+"["+d+"]="+encodeURIComponent(i[d]));g=g.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):k),c.currentFilters=i}return"function"==typeof c.customAjaxUrl&&(g=c.customAjaxUrl(b,g)),f.debug&&console.log("Pager: Ajax url = "+g),g},p=function(c,d,e){var f,h,i,j,l=a(c),m=c.config,n=m.$table.hasClass("hasFilters"),o=d&&d.length||0,p=e.page*e.size,q=e.size;if(1>o)return void(m.debug&&console.warn("Pager: >> No rows for pager to render"));if(e.page>=e.totalPages&&y(c,e),e.cacheIndex=[],e.isDisabled=!1,e.initialized&&(m.debug&&console.log("Pager: Triggering pagerChange"),l.trigger("pagerChange",e)),e.removeRows){for(b.clearTableBody(c),f=b.processTbody(c,m.$tbodies.eq(0),!0),h=n?0:p,i=n?0:p,j=0;q>j&&hp&&q>=j&&(j++,e.cacheIndex.push(h),f.append(d[h]))),h++;b.processTbody(c,f,!1)}else k(c,e);g(c,e),c.isUpdating&&(m.debug&&console.log("Pager: Triggering updateComplete"),l.trigger("updateComplete",[c,!0]))},q=function(c,d){var f,g,h;for(d.ajax?e(c,d,!0):(a.data(c,"pagerLastPage",d.page),a.data(c,"pagerLastSize",d.size),d.page=0,d.size=d.totalRows,d.totalPages=1,a(c).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),p(c,c.config.rowsCopy,d),d.isDisabled=!0,b.applyWidget(c),c.config.debug&&console.log("Pager: Disabled")),g=d.$size.add(d.$goto).add(d.$container.find(".ts-startRow, .ts-page")),h=g.length,f=0;h>f;f++)g.eq(f).attr("aria-disabled","true").addClass(d.cssDisabled)[0].disabled=!0},r=function(a){var c=a.config,d=c.pager;b.updateCache(c,function(){var b,e=[],f=a.config.cache[0].normalized;for(d.totalRows=f.length,b=0;bc&&0!==c&&(b.page=c),b.page},w=function(b,c,d){d.size=u(d,c,"get"),d.$size.val(u(d,d.size,"set")),a.data(b,"pagerLastPage",v(b,d)),a.data(b,"pagerLastSize",d.size),d.totalPages=Math.ceil(d.totalRows/d.size),d.filteredPages=Math.ceil(d.filteredRows/d.size),s(b,d)},x=function(a,b){b.page=0,s(a,b)},y=function(a,b){b.page=t(a,b)-1,s(a,b)},z=function(a,b){b.page++;var c=t(a,b)-1;b.page>=c&&(b.page=c),s(a,b)},A=function(a,b){b.page--,b.page<=0&&(b.page=0),s(a,b)},B=function(a,c){var d=a.config,e=d.namespace+"pager",f=[c.cssFirst,c.cssPrev,c.cssNext,c.cssLast,c.cssGoto,c.cssPageSize].join(",");q(a,c),c.$container.hide().find(f).unbind(e),d.appender=null,d.$table.unbind(e),b.storage&&b.storage(a,c.storageKey,""),delete d.pager,delete d.rowsCopy},C=function(c,d,e){var f,g,h=c.config;d.$size.add(d.$goto).add(d.$container.find(".ts-startRow, .ts-page")).removeClass(d.cssDisabled).removeAttr("disabled").attr("aria-disabled","false"),d.isDisabled=!1,d.page=a.data(c,"pagerLastPage")||d.page||0,g=d.$size.find("option[selected]").val(),d.size=a.data(c,"pagerLastSize")||u(d,d.size,"get"),d.$size.val(u(d,d.size,"set")),d.totalPages=Math.ceil(t(c,d)/d.size),c.id&&(f=c.id+"_pager_info",d.$container.find(d.cssPageDisplay).attr("id",f),h.$table.attr("aria-describedby",f)),j(c,d),e&&(b.update(h),w(c,d.size,d),l(c,d),h.debug&&console.log("Pager: Enabled"))};d.appender=function(b,c){var d=b.config,e=d.pager;e.ajax||(d.rowsCopy=c,e.totalRows=e.countChildRows?d.$tbodies.eq(0).children("tr").length:c.length,e.size=a.data(b,"pagerLastSize")||e.size||e.settings.size||10,e.totalPages=Math.ceil(e.totalRows/e.size),p(b,c,e),g(b,e,!1))},d.construct=function(e){return this.each(function(){if(this.config&&this.hasInitialized){var f,h,i,m=this,n=m.config,o=n.widgetOptions,p=n.pager=a.extend(!0,{},a.tablesorterPager.defaults,e),t=n.$table,v=n.namespace+"pager",D=p.$container=a(p.container).addClass("tablesorter-pager").show();p.settings=a.extend(!0,{},a.tablesorterPager.defaults,e),n.debug&&console.log("Pager: Initializing"),p.oldAjaxSuccess=p.oldAjaxSuccess||p.ajaxObject.success,n.appender=d.appender,p.initializing=!0,p.savePages&&b.storage&&(f=b.storage(m,p.storageKey)||{},p.page=isNaN(f.page)?p.page:f.page,p.size=(isNaN(f.size)?p.size:f.size)||p.settings.size||10,a.data(m,"pagerLastSize",p.size)),p.regexRows=new RegExp("("+(o.filter_filteredRow||"filtered")+"|"+n.selectorRemove.slice(1)+"|"+n.cssChildRow+")"),t.unbind(c.split(" ").join(v+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(v+" "),function(b,c){p.currentFilters=a.isArray(c)?c:n.$table.data("lastSearch"),"filterStart"===b.type&&p.pageReset!==!1&&(n.lastCombinedFilter||"")!==(p.currentFilters||[]).join("")&&(p.page=p.pageReset)}).bind("filterEnd sortEnd ".split(" ").join(v+" "),function(){p.currentFilters=n.$table.data("lastSearch"),(p.initialized||p.initializing)&&(n.delayInit&&n.rowsCopy&&0===n.rowsCopy.length&&r(m),g(m,p,!1),s(m,p,!1),b.applyWidget(m))}).bind("disablePager"+v,function(a){a.stopPropagation(),q(m,p)}).bind("enablePager"+v,function(a){a.stopPropagation(),C(m,p,!0)}).bind("destroyPager"+v,function(a){a.stopPropagation(),B(m,p)}).bind("updateComplete"+v,function(a,b,c){if(a.stopPropagation(),b&&!c&&!p.ajax){var d=n.$tbodies.eq(0).children("tr").not(n.selectorRemove);p.totalRows=d.length-(p.countChildRows?0:d.filter("."+n.cssChildRow).length),p.totalPages=Math.ceil(p.totalRows/p.size),d.length&&n.rowsCopy&&0===n.rowsCopy.length&&r(b),p.page>=p.totalPages&&y(b,p),k(b,p),j(b,p),g(b,p,!0)}}).bind("pageSize refreshComplete ".split(" ").join(v+" "),function(a,b){a.stopPropagation(),w(m,u(p,b,"get"),p),k(m,p),g(m,p,!1)}).bind("pageSet pagerUpdate ".split(" ").join(v+" "),function(a,b){a.stopPropagation(),"pagerUpdate"===a.type&&(b="undefined"==typeof b?p.page+1:b,p.last.page=!0),p.page=(parseInt(b,10)||1)-1,s(m,p,!0),g(m,p,!1)}).bind("pageAndSize"+v,function(a,b,c){a.stopPropagation(),p.page=(parseInt(b,10)||1)-1,w(m,u(p,c,"get"),p),s(m,p,!0),k(m,p),g(m,p,!1)}),h=[p.cssFirst,p.cssPrev,p.cssNext,p.cssLast],i=[x,A,z,y],n.debug&&!D.length&&console.warn("Pager: >> Container not found"),D.find(h.join(",")).attr("tabindex",0).unbind("click"+v).bind("click"+v,function(b){b.stopPropagation();var c,d=a(this),e=h.length;if(!d.hasClass(p.cssDisabled))for(c=0;e>c;c++)if(d.is(h[c])){i[c](m,p);break}}),p.$goto=D.find(p.cssGoto),p.$goto.length?p.$goto.unbind("change"+v).bind("change"+v,function(){p.page=a(this).val()-1,s(m,p,!0),g(m,p,!1)}):n.debug&&console.warn("Pager: >> Goto selector not found"),p.$size=D.find(p.cssPageSize),p.$size.length?(p.$size.find("option").removeAttr("selected"),p.$size.unbind("change"+v).bind("change"+v,function(){if(!a(this).hasClass(p.cssDisabled)){var b=a(this).val();p.$size.val(b),w(m,b,p),j(m,p)}return!1})):n.debug&&console.warn("Pager: >> Size selector not found"),p.initialized=!1,t.trigger("pagerBeforeInitialized",p),C(m,p,!1),"string"==typeof p.ajaxUrl?(p.ajax=!0,n.widgetOptions.filter_serversideFiltering=!0,n.serverSideSorting=!0,s(m,p)):(p.ajax=!1,b.appendCache(n,!0),l(m,p)),p.ajax||p.initialized||(p.initializing=!1,p.initialized=!0,s(m,p),n.debug&&console.log("Pager: Triggering pagerInitialized"),n.$table.trigger("pagerInitialized",p),n.widgetOptions.filter_initialized&&b.hasWidget(m,"filter")||g(m,p,!1)),n.widgetInit.pager=!0}})}}}),b.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:''+m+"").click(function(){a(this).remove()}).appendTo(h.$table.find("thead:first")).addClass(j+" "+h.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})},a.fn.extend({tablesorterPager:a.tablesorterPager.construct})}(jQuery); \ No newline at end of file diff --git a/dist/js/widgets/widget-pager.min.js b/dist/js/widgets/widget-pager.min.js index be0f31ae..c417ff1f 100644 --- a/dist/js/widgets/widget-pager.min.js +++ b/dist/js/widgets/widget-pager.min.js @@ -1,2 +1,2 @@ /*! Widget: Pager - updated 11/10/2015 (v2.24.4) */ -!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(a,c.pager,!1):b.initComplete(a,c)},remove:function(a,c,d,e){b.destroyPager(a,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=(isNaN(e.size)?i.size:e.size)||i.setSize||10,a.data(d,"pagerLastSize",i.size)),i.regexRows=new RegExp("("+(g.filter_filteredRow||"filtered")+"|"+f.selectorRemove.slice(1)+"|"+f.cssChildRow+")"),i.initialized=!1,f.$table.trigger("pagerBeforeInitialized",f),b.enablePager(d,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(d,i)):(i.ajax=!1,c.appendCache(f,!0)))}},initComplete:function(a,d){var e=d.pager;b.bindEvents(a,d),b.setPageSize(d,0),e.ajax||b.hideRowsSetup(a,d),e.initialized=!0,e.initializing=!1,e.isInitializing=!1,d.debug&&console.log("Pager: Triggering pagerInitialized"),d.$table.trigger("pagerInitialized",d),d.widgetOptions.filter_initialized&&c.hasWidget(a,"filter")||b.updatePageDisplay(a,d,!e.ajax)},bindEvents:function(d,e){var f,g,h=e.pager,i=e.widgetOptions,j=e.namespace+"pager",k=i.pager_selectors;e.$table.off(j).on("filterInit filterStart ".split(" ").join(j+" "),function(b,c){h.currentFilters=a.isArray(c)?c:e.$table.data("lastSearch"),"filterStart"===b.type&&i.pager_pageReset!==!1&&(e.lastCombinedFilter||"")!==(h.currentFilters||[]).join("")&&(h.page=i.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(j+" "),function(){h.currentFilters=e.$table.data("lastSearch"),(h.initialized||h.initializing)&&(e.delayInit&&e.rowsCopy&&0===e.rowsCopy.length&&b.updateCache(d),b.updatePageDisplay(d,e,!1),c.applyWidget(d))}).on("disablePager"+j,function(a){a.stopPropagation(),b.showAllRows(d,e)}).on("enablePager"+j,function(a){a.stopPropagation(),b.enablePager(d,e,!0)}).on("destroyPager"+j,function(a,b){a.stopPropagation(),c.removeWidget(d,"pager",!1)}).on("updateComplete"+j,function(a,d,f){if(a.stopPropagation(),d&&!f&&!h.ajax){var g=e.$tbodies.eq(0).children("tr").not(e.selectorRemove);h.totalRows=g.length-(i.pager_countChildRows?0:g.filter("."+e.cssChildRow).length),h.totalPages=Math.ceil(h.totalRows/h.size),g.length&&e.rowsCopy&&0===e.rowsCopy.length&&b.updateCache(d),h.page>=h.totalPages&&b.moveToLastPage(d,h),b.hideRows(d,e),b.changeHeight(d,e),b.updatePageDisplay(d,e,!1),c.applyWidget(d),b.updatePageDisplay(d,e)}}).on("pageSize refreshComplete ".split(" ").join(j+" "),function(a,c){a.stopPropagation(),b.setPageSize(e,b.parsePageSize(e,c,"get")),b.hideRows(d,e),b.updatePageDisplay(d,e,!1)}).on("pageSet pagerUpdate ".split(" ").join(j+" "),function(a,c){a.stopPropagation(),"pagerUpdate"===a.type&&(c="undefined"==typeof c?h.page+1:c,h.last.page=!0),h.page=(parseInt(c,10)||1)-1,b.moveToPage(d,h,!0),b.updatePageDisplay(d,e,!1)}).on("pageAndSize"+j,function(a,c,f){a.stopPropagation(),h.page=(parseInt(c,10)||1)-1,b.setPageSize(e,b.parsePageSize(e,f,"get")),b.moveToPage(d,h,!0),b.hideRows(d,e),b.updatePageDisplay(d,e,!1)}),f=[k.first,k.prev,k.next,k.last],g=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],e.debug&&!h.$container.length&&console.warn("Pager: >> Container not found"),h.$container.find(f.join(",")).attr("tabindex",0).off("click"+j).on("click"+j,function(c){c.stopPropagation();var e,j=a(this),k=f.length;if(!j.hasClass(i.pager_css.disabled))for(e=0;k>e;e++)if(j.is(f[e])){b[g[e]](d,h);break}}),h.$goto.length?h.$goto.off("change"+j).on("change"+j,function(){h.page=a(this).val()-1,b.moveToPage(d,h,!0),b.updatePageDisplay(d,e,!1)}):e.debug&&console.warn("Pager: >> Goto selector not found"),h.$size.length?(h.$size.find("option").removeAttr("selected"),h.$size.off("change"+j).on("change"+j,function(){if(!a(this).hasClass(i.pager_css.disabled)){var c=a(this).val();h.$size.val(c),b.setPageSize(e,c),b.changeHeight(d,e)}return!1})):e.debug&&console.warn("Pager: >> Size selector not found")},pagerArrows:function(a,b){var c=a.pager,d=!!b,e=d||0===c.page,f=Math.min(c.totalPages,c.filteredPages),g=d||c.page===f-1||0===f,h=a.widgetOptions,i=h.pager_selectors;h.pager_updateArrows&&(c.$container.find(i.first+","+i.prev).toggleClass(h.pager_css.disabled,e).attr("aria-disabled",e),c.$container.find(i.next+","+i.last).toggleClass(h.pager_css.disabled,g).attr("aria-disabled",g))},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,f){if(!e.pager.initializing){var g,h,i,j,k,l,m=e.widgetOptions,n=e.pager,o=e.namespace+"pager",p=b.parsePageSize(e,n.size,"get");if(m.pager_countChildRows&&h.push(e.cssChildRow),n.$size.add(n.$goto).removeClass(m.pager_css.disabled).removeAttr("disabled").attr("aria-disabled","false"),n.totalPages=Math.ceil(n.totalRows/p),e.totalRows=n.totalRows,b.parsePageNumber(e,n),b.calcFilters(e),e.filteredRows=n.filteredRows,n.filteredPages=Math.ceil(n.filteredRows/p)||0,Math.min(n.totalPages,n.filteredPages)>=0){if(h=n.size*n.page>n.filteredRows&&f,n.page=h?m.pager_pageReset||0:n.page,n.startRow=h?n.size*n.page+1:0===n.filteredRows?0:n.size*n.page+1,n.endRow=Math.min(n.filteredRows,n.totalRows,n.size*(n.page+1)),i=n.$container.find(m.pager_selectors.pageDisplay),g=(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,''):e.length>1&&f&&f[e[0]]?f[e[0]][e[1]]:n[d]||(f?f[d]:g)||g}),n.$goto.length){for(h="",j=b.buildPageSelect(n,e),l=j.length,k=0;l>k;k++)h+='";n.$goto.html(h).val(n.page+1)}i.length&&(i["INPUT"===i[0].nodeName?"val":"html"](g),i.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/n.size)+1:b;e.$table.trigger("pageSet"+o,[c])}))}b.pagerArrows(e),b.fixHeight(d,e),n.initialized&&f!==!1&&(e.debug&&console.log("Pager: Triggering pagerComplete"),e.$table.trigger("pagerComplete",e),m.pager_savePages&&c.storage&&c.storage(d,m.pager_storageKey,{page:n.page,size:n.size}))}},buildPageSelect:function(b,c){var d,e,f,g,h,i,j=c.widgetOptions,k=Math.min(b.totalPages,b.filteredPages)||1,l=5*Math.ceil(k/j.pager_maxOptionSize/5),m=k>j.pager_maxOptionSize,n=b.page+1,o=l,p=k-l,q=[1],r=m?l:1;for(d=r;k>=d;)q.push(d),d+=m?l:1;if(q.push(k),m){for(f=[],e=Math.max(Math.floor(j.pager_maxOptionSize/l)-1,5),o=n-e,1>o&&(o=1),p=n+e,p>k&&(p=k),d=o;p>=d;d++)f.push(d);q=a.grep(q,function(b,c){return a.inArray(b,q)===c}),h=q.length,i=f.length,h-i>l/2&&h+i>j.pager_maxOptionSize&&(g=Math.floor(h/2)-Math.floor(i/2),Array.prototype.splice.apply(q,[g,i])),q=q.concat(f)}return q=a.grep(q,function(b,c){return a.inArray(b,q)===c}).sort(function(a,b){return a-b})},fixHeight:function(b,c){var d,e,f=c.pager,g=c.widgetOptions,h=c.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),g.pager_fixedHeight&&!f.isDisabled&&(e=a.data(b,"pagerSavedHeight"),e&&(d=e-h.height(),d>5&&a.data(b,"pagerLastSize")===f.size&&h.children("tr:visible").length')))},changeHeight:function(c,d){var e,f=d.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove(),f.children("tr:visible").length||f.append(' '),e=f.children("tr").eq(0).height()*d.pager.size,a.data(c,"pagerSavedHeight",e),b.fixHeight(c,d),a.data(c,"pagerLastSize",d.pager.size)},hideRows:function(a,b){if(!b.widgetOptions.pager_ajaxUrl){var d,e,f,g,h,i=b.pager,j=b.widgetOptions,k=b.$tbodies.length,l=i.page*i.size,m=l+i.size,n=j&&j.filter_filteredRow||"filtered",o=0,p=0;for(i.cacheIndex=[],d=0;k>d;d++){for(f=b.$tbodies.eq(d).children("tr"),g=f.length,h=0,o=0,p=0,e=0;g>e;e++)f[e].className.match(n)||(p===l&&f[e].className.match(b.cssChildRow)?f[e].style.display="none":(f[e].style.display=p>=l&&m>p?"":"none",o!==p&&p>=l&&m>p&&(i.cacheIndex.push(e),o=p),p+=f[e].className.match(b.cssChildRow+"|"+b.selectorRemove.slice(1))&&!j.pager_countChildRows?0:1,p===m&&"none"!==f[e].style.display&&f[e].className.match(c.css.cssHasChild)&&(h=e)));if(h>0&&f[h].className.match(c.css.cssHasChild))for(;++h> Ajax Error",g,h,i),c.showError(e,g,h,i),f.$tbodies.eq(0).children("tr").detach(),j.totalRows=0;else{if(a.isArray(B)?(n=isNaN(B[0])&&!isNaN(B[1]),x=B[n?1:0],j.totalRows=isNaN(x)?j.totalRows||0:x,f.totalRows=f.filteredRows=j.filteredRows=j.totalRows,v=0===j.totalRows?[]:B[n?0:1]||[],u=B[2]):(j.ajaxData=B,f.totalRows=j.totalRows=B.total,f.filteredRows=j.filteredRows="undefined"!=typeof B.filteredRows?B.filteredRows:B.total,u=B.headers,v=B.rows||[]),w=v&&v.length,v instanceof jQuery)k.pager_processAjaxOnInit&&(f.$tbodies.eq(0).empty(),f.$tbodies.eq(0).append(v));else if(w){for(l=0;w>l;l++){for(A+="",m=0;m"+v[l][m]+"";A+=""}k.pager_processAjaxOnInit&&f.$tbodies.eq(0).html(A)}if(k.pager_processAjaxOnInit=!0,u&&u.length===C)for(o=z.hasClass("hasStickyHeaders"),q=o?k.$sticky.children("thead:first").children("tr").children():"",p=z.find("tfoot tr:first").children(),r=f.$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])}f.showProcessing&&c.isProcessing(e),j.totalPages=Math.ceil(j.totalRows/b.parsePageSize(f,j.size,"get")),j.last.totalRows=j.totalRows,j.last.currentFilters=j.currentFilters,j.last.sortList=(f.sortList||[]).join(","),j.initializing=!1,b.updatePageDisplay(e,f,!1),c.updateCache(f,function(){j.initialized&&setTimeout(function(){f.debug&&console.log("Pager: Triggering pagerChange"),z.trigger("pagerChange",j),c.applyWidget(e),b.updatePageDisplay(e,f)},0)})}j.initialized||c.applyWidget(e)},getAjax:function(d,e){var f,g=b.getAjaxUrl(d,e),h=a(document),i=e.namespace+"pager",j=e.pager;""!==g&&(e.showProcessing&&c.isProcessing(d,!0),h.on("ajaxError"+i,function(a,c,f,g){b.renderAjax(null,d,e,c,f,g),h.off("ajaxError"+i)}),f=++j.ajaxCounter,j.last.ajaxUrl=g,j.ajaxObject.url=g,j.ajaxObject.success=function(a,c,g){fd;d++)m.push(k+"["+i[d][0]+"]="+i[d][1]);h=h.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,m.length?m.join("&"):k),m=[]}if(l){for(l=l[1],e=j.length,d=0;e>d;d++)j[d]&&m.push(l+"["+d+"]="+encodeURIComponent(j[d]));h=h.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,m.length?m.join("&"):l),f.currentFilters=j}return a.isFunction(g.pager_customAjaxUrl)&&(h=g.pager_customAjaxUrl(b,h)),c.debug&&console.log("Pager: Ajax url = "+h),h},renderTable:function(a,d){var e,f,g,h,i=a.config,j=i.pager,k=i.widgetOptions,l=i.$table.hasClass("hasFilters"),m=d&&d.length||0,n=j.page*j.size,o=j.size;if(1>m)return void(i.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&&(i.debug&&console.log("Pager: Triggering pagerChange"),i.$table.trigger("pagerChange",i)),k.pager_removeRows){for(c.clearTableBody(a),e=c.processTbody(a,i.$tbodies.eq(0),!0),f=l?0:n,g=l?0:n,h=0;o>h&&fn&&o>=h&&(h++,j.cacheIndex.push(f),e.append(d[f]))),f++;c.processTbody(a,e,!1)}else b.hideRows(a,i);b.updatePageDisplay(a,i),k.pager_startPage=j.page,k.pager_size=j.size,a.isUpdating&&(i.debug&&console.log("Pager: Triggering updateComplete"),i.$table.trigger("updateComplete",[a,!0]))},showAllRows:function(d,e){var f,g,h,i=e.pager,j=e.widgetOptions;for(i.ajax?b.pagerArrows(e,!0):(a.data(d,"pagerLastPage",i.page),a.data(d,"pagerLastSize",i.size),i.page=0,i.size=i.totalRows,i.totalPages=1,e.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(d,e.rowsCopy),i.isDisabled=!0,c.applyWidget(d),e.debug&&console.log("Pager: Disabled")),g=i.$size.add(i.$goto).add(i.$container.find(".ts-startRow, .ts-page ")),h=g.length,f=0;h>f;f++)g.eq(f).attr("aria-disabled","true").addClass(j.pager_css.disabled)[0].disabled=!0},updateCache:function(d){var e=d.config,f=e.pager;c.updateCache(e,function(){if(!a.isEmptyObject(d.config.cache)){var c,g=[],h=d.config.cache[0].normalized;for(f.totalRows=h.length,c=0;cd&&0!==b.page&&(b.page=d),b.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=Math.ceil(e.totalRows/e.size),e.filteredPages=Math.ceil(e.filteredRows/e.size),b.moveToPage(f,e,!0)},moveToFirstPage:function(a,c){c.page=0,b.moveToPage(a,c,!0)},moveToLastPage:function(a,c){c.page=Math.min(c.totalPages,c.filteredPages)-1,b.moveToPage(a,c,!0)},moveToNextPage:function(a,c){c.page++,c.page>=Math.min(c.totalPages,c.filteredPages)-1&&(c.page=Math.min(c.totalPages,c.filteredPages)-1),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,e){var f=d.pager,g=d.widgetOptions.pager_selectors,h=[g.first,g.prev,g.next,g.last,g.gotoPage,g.pageSize].join(","),i=d.namespace+"pager";f.initialized=!1,d.$table.off(i),f.$container.hide().find(h).off(i),e||(b.showAllRows(a,d),d.appender=null,c.storage&&c.storage(a,d.widgetOptions.pager_storageKey,""),delete a.config.pager,delete a.config.rowsCopy)},enablePager:function(d,e,f){var g,h,i=e.pager;i.isDisabled=!1,i.page=a.data(d,"pagerLastPage")||i.page||0,h=i.$size.find("option[selected]").val(),i.size=a.data(d,"pagerLastSize")||b.parsePageSize(e,h,"get"),i.$size.val(b.parsePageSize(e,i.size,"set")),i.totalPages=Math.ceil(Math.min(i.totalRows,i.filteredRows)/i.size),e.$table.removeClass("pagerDisabled"),d.id&&(g=d.id+"_pager_info",i.$container.find(e.widgetOptions.pager_selectors.pageDisplay).attr("id",g),e.$table.attr("aria-describedby",g)),b.changeHeight(d,e),f&&(c.update(e),b.setPageSize(e,i.size),b.hideRowsSetup(d,e),e.debug&&console.log("Pager: Enabled"))},appender:function(c,d){var e=c.config,f=e.widgetOptions,g=e.pager;g.ajax?b.moveToPage(c,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=Math.ceil(g.totalRows/g.size),b.moveToPage(c,g),b.updatePageDisplay(c,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:''+m+"").click(function(){a(this).remove()}).appendTo(h.$table.find("thead:first")).addClass(j+" "+h.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})}}(jQuery); \ No newline at end of file +!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(a,c.pager,!1):b.initComplete(a,c)},remove:function(a,c,d,e){b.destroyPager(a,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=(isNaN(e.size)?i.size:e.size)||i.setSize||10,a.data(d,"pagerLastSize",i.size)),i.regexRows=new RegExp("("+(g.filter_filteredRow||"filtered")+"|"+f.selectorRemove.slice(1)+"|"+f.cssChildRow+")"),i.initialized=!1,f.$table.trigger("pagerBeforeInitialized",f),b.enablePager(d,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(d,i)):(i.ajax=!1,c.appendCache(f,!0)))}},initComplete:function(a,d){var e=d.pager;b.bindEvents(a,d),b.setPageSize(d,0),e.ajax||b.hideRowsSetup(a,d),e.initialized=!0,e.initializing=!1,e.isInitializing=!1,d.debug&&console.log("Pager: Triggering pagerInitialized"),d.$table.trigger("pagerInitialized",d),d.widgetOptions.filter_initialized&&c.hasWidget(a,"filter")||b.updatePageDisplay(a,d,!e.ajax)},bindEvents:function(d,e){var f,g,h=e.pager,i=e.widgetOptions,j=e.namespace+"pager",k=i.pager_selectors;e.$table.off(j).on("filterInit filterStart ".split(" ").join(j+" "),function(b,c){h.currentFilters=a.isArray(c)?c:e.$table.data("lastSearch"),"filterStart"===b.type&&i.pager_pageReset!==!1&&(e.lastCombinedFilter||"")!==(h.currentFilters||[]).join("")&&(h.page=i.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(j+" "),function(){h.currentFilters=e.$table.data("lastSearch"),(h.initialized||h.initializing)&&(e.delayInit&&e.rowsCopy&&0===e.rowsCopy.length&&b.updateCache(d),b.updatePageDisplay(d,e,!1),c.applyWidget(d))}).on("disablePager"+j,function(a){a.stopPropagation(),b.showAllRows(d,e)}).on("enablePager"+j,function(a){a.stopPropagation(),b.enablePager(d,e,!0)}).on("destroyPager"+j,function(a,b){a.stopPropagation(),c.removeWidget(d,"pager",!1)}).on("updateComplete"+j,function(a,d,f){if(a.stopPropagation(),d&&!f&&!h.ajax){var g=e.$tbodies.eq(0).children("tr").not(e.selectorRemove);h.totalRows=g.length-(i.pager_countChildRows?0:g.filter("."+e.cssChildRow).length),h.totalPages=Math.ceil(h.totalRows/h.size),g.length&&e.rowsCopy&&0===e.rowsCopy.length&&b.updateCache(d),h.page>=h.totalPages&&b.moveToLastPage(d,h),b.hideRows(d,e),b.changeHeight(d,e),b.updatePageDisplay(d,e,!1),c.applyWidget(d),b.updatePageDisplay(d,e)}}).on("pageSize refreshComplete ".split(" ").join(j+" "),function(a,c){a.stopPropagation(),b.setPageSize(e,b.parsePageSize(e,c,"get")),b.hideRows(d,e),b.updatePageDisplay(d,e,!1)}).on("pageSet pagerUpdate ".split(" ").join(j+" "),function(a,c){a.stopPropagation(),"pagerUpdate"===a.type&&(c="undefined"==typeof c?h.page+1:c,h.last.page=!0),h.page=(parseInt(c,10)||1)-1,b.moveToPage(d,h,!0),b.updatePageDisplay(d,e,!1)}).on("pageAndSize"+j,function(a,c,f){a.stopPropagation(),h.page=(parseInt(c,10)||1)-1,b.setPageSize(e,b.parsePageSize(e,f,"get")),b.moveToPage(d,h,!0),b.hideRows(d,e),b.updatePageDisplay(d,e,!1)}),f=[k.first,k.prev,k.next,k.last],g=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],e.debug&&!h.$container.length&&console.warn("Pager: >> Container not found"),h.$container.find(f.join(",")).attr("tabindex",0).off("click"+j).on("click"+j,function(c){c.stopPropagation();var e,j=a(this),k=f.length;if(!j.hasClass(i.pager_css.disabled))for(e=0;k>e;e++)if(j.is(f[e])){b[g[e]](d,h);break}}),h.$goto.length?h.$goto.off("change"+j).on("change"+j,function(){h.page=a(this).val()-1,b.moveToPage(d,h,!0),b.updatePageDisplay(d,e,!1)}):e.debug&&console.warn("Pager: >> Goto selector not found"),h.$size.length?(h.$size.find("option").removeAttr("selected"),h.$size.off("change"+j).on("change"+j,function(){if(!a(this).hasClass(i.pager_css.disabled)){var c=a(this).val();h.$size.val(c),b.setPageSize(e,c),b.changeHeight(d,e)}return!1})):e.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,f){if(!e.pager.initializing){var g,h,i,j,k,l,m=e.widgetOptions,n=e.pager,o=e.namespace+"pager",p=b.parsePageSize(e,n.size,"get");if(m.pager_countChildRows&&h.push(e.cssChildRow),n.$size.add(n.$goto).removeClass(m.pager_css.disabled).removeAttr("disabled").attr("aria-disabled","false"),n.totalPages=Math.ceil(n.totalRows/p),e.totalRows=n.totalRows,b.parsePageNumber(e,n),b.calcFilters(e),e.filteredRows=n.filteredRows,n.filteredPages=Math.ceil(n.filteredRows/p)||0,b.getTotalPages(e,n)>=0){if(h=n.size*n.page>n.filteredRows&&f,n.page=h?m.pager_pageReset||0:n.page,n.startRow=h?n.size*n.page+1:0===n.filteredRows?0:n.size*n.page+1,n.endRow=Math.min(n.filteredRows,n.totalRows,n.size*(n.page+1)),i=n.$container.find(m.pager_selectors.pageDisplay),g=(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,''):e.length>1&&f&&f[e[0]]?f[e[0]][e[1]]:n[d]||(f?f[d]:g)||g}),n.$goto.length){for(h="",j=b.buildPageSelect(n,e),l=j.length,k=0;l>k;k++)h+='";n.$goto.html(h).val(n.page+1)}i.length&&(i["INPUT"===i[0].nodeName?"val":"html"](g),i.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/n.size)+1:b;e.$table.trigger("pageSet"+o,[c])}))}b.pagerArrows(e),b.fixHeight(d,e),n.initialized&&f!==!1&&(e.debug&&console.log("Pager: Triggering pagerComplete"),e.$table.trigger("pagerComplete",e),m.pager_savePages&&c.storage&&c.storage(d,m.pager_storageKey,{page:n.page,size:n.size}))}},buildPageSelect:function(c,d){var e,f,g,h,i,j,k=d.widgetOptions,l=b.getTotalPages(d,c)||1,m=5*Math.ceil(l/k.pager_maxOptionSize/5),n=l>k.pager_maxOptionSize,o=c.page+1,p=m,q=l-m,r=[1],s=n?m:1;for(e=s;l>=e;)r.push(e),e+=n?m:1;if(r.push(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.push(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,c){var d,e,f=c.pager,g=c.widgetOptions,h=c.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),g.pager_fixedHeight&&!f.isDisabled&&(e=a.data(b,"pagerSavedHeight"),e&&(d=e-h.height(),d>5&&a.data(b,"pagerLastSize")===f.size&&h.children("tr:visible").length')))},changeHeight:function(c,d){var e,f=d.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove(),f.children("tr:visible").length||f.append(' '),e=f.children("tr").eq(0).height()*d.pager.size,a.data(c,"pagerSavedHeight",e),b.fixHeight(c,d),a.data(c,"pagerLastSize",d.pager.size)},hideRows:function(a,b){if(!b.widgetOptions.pager_ajaxUrl){var d,e,f,g,h,i=b.pager,j=b.widgetOptions,k=b.$tbodies.length,l=i.page*i.size,m=l+i.size,n=j&&j.filter_filteredRow||"filtered",o=0,p=0;for(i.cacheIndex=[],d=0;k>d;d++){for(f=b.$tbodies.eq(d).children("tr"),g=f.length,h=0,o=0,p=0,e=0;g>e;e++)f[e].className.match(n)||(p===l&&f[e].className.match(b.cssChildRow)?f[e].style.display="none":(f[e].style.display=p>=l&&m>p?"":"none",o!==p&&p>=l&&m>p&&(i.cacheIndex.push(e),o=p),p+=f[e].className.match(b.cssChildRow+"|"+b.selectorRemove.slice(1))&&!j.pager_countChildRows?0:1,p===m&&"none"!==f[e].style.display&&f[e].className.match(c.css.cssHasChild)&&(h=e)));if(h>0&&f[h].className.match(c.css.cssHasChild))for(;++h> Ajax Error",g,h,i),c.showError(e,g,h,i),f.$tbodies.eq(0).children("tr").detach(),j.totalRows=0;else{if(a.isArray(B)?(n=isNaN(B[0])&&!isNaN(B[1]),x=B[n?1:0],j.totalRows=isNaN(x)?j.totalRows||0:x,f.totalRows=f.filteredRows=j.filteredRows=j.totalRows,v=0===j.totalRows?[]:B[n?0:1]||[],u=B[2]):(j.ajaxData=B,f.totalRows=j.totalRows=B.total,f.filteredRows=j.filteredRows="undefined"!=typeof B.filteredRows?B.filteredRows:B.total,u=B.headers,v=B.rows||[]),w=v&&v.length,v instanceof jQuery)k.pager_processAjaxOnInit&&(f.$tbodies.eq(0).empty(),f.$tbodies.eq(0).append(v));else if(w){for(l=0;w>l;l++){for(A+="",m=0;m"+v[l][m]+"";A+=""}k.pager_processAjaxOnInit&&f.$tbodies.eq(0).html(A)}if(k.pager_processAjaxOnInit=!0,u&&u.length===C)for(o=z.hasClass("hasStickyHeaders"),q=o?k.$sticky.children("thead:first").children("tr").children():"",p=z.find("tfoot tr:first").children(),r=f.$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])}f.showProcessing&&c.isProcessing(e),j.totalPages=Math.ceil(j.totalRows/b.parsePageSize(f,j.size,"get")),j.last.totalRows=j.totalRows,j.last.currentFilters=j.currentFilters,j.last.sortList=(f.sortList||[]).join(","),j.initializing=!1,b.updatePageDisplay(e,f,!1),c.updateCache(f,function(){j.initialized&&setTimeout(function(){f.debug&&console.log("Pager: Triggering pagerChange"),z.trigger("pagerChange",j),c.applyWidget(e),b.updatePageDisplay(e,f)},0)})}j.initialized||c.applyWidget(e)},getAjax:function(d,e){var f,g=b.getAjaxUrl(d,e),h=a(document),i=e.namespace+"pager",j=e.pager;""!==g&&(e.showProcessing&&c.isProcessing(d,!0),h.on("ajaxError"+i,function(a,c,f,g){b.renderAjax(null,d,e,c,f,g),h.off("ajaxError"+i)}),f=++j.ajaxCounter,j.last.ajaxUrl=g,j.ajaxObject.url=g,j.ajaxObject.success=function(a,c,g){fd;d++)m.push(k+"["+i[d][0]+"]="+i[d][1]);h=h.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,m.length?m.join("&"):k),m=[]}if(l){for(l=l[1],e=j.length,d=0;e>d;d++)j[d]&&m.push(l+"["+d+"]="+encodeURIComponent(j[d]));h=h.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,m.length?m.join("&"):l),f.currentFilters=j}return a.isFunction(g.pager_customAjaxUrl)&&(h=g.pager_customAjaxUrl(b,h)),c.debug&&console.log("Pager: Ajax url = "+h),h},renderTable:function(a,d){var e,f,g,h,i=a.config,j=i.pager,k=i.widgetOptions,l=i.$table.hasClass("hasFilters"),m=d&&d.length||0,n=j.page*j.size,o=j.size;if(1>m)return void(i.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&&(i.debug&&console.log("Pager: Triggering pagerChange"),i.$table.trigger("pagerChange",i)),k.pager_removeRows){for(c.clearTableBody(a),e=c.processTbody(a,i.$tbodies.eq(0),!0),f=l?0:n,g=l?0:n,h=0;o>h&&fn&&o>=h&&(h++,j.cacheIndex.push(f),e.append(d[f]))),f++;c.processTbody(a,e,!1)}else b.hideRows(a,i);b.updatePageDisplay(a,i),k.pager_startPage=j.page,k.pager_size=j.size,a.isUpdating&&(i.debug&&console.log("Pager: Triggering updateComplete"),i.$table.trigger("updateComplete",[a,!0]))},showAllRows:function(d,e){var f,g,h,i=e.pager,j=e.widgetOptions;for(i.ajax?b.pagerArrows(e,!0):(a.data(d,"pagerLastPage",i.page),a.data(d,"pagerLastSize",i.size),i.page=0,i.size=i.totalRows,i.totalPages=1,e.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(d,e.rowsCopy),i.isDisabled=!0,c.applyWidget(d),e.debug&&console.log("Pager: Disabled")),g=i.$size.add(i.$goto).add(i.$container.find(".ts-startRow, .ts-page ")),h=g.length,f=0;h>f;f++)g.eq(f).attr("aria-disabled","true").addClass(j.pager_css.disabled)[0].disabled=!0},updateCache:function(d){var e=d.config,f=e.pager;c.updateCache(e,function(){if(!a.isEmptyObject(d.config.cache)){var c,g=[],h=d.config.cache[0].normalized;for(f.totalRows=h.length,c=0;cd&&0!==c.page&&(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=Math.ceil(e.totalRows/e.size),e.filteredPages=Math.ceil(e.filteredRows/e.size),b.moveToPage(f,e,!0)},moveToFirstPage:function(a,c){c.page=0,b.moveToPage(a,c,!0)},moveToLastPage:function(a,c){c.page=b.getTotalPages(a.config,c)-1,b.moveToPage(a,c,!0)},moveToNextPage:function(a,c){c.page++;var d=b.getTotalPages(a.config,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,e){var f=d.pager,g=d.widgetOptions.pager_selectors,h=[g.first,g.prev,g.next,g.last,g.gotoPage,g.pageSize].join(","),i=d.namespace+"pager";f.initialized=!1,d.$table.off(i),f.$container.hide().find(h).off(i),e||(b.showAllRows(a,d),d.appender=null,c.storage&&c.storage(a,d.widgetOptions.pager_storageKey,""),delete a.config.pager,delete a.config.rowsCopy)},enablePager:function(d,e,f){var g,h,i=e.pager;i.isDisabled=!1,i.page=a.data(d,"pagerLastPage")||i.page||0,h=i.$size.find("option[selected]").val(),i.size=a.data(d,"pagerLastSize")||b.parsePageSize(e,h,"get"),i.$size.val(b.parsePageSize(e,i.size,"set")),i.totalPages=Math.ceil(b.getTotalPages(e,i)/i.size),e.$table.removeClass("pagerDisabled"),d.id&&(g=d.id+"_pager_info",i.$container.find(e.widgetOptions.pager_selectors.pageDisplay).attr("id",g),e.$table.attr("aria-describedby",g)),b.changeHeight(d,e),f&&(c.update(e),b.setPageSize(e,i.size),b.hideRowsSetup(d,e),e.debug&&console.log("Pager: Enabled"))},appender:function(c,d){var e=c.config,f=e.widgetOptions,g=e.pager;g.ajax?b.moveToPage(c,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=Math.ceil(g.totalRows/g.size),b.moveToPage(c,g),b.updatePageDisplay(c,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:''+m+"").click(function(){a(this).remove()}).appendTo(h.$table.find("thead:first")).addClass(j+" "+h.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"})}}(jQuery); \ No newline at end of file diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index 06516dff..77e2c1f4 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -382,7 +382,7 @@ var p = c.pager, dis = !!disable, first = dis || p.page === 0, - tp = Math.min( p.totalPages, p.filteredPages ), + tp = tsp.getTotalPages( c, p ), last = dis || p.page === tp - 1 || tp === 0, wo = c.widgetOptions, s = wo.pager_selectors; @@ -429,7 +429,7 @@ tsp.calcFilters( c ); c.filteredRows = p.filteredRows; p.filteredPages = Math.ceil( p.filteredRows / sz ) || 0; - if ( Math.min( p.totalPages, p.filteredPages ) >= 0 ) { + if ( tsp.getTotalPages( c, p ) >= 0 ) { t = (p.size * p.page > p.filteredRows) && completed; p.page = (t) ? wo.pager_pageReset || 0 : p.page; p.startRow = (t) ? p.size * p.page + 1 : (p.filteredRows === 0 ? 0 : p.size * p.page + 1); @@ -498,7 +498,7 @@ // as large page set links will slow the browser on large dom inserts var i, central_focus_size, focus_option_pages, insert_index, option_length, focus_length, wo = c.widgetOptions, - pg = Math.min( p.totalPages, p.filteredPages ) || 1, + pg = tsp.getTotalPages( c, p ) || 1, // make skip set size multiples of 5 skip_set_size = Math.ceil( ( pg / wo.pager_maxOptionSize ) / 5 ) * 5, large_collection = pg > wo.pager_maxOptionSize, @@ -1045,6 +1045,10 @@ } }, + getTotalPages: function( c, p ) { + return ts.hasWidget( c.table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages; + }, + // set to either set or get value parsePageSize: function( c, size, mode ) { var p = c.pager, @@ -1058,7 +1062,7 @@ }, parsePageNumber: function( c, p ) { - var min = ( ts.hasWidget( c.table, 'filter' ) ? Math.min( p.totalPages, p.filteredPages ) : p.totalPages ) - 1; + var min = tsp.getTotalPages( c, p ) - 1; p.page = parseInt( p.page, 10 ); if ( p.page < 0 || isNaN( p.page ) ) { p.page = 0; } if ( p.page > min && p.page !== 0 ) { p.page = min; } @@ -1083,14 +1087,15 @@ }, moveToLastPage: function(table, p) { - p.page = ( Math.min( p.totalPages, p.filteredPages ) - 1 ); + p.page = tsp.getTotalPages( table.config, p ) - 1; tsp.moveToPage(table, p, true); }, moveToNextPage: function(table, p) { p.page++; - if ( p.page >= ( Math.min( p.totalPages, p.filteredPages ) - 1 ) ) { - p.page = ( Math.min( p.totalPages, p.filteredPages ) - 1 ); + var last = tsp.getTotalPages( table.config, p ) - 1; + if ( p.page >= last ) { + p.page = last; } tsp.moveToPage(table, p, true); }, @@ -1134,7 +1139,7 @@ size = p.$size.find('option[selected]').val(); p.size = $.data(table, 'pagerLastSize') || tsp.parsePageSize( c, size, 'get' ); p.$size.val( tsp.parsePageSize( c, p.size, 'set' ) ); // set page size - p.totalPages = Math.ceil( Math.min( p.totalRows, p.filteredRows ) / p.size ); + p.totalPages = Math.ceil( tsp.getTotalPages( c, p ) / p.size ); c.$table.removeClass('pagerDisabled'); // if table id exists, include page display with aria info if ( table.id ) {