From d1e9530bcfd5fbc6a2e0d62b114cec466807a7de Mon Sep 17 00:00:00 2001 From: Mottie Date: Wed, 19 Aug 2015 16:33:32 -0500 Subject: [PATCH] Pager: include settings parameter from ajaxError method & prevent js error. Fixes #997 --- addons/pager/jquery.tablesorter.pager.js | 66 ++++++++++--------- .../js/extras/jquery.tablesorter.pager.min.js | 2 +- dist/js/widgets/widget-pager.min.js | 2 +- docs/example-pager-ajax.html | 5 ++ docs/example-pager.html | 5 ++ docs/example-widget-pager-ajax.html | 5 ++ docs/example-widget-pager.html | 5 ++ docs/index.html | 13 +++- js/widgets/widget-pager.js | 66 ++++++++++--------- 9 files changed, 100 insertions(+), 69 deletions(-) diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 86da0919..073c4d86 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -26,7 +26,7 @@ customAjaxUrl: function(table, url) { return url; }, // ajax error callback from $.tablesorter.showError function - // ajaxError: function( config, xhr, exception ){ return exception; }; + // ajaxError: function( config, xhr, settings, exception ){ return exception; }; // returning false will abort the error message ajaxError: null, @@ -379,7 +379,7 @@ } }, - renderAjax = function(data, table, p, xhr, exception){ + renderAjax = function(data, table, p, xhr, settings, exception){ // process data if ( typeof p.ajaxProcessing === 'function' ) { // ajaxProcessing result: [ total, rows, headers ] @@ -395,9 +395,9 @@ if ( exception ) { if (c.debug) { - console.error('Pager: >> Ajax Error', xhr, exception); + console.error('Pager: >> Ajax Error', xhr, settings, exception); } - ts.showError( table, xhr, exception ); + ts.showError( table, xhr, settings, exception ); c.$tbodies.eq(0).children('tr').detach(); p.totalRows = 0; } else { @@ -522,7 +522,7 @@ ts.isProcessing(table, true); // show loading icon } $doc.bind('ajaxError' + namespace, function(e, xhr, settings, exception) { - renderAjax(null, table, p, xhr, exception); + renderAjax(null, table, p, xhr, settings, exception); $doc.unbind('ajaxError' + namespace); }); @@ -1067,12 +1067,14 @@ }() }); // see #486 - ts.showError = function( table, xhr, exception ) { + ts.showError = function( table, xhr, settings, exception ) { var $row, $table = $( table ), c = $table[0].config, wo = c && c.widgetOptions, - errorRow = c.pager && c.pager.cssErrorRow || wo.pager_css && wo.pager_css.errorRow || 'tablesorter-errorRow', + errorRow = c.pager && c.pager.cssErrorRow || + wo && wo.pager_css && wo.pager_css.errorRow || + 'tablesorter-errorRow', typ = typeof xhr, valid = true, message = '', @@ -1085,23 +1087,25 @@ return; } - if ( typ !== 'string' ) { - // ajaxError callback for plugin or widget - see #992 - if ( typeof c.pager.ajaxError === 'function' ) { - valid = c.pager.ajaxError( c, xhr, exception ); - if ( valid === false ) { - return removeRow(); - } else { - message = valid; - } - } else if ( typeof wo.pager_ajaxError === 'function' ) { - valid = wo.pager_ajaxError( c, xhr, exception ); - if ( valid === false ) { - return removeRow(); - } else { - message = valid; - } + // ajaxError callback for plugin or widget - see #992 + if ( typeof c.pager.ajaxError === 'function' ) { + valid = c.pager.ajaxError( c, xhr, settings, exception ); + if ( valid === false ) { + return removeRow(); } else { + message = valid; + } + } else if ( typeof wo.pager_ajaxError === 'function' ) { + valid = wo.pager_ajaxError( c, xhr, settings, exception ); + if ( valid === false ) { + return removeRow(); + } else { + message = valid; + } + } + + if ( message === '' ) { + if ( typ === 'object' ) { message = xhr.status === 0 ? 'Not connected, verify Network' : xhr.status === 404 ? 'Requested page not found [404]' : @@ -1110,18 +1114,16 @@ exception === 'timeout' ? 'Time out error' : exception === 'abort' ? 'Ajax Request aborted' : 'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']'; + } else if ( typ === 'string' ) { + // keep backward compatibility (external usage just passes a message string) + message = xhr; + } else { + // remove all error rows + return removeRow(); } - } else if ( typ !== 'undefined' ) { - // keep backward compatibility (external usage just passes a message string) - message = xhr; } - if ( message === '' ) { - // remove all error rows - return removeRow(); - } - - // allow message to include HTML (must include entire row!) + // allow message to include entire row HTML! $row = ( /tr\>/.test(message) ? $(message) : $('' + message + '') ) .click( function() { $( this ).remove(); diff --git a/dist/js/extras/jquery.tablesorter.pager.min.js b/dist/js/extras/jquery.tablesorter.pager.min.js index 3deea890..cd0645e1 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 8/17/2015 (v2.23.0) */ -!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=d.size||d.settings.size||10;if(d.countChildRows&&k.push(p.cssChildRow),d.totalPages=Math.ceil(d.totalRows/r),p.totalRows=d.totalRows,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),b.showError(d,f,h),w.$tbodies.eq(0).children("tr").detach(),e.totalRows=0;else{if(a.isArray(z)?(k=isNaN(z[0])&&!isNaN(z[1]),u=z[k?1:0],e.totalRows=isNaN(u)?e.totalRows||0:u,w.totalRows=w.filteredRows=e.filteredRows=e.totalRows,s=0===e.totalRows?[]:z[k?0:1]||[],r=z[2]):(e.ajaxData=z,w.totalRows=e.totalRows=z.total,w.filteredRows=e.filteredRows="undefined"!=typeof z.filteredRows?z.filteredRows:z.total,r=z.headers,s=z.rows||[]),t=s&&s.length,s instanceof jQuery)e.processAjaxOnInit&&(w.$tbodies.eq(0).children("tr").detach(),w.$tbodies.eq(0).append(s));else if(t){for(i=0;t>i;i++){for(y+="",j=0;j"+s[i][j]+"";y+=""}e.processAjaxOnInit&&w.$tbodies.eq(0).html(y)}if(e.processAjaxOnInit=!0,r&&r.length===A)for(l=x.hasClass("hasStickyHeaders"),n=l?w.widgetOptions.$sticky.children("thead:first").children("tr").children():"",m=x.find("tfoot tr:first").children(),o=w.$headers.filter("th "),v=o.length,j=0;v>j;j++)p=o.eq(j),p.find("."+b.css.icon).length?(q=p.find("."+b.css.icon).clone(!0),p.find(".tablesorter-header-inner").html(r[j]).append(q),l&&n.length&&(q=n.eq(j).find("."+b.css.icon).clone(!0),n.eq(j).find(".tablesorter-header-inner").html(r[j]).append(q))):(p.find(".tablesorter-header-inner").html(r[j]),l&&n.length&&n.eq(j).find(".tablesorter-header-inner").html(r[j])),m.eq(j).html(r[j])}w.showProcessing&&b.isProcessing(d),e.totalPages=Math.ceil(e.totalRows/(e.size||e.settings.size||10)),e.last.totalRows=e.totalRows,e.last.currentFilters=e.currentFilters,e.last.sortList=(w.sortList||[]).join(","),g(d,e,!1),x.trigger("updateCache",[function(){e.initialized&&setTimeout(function(){w.debug&&console.log("Pager: Triggering pagerChange"),x.trigger("applyWidgets").trigger("pagerChange",e),g(d,e,!0)},0)}])}e.initialized||(e.initialized=!0,e.initializing=!1,d.config.debug&&console.log("Pager: Triggering pagerInitialized"),a(d).trigger("applyWidgets").trigger("pagerInitialized",e),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,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&&v(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(b,c){var d,f,g;for(c.ajax?e(c,!0):(c.isDisabled=!0,a.data(b,"pagerLastPage",c.page),a.data(b,"pagerLastSize",c.size),c.page=0,c.size=c.totalRows,c.totalPages=1,a(b).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),p(b,b.config.rowsCopy,c),a(b).trigger("applyWidgets"),b.config.debug&&console.log("Pager: Disabled")),f=c.$size.add(c.$goto).add(c.$container.find(".ts-startRow, .ts-page")),g=f.length,d=0;g>d;d++)f.eq(d).attr("aria-disabled","true").addClass(c.cssDisabled)[0].disabled=!0},r=function(a){var b=a.config,c=b.pager;b.$table.trigger("updateCache",[function(){var d,e=[],f=a.config.cache[0].normalized;for(c.totalRows=f.length,d=0;dg-1&&0!==g&&(d.page=g-1),j.currentFilters=""===(j.currentFilters||[]).join("")?[]:j.currentFilters,d.currentFilters=""===(d.currentFilters||[]).join("")?[]:d.currentFilters,(j.page!==d.page||j.size!==d.size||j.totalRows!==d.totalRows||(j.currentFilters||[]).join(",")!==(d.currentFilters||[]).join(",")||(j.ajaxUrl||"")!==(d.ajaxObject.url||"")||(j.optAjaxUrl||"")!==(d.ajaxUrl||"")||j.sortList!==(h.sortList||[]).join(","))&&(h.debug&&console.log("Pager: Changing to page "+d.page),d.last={page:d.page,size:d.size,sortList:(h.sortList||[]).join(","),totalRows:d.totalRows,currentFilters:d.currentFilters||[],ajaxUrl:d.ajaxObject.url||"",optAjaxUrl:d.ajaxUrl||""},d.ajax?n(c,d):d.ajax||p(c,h.rowsCopy,d),a.data(c,"pagerLastPage",d.page),d.initialized&&e!==!1&&(h.debug&&console.log("Pager: Triggering pageMoved"),i.trigger("pageMoved",d).trigger("applyWidgets"),c.isUpdating&&(h.debug&&console.log("Pager: Triggering updateComplete"),i.trigger("updateComplete",[c,!0]))))))}},t=function(b,c,d){d.size=c||d.size||d.settings.size||10,d.$size.val(d.size),a.data(b,"pagerLastPage",d.page),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)},u=function(a,b){b.page=0,s(a,b)},v=function(a,b){b.page=Math.min(b.totalPages,b.filteredPages)-1,s(a,b)},w=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)},x=function(a,b){b.page--,b.page<=0&&(b.page=0),s(a,b)},y=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},z=function(b,c,d){var e,f=b.config;c.$size.add(c.$goto).add(c.$container.find(".ts-startRow, .ts-page")).removeClass(c.cssDisabled).removeAttr("disabled").attr("aria-disabled","false"),c.isDisabled=!1,c.page=a.data(b,"pagerLastPage")||c.page||0,c.size=a.data(b,"pagerLastSize")||parseInt(c.$size.find("option[selected]").val(),10)||c.size||c.settings.size||10,c.$size.val(c.size),c.totalPages=Math.ceil(Math.min(c.totalRows,c.filteredRows)/c.size),b.id&&(e=b.id+"_pager_info",c.$container.find(c.cssPageDisplay).attr("id",e),f.$table.attr("aria-describedby",e)),j(b,c),d&&(f.$table.trigger("updateRows"),t(b,c.size,c),l(b,c),f.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),A=n.$table,B=n.namespace+"pager",C=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+")"),A.unbind(c.split(" ").join(B+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(B+" "),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(B+" "),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),n.$table.trigger("applyWidgets"))}).bind("disablePager"+B,function(a){a.stopPropagation(),q(m,p)}).bind("enablePager"+B,function(a){a.stopPropagation(),z(m,p,!0)}).bind("destroyPager"+B,function(a){a.stopPropagation(),y(m,p)}).bind("updateComplete"+B,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&&v(b,p),k(b,p),j(b,p),g(b,p,!0)}}).bind("pageSize refreshComplete ".split(" ").join(B+" "),function(a,b){a.stopPropagation(),t(m,parseInt(b,10)||p.settings.size||10,p),k(m,p),g(m,p,!1)}).bind("pageSet pagerUpdate ".split(" ").join(B+" "),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"+B,function(a,b,c){a.stopPropagation(),p.page=(parseInt(b,10)||1)-1,t(m,parseInt(c,10)||p.settings.size||10,p),s(m,p,!0),k(m,p),g(m,p,!1)}),h=[p.cssFirst,p.cssPrev,p.cssNext,p.cssLast],i=[u,x,w,v],n.debug&&!C.length&&console.warn("Pager: >> Container not found"),C.find(h.join(",")).attr("tabindex",0).unbind("click"+B).bind("click"+B,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=C.find(p.cssGoto),p.$goto.length?p.$goto.unbind("change"+B).bind("change"+B,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=C.find(p.cssPageSize),p.$size.length?(p.$size.find("option").removeAttr("selected"),p.$size.unbind("change"+B).bind("change"+B,function(){return p.$size.val(a(this).val()),a(this).hasClass(p.cssDisabled)||(t(m,parseInt(a(this).val(),10),p),j(m,p)),!1})):n.debug&&console.warn("Pager: >> Size selector not found"),p.initialized=!1,A.trigger("pagerBeforeInitialized",p),z(m,p,!1),"string"==typeof p.ajaxUrl?(p.ajax=!0,n.widgetOptions.filter_serversideFiltering=!0,n.serverSideSorting=!0,s(m,p)):(p.ajax=!1,a(this).trigger("appendCache",!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){var e,f=a(b),g=f[0].config,h=g&&g.widgetOptions,i=g.pager&&g.pager.cssErrorRow||h.pager_css&&h.pager_css.errorRow||"tablesorter-errorRow",j=typeof c,k=!0,l="",m=function(){g.$table.find("thead").find("."+i).remove()};if(!f.length)return void console.error("tablesorter showError: no table parameter passed");if("string"!==j)if("function"==typeof g.pager.ajaxError){if(k=g.pager.ajaxError(g,c,d),k===!1)return m();l=k}else if("function"==typeof h.pager_ajaxError){if(k=h.pager_ajaxError(g,c,d),k===!1)return m();l=k}else l=0===c.status?"Not connected, verify Network":404===c.status?"Requested page not found [404]":500===c.status?"Internal Server Error [500]":"parsererror"===d?"Requested JSON parse failed":"timeout"===d?"Time out error":"abort"===d?"Ajax Request aborted":"Uncaught error: "+c.statusText+" ["+c.status+"]";else"undefined"!==j&&(l=c);return""===l?m():void(e=a(/tr\>/.test(l)?l:''+l+"").click(function(){a(this).remove()}).appendTo(g.$table.find("thead:first")).addClass(i+" "+g.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){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=d.size||d.settings.size||10;if(d.countChildRows&&k.push(p.cssChildRow),d.totalPages=Math.ceil(d.totalRows/r),p.totalRows=d.totalRows,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),x.$tbodies.eq(0).children("tr").detach(),e.totalRows=0;else{if(a.isArray(A)?(l=isNaN(A[0])&&!isNaN(A[1]),v=A[l?1:0],e.totalRows=isNaN(v)?e.totalRows||0:v,x.totalRows=x.filteredRows=e.filteredRows=e.totalRows,t=0===e.totalRows?[]:A[l?0:1]||[],s=A[2]):(e.ajaxData=A,x.totalRows=e.totalRows=A.total,x.filteredRows=e.filteredRows="undefined"!=typeof A.filteredRows?A.filteredRows:A.total,s=A.headers,t=A.rows||[]),u=t&&t.length,t instanceof jQuery)e.processAjaxOnInit&&(x.$tbodies.eq(0).children("tr").detach(),x.$tbodies.eq(0).append(t));else if(u){for(j=0;u>j;j++){for(z+="",k=0;k"+t[j][k]+"";z+=""}e.processAjaxOnInit&&x.$tbodies.eq(0).html(z)}if(e.processAjaxOnInit=!0,s&&s.length===B)for(m=y.hasClass("hasStickyHeaders"),o=m?x.widgetOptions.$sticky.children("thead:first").children("tr").children():"",n=y.find("tfoot tr:first").children(),p=x.$headers.filter("th "),w=p.length,k=0;w>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])}x.showProcessing&&b.isProcessing(d),e.totalPages=Math.ceil(e.totalRows/(e.size||e.settings.size||10)),e.last.totalRows=e.totalRows,e.last.currentFilters=e.currentFilters,e.last.sortList=(x.sortList||[]).join(","),g(d,e,!1),y.trigger("updateCache",[function(){e.initialized&&setTimeout(function(){x.debug&&console.log("Pager: Triggering pagerChange"),y.trigger("applyWidgets").trigger("pagerChange",e),g(d,e,!0)},0)}])}e.initialized||(e.initialized=!0,e.initializing=!1,d.config.debug&&console.log("Pager: Triggering pagerInitialized"),a(d).trigger("applyWidgets").trigger("pagerInitialized",e),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&&v(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(b,c){var d,f,g;for(c.ajax?e(c,!0):(c.isDisabled=!0,a.data(b,"pagerLastPage",c.page),a.data(b,"pagerLastSize",c.size),c.page=0,c.size=c.totalRows,c.totalPages=1,a(b).addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),p(b,b.config.rowsCopy,c),a(b).trigger("applyWidgets"),b.config.debug&&console.log("Pager: Disabled")),f=c.$size.add(c.$goto).add(c.$container.find(".ts-startRow, .ts-page")),g=f.length,d=0;g>d;d++)f.eq(d).attr("aria-disabled","true").addClass(c.cssDisabled)[0].disabled=!0},r=function(a){var b=a.config,c=b.pager;b.$table.trigger("updateCache",[function(){var d,e=[],f=a.config.cache[0].normalized;for(c.totalRows=f.length,d=0;dg-1&&0!==g&&(d.page=g-1),j.currentFilters=""===(j.currentFilters||[]).join("")?[]:j.currentFilters,d.currentFilters=""===(d.currentFilters||[]).join("")?[]:d.currentFilters,(j.page!==d.page||j.size!==d.size||j.totalRows!==d.totalRows||(j.currentFilters||[]).join(",")!==(d.currentFilters||[]).join(",")||(j.ajaxUrl||"")!==(d.ajaxObject.url||"")||(j.optAjaxUrl||"")!==(d.ajaxUrl||"")||j.sortList!==(h.sortList||[]).join(","))&&(h.debug&&console.log("Pager: Changing to page "+d.page),d.last={page:d.page,size:d.size,sortList:(h.sortList||[]).join(","),totalRows:d.totalRows,currentFilters:d.currentFilters||[],ajaxUrl:d.ajaxObject.url||"",optAjaxUrl:d.ajaxUrl||""},d.ajax?n(c,d):d.ajax||p(c,h.rowsCopy,d),a.data(c,"pagerLastPage",d.page),d.initialized&&e!==!1&&(h.debug&&console.log("Pager: Triggering pageMoved"),i.trigger("pageMoved",d).trigger("applyWidgets"),c.isUpdating&&(h.debug&&console.log("Pager: Triggering updateComplete"),i.trigger("updateComplete",[c,!0]))))))}},t=function(b,c,d){d.size=c||d.size||d.settings.size||10,d.$size.val(d.size),a.data(b,"pagerLastPage",d.page),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)},u=function(a,b){b.page=0,s(a,b)},v=function(a,b){b.page=Math.min(b.totalPages,b.filteredPages)-1,s(a,b)},w=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)},x=function(a,b){b.page--,b.page<=0&&(b.page=0),s(a,b)},y=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},z=function(b,c,d){var e,f=b.config;c.$size.add(c.$goto).add(c.$container.find(".ts-startRow, .ts-page")).removeClass(c.cssDisabled).removeAttr("disabled").attr("aria-disabled","false"),c.isDisabled=!1,c.page=a.data(b,"pagerLastPage")||c.page||0,c.size=a.data(b,"pagerLastSize")||parseInt(c.$size.find("option[selected]").val(),10)||c.size||c.settings.size||10,c.$size.val(c.size),c.totalPages=Math.ceil(Math.min(c.totalRows,c.filteredRows)/c.size),b.id&&(e=b.id+"_pager_info",c.$container.find(c.cssPageDisplay).attr("id",e),f.$table.attr("aria-describedby",e)),j(b,c),d&&(f.$table.trigger("updateRows"),t(b,c.size,c),l(b,c),f.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),A=n.$table,B=n.namespace+"pager",C=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+")"),A.unbind(c.split(" ").join(B+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(B+" "),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(B+" "),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),n.$table.trigger("applyWidgets"))}).bind("disablePager"+B,function(a){a.stopPropagation(),q(m,p)}).bind("enablePager"+B,function(a){a.stopPropagation(),z(m,p,!0)}).bind("destroyPager"+B,function(a){a.stopPropagation(),y(m,p)}).bind("updateComplete"+B,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&&v(b,p),k(b,p),j(b,p),g(b,p,!0)}}).bind("pageSize refreshComplete ".split(" ").join(B+" "),function(a,b){a.stopPropagation(),t(m,parseInt(b,10)||p.settings.size||10,p),k(m,p),g(m,p,!1)}).bind("pageSet pagerUpdate ".split(" ").join(B+" "),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"+B,function(a,b,c){a.stopPropagation(),p.page=(parseInt(b,10)||1)-1,t(m,parseInt(c,10)||p.settings.size||10,p),s(m,p,!0),k(m,p),g(m,p,!1)}),h=[p.cssFirst,p.cssPrev,p.cssNext,p.cssLast],i=[u,x,w,v],n.debug&&!C.length&&console.warn("Pager: >> Container not found"),C.find(h.join(",")).attr("tabindex",0).unbind("click"+B).bind("click"+B,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=C.find(p.cssGoto),p.$goto.length?p.$goto.unbind("change"+B).bind("change"+B,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=C.find(p.cssPageSize),p.$size.length?(p.$size.find("option").removeAttr("selected"),p.$size.unbind("change"+B).bind("change"+B,function(){return p.$size.val(a(this).val()),a(this).hasClass(p.cssDisabled)||(t(m,parseInt(a(this).val(),10),p),j(m,p)),!1})):n.debug&&console.warn("Pager: >> Size selector not found"),p.initialized=!1,A.trigger("pagerBeforeInitialized",p),z(m,p,!1),"string"==typeof p.ajaxUrl?(p.ajax=!0,n.widgetOptions.filter_serversideFiltering=!0,n.serverSideSorting=!0,s(m,p)):(p.ajax=!1,a(this).trigger("appendCache",!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 f4549096..1deac92d 100644 --- a/dist/js/widgets/widget-pager.min.js +++ b/dist/js/widgets/widget-pager.min.js @@ -1,2 +1,2 @@ /*! Widget: Pager - updated 8/17/2015 (v2.23.0) */ -!function(a){"use strict";var b,c=a.tablesorter;c.addWidget({id:"pager",priority:55,options:{pager_output:"{startRow} to {endRow} of {totalRows} rows",pager_updateArrows:!0,pager_startPage:0,pager_pageReset:0,pager_size:10,pager_maxOptionSize:20,pager_savePages:!0,pager_storageKey:"tablesorter-pager",pager_fixedHeight:!1,pager_countChildRows:!1,pager_removeRows:!1,pager_ajaxUrl:null,pager_customAjaxUrl:function(a,b){return b},pager_ajaxError:null,pager_ajaxObject:{dataType:"json"},pager_processAjaxOnInit:!0,pager_ajaxProcessing:function(a){return[0,[],null]},pager_css:{container:"tablesorter-pager",errorRow:"tablesorter-errorRow",disabled:"disabled"},pager_selectors:{container:".pager",first:".first",prev:".prev",next:".next",last:".last",gotoPage:".gotoPage",pageDisplay:".pagedisplay",pageSize:".pagesize"}},init:function(a){b.init(a)},format:function(a,c){return c.pager&&c.pager.initialized?void b.moveToPage(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.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,f.$table.trigger("appendCache",[{},!0])))}},initComplete:function(a,d){var e=d.pager;b.bindEvents(a,d),b.setPageSize(a,0,d),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(c,d){var e,f,g=d.pager,h=d.widgetOptions,i=d.namespace+"pager",j=h.pager_selectors;d.$table.off(i).on("filterInit filterStart ".split(" ").join(i+" "),function(b,c){g.currentFilters=a.isArray(c)?c:d.$table.data("lastSearch"),"filterStart"===b.type&&h.pager_pageReset!==!1&&(d.lastCombinedFilter||"")!==(g.currentFilters||[]).join("")&&(g.page=h.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(i+" "),function(){g.currentFilters=d.$table.data("lastSearch"),(g.initialized||g.initializing)&&(d.delayInit&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(c),b.updatePageDisplay(c,d,!1),d.$table.trigger("applyWidgets"))}).on("disablePager"+i,function(a){a.stopPropagation(),b.showAllRows(c,d)}).on("enablePager"+i,function(a){a.stopPropagation(),b.enablePager(c,d,!0)}).on("destroyPager"+i,function(a,e){a.stopPropagation(),b.destroyPager(c,d,e)}).on("updateComplete"+i,function(a,c,e){if(a.stopPropagation(),c&&!e&&!g.ajax){var f=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);g.totalRows=f.length-(h.pager_countChildRows?0:f.filter("."+d.cssChildRow).length),g.totalPages=Math.ceil(g.totalRows/g.size),f.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(c),g.page>=g.totalPages&&b.moveToLastPage(c,g),b.hideRows(c,d),b.changeHeight(c,d),b.updatePageDisplay(c,d,!1),d.$table.trigger("applyWidgets"),b.updatePageDisplay(c,d)}}).on("pageSize refreshComplete ".split(" ").join(i+" "),function(a,e){a.stopPropagation(),b.setPageSize(c,parseInt(e,10)||g.setSize||10,d),b.hideRows(c,d),b.updatePageDisplay(c,d,!1)}).on("pageSet pagerUpdate ".split(" ").join(i+" "),function(a,e){a.stopPropagation(),"pagerUpdate"===a.type&&(e="undefined"==typeof e?g.page+1:e,g.last.page=!0),g.page=(parseInt(e,10)||1)-1,b.moveToPage(c,g,!0),b.updatePageDisplay(c,d,!1)}).on("pageAndSize"+i,function(a,e,f){a.stopPropagation(),g.page=(parseInt(e,10)||1)-1,b.setPageSize(c,parseInt(f,10)||g.setSize||10,d),b.moveToPage(c,g,!0),b.hideRows(c,d),b.updatePageDisplay(c,d,!1)}),e=[j.first,j.prev,j.next,j.last],f=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],d.debug&&!g.$container.length&&console.warn("Pager: >> Container not found"),g.$container.find(e.join(",")).attr("tabindex",0).off("click"+i).on("click"+i,function(d){d.stopPropagation();var i,j=a(this),k=e.length;if(!j.hasClass(h.pager_css.disabled))for(i=0;k>i;i++)if(j.is(e[i])){b[f[i]](c,g);break}}),g.$goto.length?g.$goto.off("change"+i).on("change"+i,function(){g.page=a(this).val()-1,b.moveToPage(c,g,!0),b.updatePageDisplay(c,d,!1)}):d.debug&&console.warn("Pager: >> Goto selector not found"),g.$size.length?(g.$size.find("option").removeAttr("selected"),g.$size.off("change"+i).on("change"+i,function(){return g.$size.val(a(this).val()),a(this).hasClass(h.pager_css.disabled)||(b.setPageSize(c,parseInt(a(this).val(),10),d),b.changeHeight(c,d)),!1})):d.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,c){var d,e,f,g=c.widgetOptions,h=c.pager,i=c.$table.hasClass("hasFilters");if(i&&!g.pager_ajaxUrl)if(a.isEmptyObject(c.cache))h.filteredRows=h.totalRows=c.$tbodies.eq(0).children("tr").not(g.pager_countChildRows?"":"."+c.cssChildRow).length;else for(h.filteredRows=0,d=c.cache[0].normalized,f=d.length,e=0;f>e;e++)h.filteredRows+=h.regexRows.test(d[e][c.columns].$row[0].className)?0:1;else i||(h.filteredRows=h.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=n.size||n.setSize||10;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.calcFilters(d,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),c.showError(e,g,h),f.$tbodies.eq(0).children("tr").detach(),i.totalRows=0;else{if(a.isArray(A)?(m=isNaN(A[0])&&!isNaN(A[1]),w=A[m?1:0],i.totalRows=isNaN(w)?i.totalRows||0:w,f.totalRows=f.filteredRows=i.filteredRows=i.totalRows,u=0===i.totalRows?[]:A[m?0:1]||[],t=A[2]):(i.ajaxData=A,f.totalRows=i.totalRows=A.total,f.filteredRows=i.filteredRows="undefined"!=typeof A.filteredRows?A.filteredRows:A.total,t=A.headers,u=A.rows||[]),v=u&&u.length,u instanceof jQuery)j.pager_processAjaxOnInit&&(f.$tbodies.eq(0).children("tr").detach(),f.$tbodies.eq(0).append(u));else if(v){for(k=0;v>k;k++){for(z+="",l=0;l"+u[k][l]+"";z+=""}j.pager_processAjaxOnInit&&f.$tbodies.eq(0).html(z)}if(j.pager_processAjaxOnInit=!0,t&&t.length===B)for(n=y.hasClass("hasStickyHeaders"),p=n?j.$sticky.children("thead:first").children("tr").children():"",o=y.find("tfoot tr:first").children(),q=f.$headers.filter("th "),x=q.length,l=0;x>l;l++)r=q.eq(l),r.find("."+c.css.icon).length?(s=r.find("."+c.css.icon).clone(!0),r.find(".tablesorter-header-inner").html(t[l]).append(s),n&&p.length&&(s=p.eq(l).find("."+c.css.icon).clone(!0),p.eq(l).find(".tablesorter-header-inner").html(t[l]).append(s))):(r.find(".tablesorter-header-inner").html(t[l]),n&&p.length&&p.eq(l).find(".tablesorter-header-inner").html(t[l])),o.eq(l).html(t[l])}f.showProcessing&&c.isProcessing(e),i.totalPages=Math.ceil(i.totalRows/(i.size||i.setSize||10)),i.last.totalRows=i.totalRows,i.last.currentFilters=i.currentFilters,i.last.sortList=(f.sortList||[]).join(","),i.initializing=!1,b.updatePageDisplay(e,f,!1),y.trigger("updateCache",[function(){i.initialized&&setTimeout(function(){f.debug&&console.log("Pager: Triggering pagerChange"),y.trigger("applyWidgets").trigger("pagerChange",i),b.updatePageDisplay(e,f)},0)}])}i.initialized||f.$table.trigger("applyWidgets")},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,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(c,d){var e,f,g,h=d.pager,i=d.widgetOptions;for(h.ajax?b.pagerArrows(d,!0):(h.isDisabled=!0,a.data(c,"pagerLastPage",h.page),a.data(c,"pagerLastSize",h.size),h.page=0,h.size=h.totalRows,h.totalPages=1,d.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(c,d.rowsCopy),d.$table.trigger("applyWidgets"),d.debug&&console.log("Pager: Disabled")),f=h.$size.add(h.$goto).add(h.$container.find(".ts-startRow, .ts-page ")),g=f.length,e=0;g>e;e++)f.eq(e).attr("aria-disabled","true").addClass(i.pager_css.disabled)[0].disabled=!0},updateCache:function(c){var d=c.config,e=d.pager;d.$table.trigger("updateCache",[function(){if(!a.isEmptyObject(c.config.cache)){var f,g=[],h=c.config.cache[0].normalized;for(e.totalRows=h.length,f=0;fg-1&&0!==g&&(e.page=g-1),j.currentFilters=""===(j.currentFilters||[]).join("")?[]:j.currentFilters,e.currentFilters=""===(e.currentFilters||[]).join("")?[]:e.currentFilters,(j.page!==e.page||j.size!==e.size||j.totalRows!==e.totalRows||(j.currentFilters||[]).join(",")!==(e.currentFilters||[]).join(",")||(j.ajaxUrl||"")!==(e.ajaxObject.url||"")||(j.optAjaxUrl||"")!==(i.pager_ajaxUrl||"")||j.sortList!==(h.sortList||[]).join(","))&&(h.debug&&console.log("Pager: Changing to page "+e.page),e.last={page:e.page,size:e.size,sortList:(h.sortList||[]).join(","),totalRows:e.totalRows,currentFilters:e.currentFilters||[],ajaxUrl:e.ajaxObject.url||"",optAjaxUrl:i.pager_ajaxUrl},e.ajax?b.getAjax(d,h):e.ajax||b.renderTable(d,h.rowsCopy),a.data(d,"pagerLastPage",e.page),e.initialized&&f!==!1&&(h.debug&&console.log("Pager: Triggering pageMoved"),h.$table.trigger("pageMoved",h).trigger("applyWidgets"),!e.ajax&&d.isUpdating&&(h.debug&&console.log("Pager: Triggering updateComplete"),h.$table.trigger("updateComplete",[d,!0])))))}},setPageSize:function(c,d,e){var f=e.pager;f.size=d||f.size||f.setSize||10,f.$size.val(f.size),a.data(c,"pagerLastPage",f.page),a.data(c,"pagerLastSize",f.size),f.totalPages=Math.ceil(f.totalRows/f.size),f.filteredPages=Math.ceil(f.filteredRows/f.size),b.moveToPage(c,f,!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(c,d,e){var f,g=d.pager;g.isDisabled=!1,g.page=a.data(c,"pagerLastPage")||g.page||0,g.size=a.data(c,"pagerLastSize")||parseInt(g.$size.find("option[selected]").val(),10)||g.size||g.setSize||10,g.$size.val(g.size),g.totalPages=Math.ceil(Math.min(g.totalRows,g.filteredRows)/g.size),d.$table.removeClass("pagerDisabled"),c.id&&(f=c.id+"_pager_info",g.$container.find(d.widgetOptions.pager_selectors.pageDisplay).attr("id",f),d.$table.attr("aria-describedby",f)),b.changeHeight(c,d),e&&(d.$table.trigger("updateRows"),b.setPageSize(c,g.size,d),b.hideRowsSetup(c,d),d.debug&&console.log("Pager: Enabled"))},appender:function(c,d){var e=c.config,f=e.widgetOptions,g=e.pager;g.ajax?b.moveToPage(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){var e,f=a(b),g=f[0].config,h=g&&g.widgetOptions,i=g.pager&&g.pager.cssErrorRow||h.pager_css&&h.pager_css.errorRow||"tablesorter-errorRow",j=typeof c,k=!0,l="",m=function(){g.$table.find("thead").find("."+i).remove()};if(!f.length)return void console.error("tablesorter showError: no table parameter passed");if("string"!==j)if("function"==typeof g.pager.ajaxError){if(k=g.pager.ajaxError(g,c,d),k===!1)return m();l=k}else if("function"==typeof h.pager_ajaxError){if(k=h.pager_ajaxError(g,c,d),k===!1)return m();l=k}else l=0===c.status?"Not connected, verify Network":404===c.status?"Requested page not found [404]":500===c.status?"Internal Server Error [500]":"parsererror"===d?"Requested JSON parse failed":"timeout"===d?"Time out error":"abort"===d?"Ajax Request aborted":"Uncaught error: "+c.statusText+" ["+c.status+"]";else"undefined"!==j&&(l=c);return""===l?m():void(e=a(/tr\>/.test(l)?l:''+l+"").click(function(){a(this).remove()}).appendTo(g.$table.find("thead:first")).addClass(i+" "+g.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.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,f.$table.trigger("appendCache",[{},!0])))}},initComplete:function(a,d){var e=d.pager;b.bindEvents(a,d),b.setPageSize(a,0,d),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(c,d){var e,f,g=d.pager,h=d.widgetOptions,i=d.namespace+"pager",j=h.pager_selectors;d.$table.off(i).on("filterInit filterStart ".split(" ").join(i+" "),function(b,c){g.currentFilters=a.isArray(c)?c:d.$table.data("lastSearch"),"filterStart"===b.type&&h.pager_pageReset!==!1&&(d.lastCombinedFilter||"")!==(g.currentFilters||[]).join("")&&(g.page=h.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(i+" "),function(){g.currentFilters=d.$table.data("lastSearch"),(g.initialized||g.initializing)&&(d.delayInit&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(c),b.updatePageDisplay(c,d,!1),d.$table.trigger("applyWidgets"))}).on("disablePager"+i,function(a){a.stopPropagation(),b.showAllRows(c,d)}).on("enablePager"+i,function(a){a.stopPropagation(),b.enablePager(c,d,!0)}).on("destroyPager"+i,function(a,e){a.stopPropagation(),b.destroyPager(c,d,e)}).on("updateComplete"+i,function(a,c,e){if(a.stopPropagation(),c&&!e&&!g.ajax){var f=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);g.totalRows=f.length-(h.pager_countChildRows?0:f.filter("."+d.cssChildRow).length),g.totalPages=Math.ceil(g.totalRows/g.size),f.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(c),g.page>=g.totalPages&&b.moveToLastPage(c,g),b.hideRows(c,d),b.changeHeight(c,d),b.updatePageDisplay(c,d,!1),d.$table.trigger("applyWidgets"),b.updatePageDisplay(c,d)}}).on("pageSize refreshComplete ".split(" ").join(i+" "),function(a,e){a.stopPropagation(),b.setPageSize(c,parseInt(e,10)||g.setSize||10,d),b.hideRows(c,d),b.updatePageDisplay(c,d,!1)}).on("pageSet pagerUpdate ".split(" ").join(i+" "),function(a,e){a.stopPropagation(),"pagerUpdate"===a.type&&(e="undefined"==typeof e?g.page+1:e,g.last.page=!0),g.page=(parseInt(e,10)||1)-1,b.moveToPage(c,g,!0),b.updatePageDisplay(c,d,!1)}).on("pageAndSize"+i,function(a,e,f){a.stopPropagation(),g.page=(parseInt(e,10)||1)-1,b.setPageSize(c,parseInt(f,10)||g.setSize||10,d),b.moveToPage(c,g,!0),b.hideRows(c,d),b.updatePageDisplay(c,d,!1)}),e=[j.first,j.prev,j.next,j.last],f=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],d.debug&&!g.$container.length&&console.warn("Pager: >> Container not found"),g.$container.find(e.join(",")).attr("tabindex",0).off("click"+i).on("click"+i,function(d){d.stopPropagation();var i,j=a(this),k=e.length;if(!j.hasClass(h.pager_css.disabled))for(i=0;k>i;i++)if(j.is(e[i])){b[f[i]](c,g);break}}),g.$goto.length?g.$goto.off("change"+i).on("change"+i,function(){g.page=a(this).val()-1,b.moveToPage(c,g,!0),b.updatePageDisplay(c,d,!1)}):d.debug&&console.warn("Pager: >> Goto selector not found"),g.$size.length?(g.$size.find("option").removeAttr("selected"),g.$size.off("change"+i).on("change"+i,function(){return g.$size.val(a(this).val()),a(this).hasClass(h.pager_css.disabled)||(b.setPageSize(c,parseInt(a(this).val(),10),d),b.changeHeight(c,d)),!1})):d.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,c){var d,e,f,g=c.widgetOptions,h=c.pager,i=c.$table.hasClass("hasFilters");if(i&&!g.pager_ajaxUrl)if(a.isEmptyObject(c.cache))h.filteredRows=h.totalRows=c.$tbodies.eq(0).children("tr").not(g.pager_countChildRows?"":"."+c.cssChildRow).length;else for(h.filteredRows=0,d=c.cache[0].normalized,f=d.length,e=0;f>e;e++)h.filteredRows+=h.regexRows.test(d[e][c.columns].$row[0].className)?0:1;else i||(h.filteredRows=h.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=n.size||n.setSize||10;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.calcFilters(d,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).children("tr").detach(),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/(j.size||j.setSize||10)),j.last.totalRows=j.totalRows,j.last.currentFilters=j.currentFilters,j.last.sortList=(f.sortList||[]).join(","),j.initializing=!1,b.updatePageDisplay(e,f,!1),z.trigger("updateCache",[function(){j.initialized&&setTimeout(function(){f.debug&&console.log("Pager: Triggering pagerChange"),z.trigger("applyWidgets").trigger("pagerChange",j),b.updatePageDisplay(e,f)},0)}])}j.initialized||f.$table.trigger("applyWidgets")},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(c,d){var e,f,g,h=d.pager,i=d.widgetOptions;for(h.ajax?b.pagerArrows(d,!0):(h.isDisabled=!0,a.data(c,"pagerLastPage",h.page),a.data(c,"pagerLastSize",h.size),h.page=0,h.size=h.totalRows,h.totalPages=1,d.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(c,d.rowsCopy),d.$table.trigger("applyWidgets"),d.debug&&console.log("Pager: Disabled")),f=h.$size.add(h.$goto).add(h.$container.find(".ts-startRow, .ts-page ")),g=f.length,e=0;g>e;e++)f.eq(e).attr("aria-disabled","true").addClass(i.pager_css.disabled)[0].disabled=!0},updateCache:function(c){var d=c.config,e=d.pager;d.$table.trigger("updateCache",[function(){if(!a.isEmptyObject(c.config.cache)){var f,g=[],h=c.config.cache[0].normalized;for(e.totalRows=h.length,f=0;fg-1&&0!==g&&(e.page=g-1),j.currentFilters=""===(j.currentFilters||[]).join("")?[]:j.currentFilters,e.currentFilters=""===(e.currentFilters||[]).join("")?[]:e.currentFilters,(j.page!==e.page||j.size!==e.size||j.totalRows!==e.totalRows||(j.currentFilters||[]).join(",")!==(e.currentFilters||[]).join(",")||(j.ajaxUrl||"")!==(e.ajaxObject.url||"")||(j.optAjaxUrl||"")!==(i.pager_ajaxUrl||"")||j.sortList!==(h.sortList||[]).join(","))&&(h.debug&&console.log("Pager: Changing to page "+e.page),e.last={page:e.page,size:e.size,sortList:(h.sortList||[]).join(","),totalRows:e.totalRows,currentFilters:e.currentFilters||[],ajaxUrl:e.ajaxObject.url||"",optAjaxUrl:i.pager_ajaxUrl},e.ajax?b.getAjax(d,h):e.ajax||b.renderTable(d,h.rowsCopy),a.data(d,"pagerLastPage",e.page),e.initialized&&f!==!1&&(h.debug&&console.log("Pager: Triggering pageMoved"),h.$table.trigger("pageMoved",h).trigger("applyWidgets"),!e.ajax&&d.isUpdating&&(h.debug&&console.log("Pager: Triggering updateComplete"),h.$table.trigger("updateComplete",[d,!0])))))}},setPageSize:function(c,d,e){var f=e.pager;f.size=d||f.size||f.setSize||10,f.$size.val(f.size),a.data(c,"pagerLastPage",f.page),a.data(c,"pagerLastSize",f.size),f.totalPages=Math.ceil(f.totalRows/f.size),f.filteredPages=Math.ceil(f.filteredRows/f.size),b.moveToPage(c,f,!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(c,d,e){var f,g=d.pager;g.isDisabled=!1,g.page=a.data(c,"pagerLastPage")||g.page||0,g.size=a.data(c,"pagerLastSize")||parseInt(g.$size.find("option[selected]").val(),10)||g.size||g.setSize||10,g.$size.val(g.size),g.totalPages=Math.ceil(Math.min(g.totalRows,g.filteredRows)/g.size),d.$table.removeClass("pagerDisabled"),c.id&&(f=c.id+"_pager_info",g.$container.find(d.widgetOptions.pager_selectors.pageDisplay).attr("id",f),d.$table.attr("aria-describedby",f)),b.changeHeight(c,d),e&&(d.$table.trigger("updateRows"),b.setPageSize(c,g.size,d),b.hideRowsSetup(c,d),d.debug&&console.log("Pager: Enabled"))},appender:function(c,d){var e=c.config,f=e.widgetOptions,g=e.pager;g.ajax?b.moveToPage(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/docs/example-pager-ajax.html b/docs/example-pager-ajax.html index 4f0f9f7f..f0b8ebe5 100644 --- a/docs/example-pager-ajax.html +++ b/docs/example-pager-ajax.html @@ -69,6 +69,11 @@ return url; }, + // ajax error callback from $.tablesorter.showError function + // ajaxError: function( config, xhr, settings, exception ){ return exception; }; + // returning false will abort the error message + ajaxError: null, + // add more ajax settings here // see http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings ajaxObject: { diff --git a/docs/example-pager.html b/docs/example-pager.html index 9ef7ab5e..a6486f6d 100644 --- a/docs/example-pager.html +++ b/docs/example-pager.html @@ -38,6 +38,11 @@ // modify the url after all processing has been applied customAjaxUrl: function(table, url) { return url; }, + // ajax error callback from $.tablesorter.showError function + // ajaxError: function( config, xhr, settings, exception ){ return exception; }; + // returning false will abort the error message + ajaxError: null, + // add more ajax settings here // see http://api.jquery.com/jQuery.ajax/#jQuery-ajax-settings ajaxObject: { dataType: 'json' }, diff --git a/docs/example-widget-pager-ajax.html b/docs/example-widget-pager-ajax.html index b55ed122..5537d948 100644 --- a/docs/example-widget-pager-ajax.html +++ b/docs/example-widget-pager-ajax.html @@ -80,6 +80,11 @@ return url; }, + // ajax error callback from $.tablesorter.showError function + // pager_ajaxError: function( config, xhr, settings, exception ){ return exception; }; + // returning false will abort the error message + pager_ajaxError: null, + // modify the $.ajax object to allow complete control over your ajax requests pager_ajaxObject: { dataType: 'json' diff --git a/docs/example-widget-pager.html b/docs/example-widget-pager.html index 78528487..18d0e90b 100644 --- a/docs/example-widget-pager.html +++ b/docs/example-widget-pager.html @@ -73,6 +73,11 @@ // modify the url after all processing has been applied pager_customAjaxUrl: function(table, url) { return url; }, + // ajax error callback from $.tablesorter.showError function + // pager_ajaxError: function( config, xhr, settings, exception ){ return exception; }; + // returning false will abort the error message + pager_ajaxError: null, + // modify the $.ajax object to allow complete control over your ajax requests pager_ajaxObject: { dataType: 'json' diff --git a/docs/index.html b/docs/index.html index fa71e559..626feafe 100644 --- a/docs/index.html +++ b/docs/index.html @@ -3832,9 +3832,14 @@ $('table').trigger('search', false); Function null - This callback allows you to customize the error message displayed in the thead (v2.23.0). + This callback allows you to customize the error message displayed in the thead (v2.23.0; v2.23.1).

+ In v2.23.1 +
    +
  • A settings parameter was added before the exception parameter to exactly match the parameters returned by the jQuery .ajaxError() method.
  • +
  • This function is now always called, even if the $.tablesorter.showError function is called by an external function with only a string.
  • +
Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_ajaxError

When there is an ajax error, the $.tablesorter.showError function is called. In v2.23.0, that function now checks this callback to allow adding a custom error message.
@@ -3844,7 +3849,7 @@ $('table').trigger('search', false);
$("table") .tablesorter() .tablesorterPager({ - ajaxError: function( config, xhr, exception ) { + ajaxError: function( config, xhr, settings, exception ) { // returning false will abort the error message // the code below is the default behavior when this callback is set to `null` return @@ -6960,12 +6965,14 @@ $.tablesorter.isDigit( "(2,345.67)" ); This function allows adding/removing a row to the thead, to display any errors (v2.15; v2.23.0).

This function is ONLY included within the widget-pager.js and jquery.tablesorter.pager.js files; in version 3+, I plan to add it as a selectable option in a build.

+

In v2.23.1, a settings parameter was included to make it match the parametered returned by the jQuery .ajaxError() method.

In v2.23.0, this function will accept xhr and exception parameters provided by ajax error messages. To maintain backward compatibility, if xhr is a string, it will be treated as previous message parameter and displayed in the error row without modification.

Use it as follows: -
$.tablesorter.showError( table, xhr, exception );
+
$.tablesorter.showError( table, xhr, settings, exception );
  • table - table DOM element (or jQuery object) of the table.
  • xhr - a plain string, string of an HTML row, or the XMLHttpRequest (XHR) object from ajax error message.
  • +
  • settings - a plain object containing the ajax settings, as returned by the ajaxError method.
  • exception - exception string passed from the ajax error message.
This function will add a table row to the thead, with a class name from either the pager plugin cssErrorRow option setting, or the pager widget pager_css.errorRow option (the default class name is "tablesorter-errorRow"; and styled within each theme css file). diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index a5a8c1bb..e70fc620 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -63,7 +63,7 @@ pager_customAjaxUrl: function(table, url) { return url; }, // ajax error callback from $.tablesorter.showError function - // pager_ajaxError: function( config, xhr, exception ){ return exception; }; + // pager_ajaxError: function( config, xhr, settings, exception ){ return exception; }; // returning false will abort the error message pager_ajaxError: null, @@ -645,7 +645,7 @@ } }, - renderAjax: function(data, table, c, xhr, exception){ + renderAjax: function(data, table, c, xhr, settings, exception) { var p = c.pager, wo = c.widgetOptions; // process data @@ -662,9 +662,9 @@ if ( exception ) { if (c.debug) { - console.error('Pager: >> Ajax Error', xhr, exception); + console.error('Pager: >> Ajax Error', xhr, settings, exception); } - ts.showError( table, xhr, exception ); + ts.showError( table, xhr, settings, exception ); c.$tbodies.eq(0).children('tr').detach(); p.totalRows = 0; } else { @@ -782,7 +782,7 @@ ts.isProcessing(table, true); // show loading icon } $doc.on('ajaxError' + namespace, function(e, xhr, settings, exception) { - tsp.renderAjax(null, table, c, xhr, exception); + tsp.renderAjax(null, table, c, xhr, settings, exception); $doc.off('ajaxError' + namespace); }); counter = ++p.ajaxCounter; @@ -1142,12 +1142,14 @@ }; // see #486 - ts.showError = function( table, xhr, exception ) { + ts.showError = function( table, xhr, settings, exception ) { var $row, $table = $( table ), c = $table[0].config, wo = c && c.widgetOptions, - errorRow = c.pager && c.pager.cssErrorRow || wo.pager_css && wo.pager_css.errorRow || 'tablesorter-errorRow', + errorRow = c.pager && c.pager.cssErrorRow || + wo && wo.pager_css && wo.pager_css.errorRow || + 'tablesorter-errorRow', typ = typeof xhr, valid = true, message = '', @@ -1160,23 +1162,25 @@ return; } - if ( typ !== 'string' ) { - // ajaxError callback for plugin or widget - see #992 - if ( typeof c.pager.ajaxError === 'function' ) { - valid = c.pager.ajaxError( c, xhr, exception ); - if ( valid === false ) { - return removeRow(); - } else { - message = valid; - } - } else if ( typeof wo.pager_ajaxError === 'function' ) { - valid = wo.pager_ajaxError( c, xhr, exception ); - if ( valid === false ) { - return removeRow(); - } else { - message = valid; - } + // ajaxError callback for plugin or widget - see #992 + if ( typeof c.pager.ajaxError === 'function' ) { + valid = c.pager.ajaxError( c, xhr, settings, exception ); + if ( valid === false ) { + return removeRow(); } else { + message = valid; + } + } else if ( typeof wo.pager_ajaxError === 'function' ) { + valid = wo.pager_ajaxError( c, xhr, settings, exception ); + if ( valid === false ) { + return removeRow(); + } else { + message = valid; + } + } + + if ( message === '' ) { + if ( typ === 'object' ) { message = xhr.status === 0 ? 'Not connected, verify Network' : xhr.status === 404 ? 'Requested page not found [404]' : @@ -1185,18 +1189,16 @@ exception === 'timeout' ? 'Time out error' : exception === 'abort' ? 'Ajax Request aborted' : 'Uncaught error: ' + xhr.statusText + ' [' + xhr.status + ']'; + } else if ( typ === 'string' ) { + // keep backward compatibility (external usage just passes a message string) + message = xhr; + } else { + // remove all error rows + return removeRow(); } - } else if ( typ !== 'undefined' ) { - // keep backward compatibility (external usage just passes a message string) - message = xhr; } - if ( message === '' ) { - // remove all error rows - return removeRow(); - } - - // allow message to include HTML (must include entire row!) + // allow message to include entire row HTML! $row = ( /tr\>/.test(message) ? $(message) : $('' + message + '') ) .click( function() { $( this ).remove();