diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index 60ac5964..95658442 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -508,14 +508,7 @@ } if (!p.initialized) { - p.initialized = true; - p.initializing = false; - if (table.config.debug) { - console.log('Pager: Triggering pagerInitialized'); - } - $(table).triggerHandler( 'pagerInitialized', p ); - ts.applyWidget( table ); - updatePageDisplay(table, p); + pagerInitialized(table, p); } }, @@ -711,7 +704,8 @@ moveToPage = function(table, p, pageMoved) { if ( p.isDisabled ) { return; } - var c = table.config, + var tmp, + c = table.config, $t = $(table), l = p.last; if ( pageMoved !== false && p.initialized && ts.isEmptyObject(c.cache)) { @@ -747,7 +741,17 @@ optAjaxUrl : p.ajaxUrl || '' }; if (p.ajax) { - getAjax(table, p); + if ( !p.processAjaxOnInit && !ts.isEmptyObject(p.initialRows) ) { + p.processAjaxOnInit = true; + tmp = p.initialRows; + p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total : + ( c.debug ? console.error('Pager: no initial total page set!') || 0 : 0 ); + p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered : + ( c.debug ? console.error('Pager: no initial filtered page set!') || 0 : 0 ); + pagerInitialized( table, p ); + } else { + getAjax(table, p); + } } else if (!p.ajax) { renderTable(table, c.rowsCopy, p); } @@ -827,6 +831,17 @@ moveToPage(table, p); }, + pagerInitialized = function(table, p) { + p.initialized = true; + p.initializing = false; + if (table.config.debug) { + console.log('Pager: Triggering pagerInitialized'); + } + $(table).triggerHandler( 'pagerInitialized', p ); + ts.applyWidget( table ); + updatePageDisplay(table, p); + }, + destroyPager = function(table, p) { var c = table.config, namespace = c.namespace + 'pager', diff --git a/dist/js/extras/jquery.tablesorter.pager.min.js b/dist/js/extras/jquery.tablesorter.pager.min.js index 3f41f811..e73a5ed4 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/22/2015 (v2.24.6) */ -!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.triggerHandler("pageSet"+q,[c])}))}e(c,d),i(c,d),d.initialized&&g!==!1&&(p.debug&&console.log("Pager: Triggering pagerComplete"),p.$table.triggerHandler("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.triggerHandler("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).triggerHandler("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.triggerHandler("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.triggerHandler("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&&c>=0&&(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.triggerHandler("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.triggerHandler("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.triggerHandler("pageSet"+q,[c])}))}e(c,d),i(c,d),d.initialized&&g!==!1&&(p.debug&&console.log("Pager: Triggering pagerComplete"),p.$table.triggerHandler("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(C)?(l=isNaN(C[0])&&!isNaN(C[1]),w=C[l?1:0],e.totalRows=isNaN(w)?e.totalRows||0:w,y.totalRows=y.filteredRows=e.filteredRows=e.totalRows,t=0===e.totalRows?[]:C[l?0:1]||[],s=C[2]):(e.ajaxData=C,y.totalRows=e.totalRows=C.total,y.filteredRows=e.filteredRows="undefined"!=typeof C.filteredRows?C.filteredRows:C.total,s=C.headers,t=C.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===D)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.triggerHandler("pagerChange",e),b.applyWidget(d),g(d,e,!0)},0)})}e.initialized||B(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.triggerHandler("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.triggerHandler("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&&c>=0&&(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(c,d){d.initialized=!0,d.initializing=!1,c.config.debug&&console.log("Pager: Triggering pagerInitialized"),a(c).triggerHandler("pagerInitialized",d),b.applyWidget(c),g(c,d)},C=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},D=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",B=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(),D(m,p,!0)}).bind("destroyPager"+v,function(a){a.stopPropagation(),C(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&&!B.length&&console.warn("Pager: >> Container not found"),B.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=B.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=B.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.triggerHandler("pagerBeforeInitialized",p),D(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.triggerHandler("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 4ce0c4ae..91080a8d 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/22/2015 (v2.24.6) */ -!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(c,c.pager,!1):b.initComplete(c)},remove:function(a,c,d,e){b.destroyPager(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.triggerHandler("pagerBeforeInitialized",f),b.enablePager(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(f,i)):(i.ajax=!1,c.appendCache(f,!0)))}},initComplete:function(a){var d=a.pager;b.bindEvents(a),b.setPageSize(a,0),d.ajax||b.hideRowsSetup(a),d.initialized=!0,d.initializing=!1,d.isInitializing=!1,a.debug&&console.log("Pager: Triggering pagerInitialized"),a.$table.triggerHandler("pagerInitialized",a),a.widgetOptions.filter_initialized&&c.hasWidget(a.table,"filter")||b.updatePageDisplay(a,!d.ajax)},bindEvents:function(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(d),b.updatePageDisplay(d,!1),c.applyWidget(d.table))}).on("disablePager"+i,function(a){a.stopPropagation(),b.showAllRows(d)}).on("enablePager"+i,function(a){a.stopPropagation(),b.enablePager(d,!0)}).on("destroyPager"+i,function(a,b){a.stopPropagation(),c.removeWidget(d.table,"pager",!1)}).on("updateComplete"+i,function(a,e,f){if(a.stopPropagation(),e&&!f&&!g.ajax){var i=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);g.totalRows=i.length-(h.pager_countChildRows?0:i.filter("."+d.cssChildRow).length),g.totalPages=Math.ceil(g.totalRows/g.size),i.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),g.page>=g.totalPages&&b.moveToLastPage(d,g),b.hideRows(d),b.changeHeight(d),b.updatePageDisplay(d,!1),c.applyWidget(e),b.updatePageDisplay(d)}}).on("pageSize refreshComplete ".split(" ").join(i+" "),function(a,c){a.stopPropagation(),b.setPageSize(d,b.parsePageSize(d,c,"get")),b.hideRows(d),b.updatePageDisplay(d,!1)}).on("pageSet pagerUpdate ".split(" ").join(i+" "),function(a,c){a.stopPropagation(),"pagerUpdate"===a.type&&(c="undefined"==typeof c?g.page+1:c,g.last.page=!0),g.page=(parseInt(c,10)||1)-1,b.moveToPage(d,g,!0),b.updatePageDisplay(d,!1)}).on("pageAndSize"+i,function(a,c,e){a.stopPropagation(),g.page=(parseInt(c,10)||1)-1,b.setPageSize(d,b.parsePageSize(d,e,"get")),b.moveToPage(d,g,!0),b.hideRows(d),b.updatePageDisplay(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(c){c.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]](d,g);break}}),g.$goto.length?g.$goto.off("change"+i).on("change"+i,function(){g.page=a(this).val()-1,b.moveToPage(d,g,!0),b.updatePageDisplay(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(){if(!a(this).hasClass(h.pager_css.disabled)){var c=a(this).val();g.$size.val(c),b.setPageSize(d,c),b.changeHeight(d)}return!1})):d.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){if(!d.pager.initializing){var f,g,h,i,j,k,l=d.table,m=d.widgetOptions,n=d.pager,o=d.namespace+"pager",p=b.parsePageSize(d,n.size,"get");if(m.pager_countChildRows&&g.push(d.cssChildRow),n.$size.add(n.$goto).removeClass(m.pager_css.disabled).removeAttr("disabled").attr("aria-disabled","false"),n.totalPages=Math.ceil(n.totalRows/p),d.totalRows=n.totalRows,b.parsePageNumber(d,n),b.calcFilters(d),d.filteredRows=n.filteredRows,n.filteredPages=Math.ceil(n.filteredRows/p)||0,b.getTotalPages(d,n)>=0){if(g=n.size*n.page>n.filteredRows&&e,n.page=g?m.pager_pageReset||0:n.page,n.startRow=g?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)),h=n.$container.find(m.pager_selectors.pageDisplay),f=(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(g="",i=b.buildPageSelect(d,n),k=i.length,j=0;k>j;j++)g+='";n.$goto.html(g).val(n.page+1)}h.length&&(h["INPUT"===h[0].nodeName?"val":"html"](f),h.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;d.$table.triggerHandler("pageSet"+o,[c])}))}b.pagerArrows(d),b.fixHeight(d),n.initialized&&e!==!1&&(d.debug&&console.log("Pager: Triggering pagerComplete"),d.$table.triggerHandler("pagerComplete",d),m.pager_savePages&&c.storage&&c.storage(l,m.pager_storageKey,{page:n.page,size:n.size}))}},buildPageSelect:function(c,d){var e,f,g,h,i,j,k=c.widgetOptions,l=b.getTotalPages(c,d)||1,m=5*Math.ceil(l/k.pager_maxOptionSize/5),n=l>k.pager_maxOptionSize,o=d.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){var c,d,e=b.table,f=b.pager,g=b.widgetOptions,h=b.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),g.pager_fixedHeight&&!f.isDisabled&&(d=a.data(e,"pagerSavedHeight"),d&&(c=d-h.height(),c>5&&a.data(e,"pagerLastSize")===f.size&&h.children("tr:visible").length')))},changeHeight:function(c){var d,e=c.table,f=c.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove(),f.children("tr:visible").length||f.append(' '),d=f.children("tr").eq(0).height()*c.pager.size,a.data(e,"pagerSavedHeight",d),b.fixHeight(c),a.data(e,"pagerLastSize",c.pager.size)},hideRows:function(a){if(!a.widgetOptions.pager_ajaxUrl){var b,d,e,f,g,h=(a.table,a.pager),i=a.widgetOptions,j=a.$tbodies.length,k=h.page*h.size,l=k+h.size,m=i&&i.filter_filteredRow||"filtered",n=0,o=0;for(h.cacheIndex=[],b=0;j>b;b++){for(e=a.$tbodies.eq(b).children("tr"),f=e.length,g=0,n=0,o=0,d=0;f>d;d++)e[d].className.match(m)||(o===k&&e[d].className.match(a.cssChildRow)?e[d].style.display="none":(e[d].style.display=o>=k&&l>o?"":"none",n!==o&&o>=k&&l>o&&(h.cacheIndex.push(d),n=o),o+=e[d].className.match(a.cssChildRow+"|"+a.selectorRemove.slice(1))&&!i.pager_countChildRows?0:1,o===l&&"none"!==e[d].style.display&&e[d].className.match(c.css.cssHasChild)&&(g=d)));if(g>0&&e[g].className.match(c.css.cssHasChild))for(;++g> Ajax Error",f,g,h),c.showError(i,f,g,h),e.$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,e.totalRows=e.filteredRows=j.filteredRows=j.totalRows,v=0===j.totalRows?[]:B[n?0:1]||[],u=B[2]):(j.ajaxData=B,e.totalRows=j.totalRows=B.total,e.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&&(e.$tbodies.eq(0).empty(),e.$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&&e.$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=e.$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])}e.showProcessing&&c.isProcessing(i),j.totalPages=Math.ceil(j.totalRows/b.parsePageSize(e,j.size,"get")),j.last.totalRows=j.totalRows,j.last.currentFilters=j.currentFilters,j.last.sortList=(e.sortList||[]).join(","),j.initializing=!1,b.updatePageDisplay(e,!1),c.updateCache(e,function(){j.initialized&&setTimeout(function(){e.debug&&console.log("Pager: Triggering pagerChange"),z.triggerHandler("pagerChange",j),c.applyWidget(i),b.updatePageDisplay(e)},0)})}j.initialized||c.applyWidget(i)},getAjax:function(d){var e,f=b.getAjaxUrl(d),g=a(document),h=d.namespace+"pager",i=d.pager;""!==f&&(d.showProcessing&&c.isProcessing(d.table,!0),g.on("ajaxError"+h,function(a,c,e,f){b.renderAjax(null,d,c,e,f),g.off("ajaxError"+h)}),e=++i.ajaxCounter,i.last.ajaxUrl=f,i.ajaxObject.url=f,i.ajaxObject.success=function(a,c,f){ec;c++)l.push(j+"["+h[c][0]+"]="+h[c][1]);g=g.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):j),l=[]}if(k){for(k=k[1],d=i.length,c=0;d>c;c++)i[c]&&l.push(k+"["+c+"]="+encodeURIComponent(i[c]));g=g.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):k),e.currentFilters=i}return a.isFunction(f.pager_customAjaxUrl)&&(g=f.pager_customAjaxUrl(b.table,g)),b.debug&&console.log("Pager: Ajax url = "+g),g},renderTable:function(a,d){var e,f,g,h,i=a.table,j=a.pager,k=a.widgetOptions,l=a.$table.hasClass("hasFilters"),m=d&&d.length||0,n=j.page*j.size,o=j.size;if(1>m)return void(a.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&&(a.debug&&console.log("Pager: Triggering pagerChange"),a.$table.triggerHandler("pagerChange",a)),k.pager_removeRows){for(c.clearTableBody(i),e=c.processTbody(i,a.$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(i,e,!1)}else b.hideRows(a);b.updatePageDisplay(a),k.pager_startPage=j.page,k.pager_size=j.size,i.isUpdating&&(a.debug&&console.log("Pager: Triggering updateComplete"),a.$table.triggerHandler("updateComplete",[i,!0]))},showAllRows:function(d){var e,f,g,h=d.table,i=d.pager,j=d.widgetOptions;for(i.ajax?b.pagerArrows(d,!0):(a.data(h,"pagerLastPage",i.page),a.data(h,"pagerLastSize",i.size),i.page=0,i.size=i.totalRows,i.totalPages=1,d.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(d,d.rowsCopy),i.isDisabled=!0,c.applyWidget(h),d.debug&&console.log("Pager: Disabled")),f=i.$size.add(i.$goto).add(i.$container.find(".ts-startRow, .ts-page ")),g=f.length,e=0;g>e;e++)f.eq(e).attr("aria-disabled","true").addClass(j.pager_css.disabled)[0].disabled=!0},updateCache:function(d){var e=d.pager;c.updateCache(d,function(){if(!a.isEmptyObject(d.cache)){var c,f=[],g=d.cache[0].normalized;for(e.totalRows=g.length,c=0;cd&&d>=0&&(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(c,e,!0)},moveToFirstPage:function(a,c){c.page=0,b.moveToPage(a,c,!0)},moveToLastPage:function(a,c){c.page=b.getTotalPages(a,c)-1,b.moveToPage(a,c,!0)},moveToNextPage:function(a,c){c.page++;var d=b.getTotalPages(a,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){var e=a.table,f=a.pager,g=a.widgetOptions.pager_selectors,h=[g.first,g.prev,g.next,g.last,g.gotoPage,g.pageSize].join(","),i=a.namespace+"pager";f.initialized=!1,a.$table.off(i),f.$container.hide().find(h).off(i),d||(b.showAllRows(a),a.appender=null,c.storage&&c.storage(e,a.widgetOptions.pager_storageKey,""),delete e.config.pager,delete e.config.rowsCopy)},enablePager:function(d,e){var f,g,h=d.table,i=d.pager;i.isDisabled=!1,i.page=a.data(h,"pagerLastPage")||i.page||0,g=i.$size.find("option[selected]").val(),i.size=a.data(h,"pagerLastSize")||b.parsePageSize(d,g,"get"),i.$size.val(b.parsePageSize(d,i.size,"set")),i.totalPages=Math.ceil(b.getTotalPages(d,i)/i.size),d.$table.removeClass("pagerDisabled"),h.id&&(f=h.id+"_pager_info",i.$container.find(d.widgetOptions.pager_selectors.pageDisplay).attr("id",f),d.$table.attr("aria-describedby",f)),b.changeHeight(d),e&&(c.update(d),b.setPageSize(d,i.size),b.hideRowsSetup(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(e,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(e,g),b.updatePageDisplay(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(c,c.pager,!1):b.initComplete(c)},remove:function(a,c,d,e){b.destroyPager(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.triggerHandler("pagerBeforeInitialized",f),b.enablePager(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(f,i)):(i.ajax=!1,c.appendCache(f,!0)))}},initComplete:function(a){var d=a.pager;b.bindEvents(a),b.setPageSize(a,0),d.ajax||b.hideRowsSetup(a),d.initialized=!0,d.initializing=!1,d.isInitializing=!1,a.debug&&console.log("Pager: Triggering pagerInitialized"),a.$table.triggerHandler("pagerInitialized",a),a.widgetOptions.filter_initialized&&c.hasWidget(a.table,"filter")||b.updatePageDisplay(a,!d.ajax)},bindEvents:function(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(d),b.updatePageDisplay(d,!1),c.applyWidget(d.table))}).on("disablePager"+i,function(a){a.stopPropagation(),b.showAllRows(d)}).on("enablePager"+i,function(a){a.stopPropagation(),b.enablePager(d,!0)}).on("destroyPager"+i,function(a,b){a.stopPropagation(),c.removeWidget(d.table,"pager",!1)}).on("updateComplete"+i,function(a,e,f){if(a.stopPropagation(),e&&!f&&!g.ajax){var i=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);g.totalRows=i.length-(h.pager_countChildRows?0:i.filter("."+d.cssChildRow).length),g.totalPages=Math.ceil(g.totalRows/g.size),i.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),g.page>=g.totalPages&&b.moveToLastPage(d,g),b.hideRows(d),b.changeHeight(d),b.updatePageDisplay(d,!1),c.applyWidget(e),b.updatePageDisplay(d)}}).on("pageSize refreshComplete ".split(" ").join(i+" "),function(a,c){a.stopPropagation(),b.setPageSize(d,b.parsePageSize(d,c,"get")),b.hideRows(d),b.updatePageDisplay(d,!1)}).on("pageSet pagerUpdate ".split(" ").join(i+" "),function(a,c){a.stopPropagation(),"pagerUpdate"===a.type&&(c="undefined"==typeof c?g.page+1:c,g.last.page=!0),g.page=(parseInt(c,10)||1)-1,b.moveToPage(d,g,!0),b.updatePageDisplay(d,!1)}).on("pageAndSize"+i,function(a,c,e){a.stopPropagation(),g.page=(parseInt(c,10)||1)-1,b.setPageSize(d,b.parsePageSize(d,e,"get")),b.moveToPage(d,g,!0),b.hideRows(d),b.updatePageDisplay(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(c){c.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]](d,g);break}}),g.$goto.length?g.$goto.off("change"+i).on("change"+i,function(){g.page=a(this).val()-1,b.moveToPage(d,g,!0),b.updatePageDisplay(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(){if(!a(this).hasClass(h.pager_css.disabled)){var c=a(this).val();g.$size.val(c),b.setPageSize(d,c),b.changeHeight(d)}return!1})):d.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){if(!d.pager.initializing){var f,g,h,i,j,k,l=d.table,m=d.widgetOptions,n=d.pager,o=d.namespace+"pager",p=b.parsePageSize(d,n.size,"get");if(m.pager_countChildRows&&g.push(d.cssChildRow),n.$size.add(n.$goto).removeClass(m.pager_css.disabled).removeAttr("disabled").attr("aria-disabled","false"),n.totalPages=Math.ceil(n.totalRows/p),d.totalRows=n.totalRows,b.parsePageNumber(d,n),b.calcFilters(d),d.filteredRows=n.filteredRows,n.filteredPages=Math.ceil(n.filteredRows/p)||0,b.getTotalPages(d,n)>=0){if(g=n.size*n.page>n.filteredRows&&e,n.page=g?m.pager_pageReset||0:n.page,n.startRow=g?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)),h=n.$container.find(m.pager_selectors.pageDisplay),f=(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(g="",i=b.buildPageSelect(d,n),k=i.length,j=0;k>j;j++)g+='";n.$goto.html(g).val(n.page+1)}h.length&&(h["INPUT"===h[0].nodeName?"val":"html"](f),h.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;d.$table.triggerHandler("pageSet"+o,[c])}))}b.pagerArrows(d),b.fixHeight(d),n.initialized&&e!==!1&&(d.debug&&console.log("Pager: Triggering pagerComplete"),d.$table.triggerHandler("pagerComplete",d),m.pager_savePages&&c.storage&&c.storage(l,m.pager_storageKey,{page:n.page,size:n.size}))}},buildPageSelect:function(c,d){var e,f,g,h,i,j,k=c.widgetOptions,l=b.getTotalPages(c,d)||1,m=5*Math.ceil(l/k.pager_maxOptionSize/5),n=l>k.pager_maxOptionSize,o=d.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){var c,d,e=b.table,f=b.pager,g=b.widgetOptions,h=b.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),g.pager_fixedHeight&&!f.isDisabled&&(d=a.data(e,"pagerSavedHeight"),d&&(c=d-h.height(),c>5&&a.data(e,"pagerLastSize")===f.size&&h.children("tr:visible").length')))},changeHeight:function(c){var d,e=c.table,f=c.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove(),f.children("tr:visible").length||f.append(' '),d=f.children("tr").eq(0).height()*c.pager.size,a.data(e,"pagerSavedHeight",d),b.fixHeight(c),a.data(e,"pagerLastSize",c.pager.size)},hideRows:function(a){if(!a.widgetOptions.pager_ajaxUrl){var b,d,e,f,g,h=(a.table,a.pager),i=a.widgetOptions,j=a.$tbodies.length,k=h.page*h.size,l=k+h.size,m=i&&i.filter_filteredRow||"filtered",n=0,o=0;for(h.cacheIndex=[],b=0;j>b;b++){for(e=a.$tbodies.eq(b).children("tr"),f=e.length,g=0,n=0,o=0,d=0;f>d;d++)e[d].className.match(m)||(o===k&&e[d].className.match(a.cssChildRow)?e[d].style.display="none":(e[d].style.display=o>=k&&l>o?"":"none",n!==o&&o>=k&&l>o&&(h.cacheIndex.push(d),n=o),o+=e[d].className.match(a.cssChildRow+"|"+a.selectorRemove.slice(1))&&!i.pager_countChildRows?0:1,o===l&&"none"!==e[d].style.display&&e[d].className.match(c.css.cssHasChild)&&(g=d)));if(g>0&&e[g].className.match(c.css.cssHasChild))for(;++g> Ajax Error",f,g,h),c.showError(i,f,g,h),e.$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,e.totalRows=e.filteredRows=j.filteredRows=j.totalRows,v=0===j.totalRows?[]:B[n?0:1]||[],u=B[2]):(j.ajaxData=B,e.totalRows=j.totalRows=B.total,e.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&&(e.$tbodies.eq(0).empty(),e.$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&&e.$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=e.$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])}e.showProcessing&&c.isProcessing(i),j.totalPages=Math.ceil(j.totalRows/b.parsePageSize(e,j.size,"get")),j.last.totalRows=j.totalRows,j.last.currentFilters=j.currentFilters,j.last.sortList=(e.sortList||[]).join(","),j.initializing=!1,b.updatePageDisplay(e,!1),c.updateCache(e,function(){j.initialized&&setTimeout(function(){e.debug&&console.log("Pager: Triggering pagerChange"),z.triggerHandler("pagerChange",j),c.applyWidget(i),b.updatePageDisplay(e)},0)})}j.initialized||c.applyWidget(i)},getAjax:function(d){var e,f=b.getAjaxUrl(d),g=a(document),h=d.namespace+"pager",i=d.pager;""!==f&&(d.showProcessing&&c.isProcessing(d.table,!0),g.on("ajaxError"+h,function(a,c,e,f){b.renderAjax(null,d,c,e,f),g.off("ajaxError"+h)}),e=++i.ajaxCounter,i.last.ajaxUrl=f,i.ajaxObject.url=f,i.ajaxObject.success=function(a,c,f){ec;c++)l.push(j+"["+h[c][0]+"]="+h[c][1]);g=g.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):j),l=[]}if(k){for(k=k[1],d=i.length,c=0;d>c;c++)i[c]&&l.push(k+"["+c+"]="+encodeURIComponent(i[c]));g=g.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):k),e.currentFilters=i}return a.isFunction(f.pager_customAjaxUrl)&&(g=f.pager_customAjaxUrl(b.table,g)),b.debug&&console.log("Pager: Ajax url = "+g),g},renderTable:function(a,d){var e,f,g,h,i=a.table,j=a.pager,k=a.widgetOptions,l=a.$table.hasClass("hasFilters"),m=d&&d.length||0,n=j.page*j.size,o=j.size;if(1>m)return void(a.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&&(a.debug&&console.log("Pager: Triggering pagerChange"),a.$table.triggerHandler("pagerChange",a)),k.pager_removeRows){for(c.clearTableBody(i),e=c.processTbody(i,a.$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(i,e,!1)}else b.hideRows(a);b.updatePageDisplay(a),k.pager_startPage=j.page,k.pager_size=j.size,i.isUpdating&&(a.debug&&console.log("Pager: Triggering updateComplete"),a.$table.triggerHandler("updateComplete",[i,!0]))},showAllRows:function(d){var e,f,g,h=d.table,i=d.pager,j=d.widgetOptions;for(i.ajax?b.pagerArrows(d,!0):(a.data(h,"pagerLastPage",i.page),a.data(h,"pagerLastSize",i.size),i.page=0,i.size=i.totalRows,i.totalPages=1,d.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(d,d.rowsCopy),i.isDisabled=!0,c.applyWidget(h),d.debug&&console.log("Pager: Disabled")),f=i.$size.add(i.$goto).add(i.$container.find(".ts-startRow, .ts-page ")),g=f.length,e=0;g>e;e++)f.eq(e).attr("aria-disabled","true").addClass(j.pager_css.disabled)[0].disabled=!0},updateCache:function(d){var e=d.pager;c.updateCache(d,function(){if(!a.isEmptyObject(d.cache)){var c,f=[],g=d.cache[0].normalized;for(e.totalRows=g.length,c=0;cd&&d>=0&&(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(c,e,!0)},moveToFirstPage:function(a,c){c.page=0,b.moveToPage(a,c,!0)},moveToLastPage:function(a,c){c.page=b.getTotalPages(a,c)-1,b.moveToPage(a,c,!0)},moveToNextPage:function(a,c){c.page++;var d=b.getTotalPages(a,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){var e=a.table,f=a.pager,g=a.widgetOptions.pager_selectors,h=[g.first,g.prev,g.next,g.last,g.gotoPage,g.pageSize].join(","),i=a.namespace+"pager";f.initialized=!1,a.$table.off(i),f.$container.hide().find(h).off(i),d||(b.showAllRows(a),a.appender=null,c.storage&&c.storage(e,a.widgetOptions.pager_storageKey,""),delete e.config.pager,delete e.config.rowsCopy)},enablePager:function(d,e){var f,g,h=d.table,i=d.pager;i.isDisabled=!1,i.page=a.data(h,"pagerLastPage")||i.page||0,g=i.$size.find("option[selected]").val(),i.size=a.data(h,"pagerLastSize")||b.parsePageSize(d,g,"get"),i.$size.val(b.parsePageSize(d,i.size,"set")),i.totalPages=Math.ceil(b.getTotalPages(d,i)/i.size),d.$table.removeClass("pagerDisabled"),h.id&&(f=h.id+"_pager_info",i.$container.find(d.widgetOptions.pager_selectors.pageDisplay).attr("id",f),d.$table.attr("aria-describedby",f)),b.changeHeight(d),e&&(c.update(d),b.setPageSize(d,i.size),b.hideRowsSetup(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(e,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(e,g),b.updatePageDisplay(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/index.html b/docs/index.html index 11b52047..2095b539 100644 --- a/docs/index.html +++ b/docs/index.html @@ -487,9 +487,9 @@

-
  • Pager plugin (basic & ajax demos; v2.24.6).
  • +
  • Pager plugin (basic & ajax demos; v2.25.4).
  • - Pager widget (basic & ajax demos) (v2.12; v2.24.6).
    + Pager widget (basic & ajax demos) (v2.12; v2.25.4).

  • @@ -1015,7 +1015,7 @@ '.first-name' : { sorter: 'text' }, '.disabled' : { sorter: false } } - Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc. + Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc. @@ -1101,7 +1101,7 @@ String - 'widget-{name}' + "widget-{name}" When the table has a class name that matches the template and a widget id that matches the {name}, the widget will automatically be added to the table (v2.18.0)

    @@ -1595,7 +1595,7 @@ $.extend($.tablesorter.themes.jui, {
    * Note This option accepts multiple types (String, Object or Function); see below for further details.

    - In v2.19.0, the code was further optimized. When set to "basic" (the default), the textExtraction code will check for data-attributes, otherwise, any other string value setting will skip the data-attribute value check; because of this change, there is a noticable lessening of initialization time in Internet Explorer. + In v2.19.0, the code was further optimized. When set to "basic" (the default), the textExtraction code will check for data-attributes, otherwise, any other string value setting will skip the data-attribute value check; because of this change, there is a noticable lessening of initialization time in Internet Explorer.

    In v2.17.0, the textExtraction column can also be referenced by using a jQuery selector (e.g. class name, id or column index) that points to a table header cell.
    textExtraction : {
    @@ -1608,7 +1608,7 @@ $.extend($.tablesorter.themes.jui, {
             return $(node).find('img').attr('title');
         }
     }
    - Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.
    + Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

    As of version 2.16.0,
      @@ -1996,11 +1996,11 @@ $(function(){ String - "checked" + "checked" Used by the "checkbox" parser in the parser-input-select.js file (v2.22.2; v2.25.0).

      When using the checkbox parser, this class name is added to the row along with this class name plus the column index when the targeted checkbox is checked.

      -

      For example, if the named parser file has been loaded & "sorter-checkbox" class is added to the first column header, then any checked checkbox in the first column will have "checked checked-0" class names added to the row.

      +

      For example, if the named parser file has been loaded & "sorter-checkbox" class is added to the first column header, then any checked checkbox in the first column will have "checked checked-0" class names added to the row.

      Checkboxes in any other column, not targeted by the parser, will be ignored and no extra row class names will be added.
      @@ -2065,7 +2065,7 @@ $(function(){ String - "alt" + "alt" Used by the image parser to grab the image attribute content (v2.17.5; moved to tablesorter core in v2.18.0; see config.parsers).

      @@ -2513,13 +2513,13 @@ filter_cssFilter : [ '', 'hidden', '', 'hidden' ] Set up the column string as follows:
      • Add the desired filter type symbol along with {query} or {q} to maintain positioning
      • -
      • Symbols can be added to the beginning "~{query}" (default fuzzy search) or end "{q}=" (default exact search)
      • +
      • Symbols can be added to the beginning "~{query}" (default fuzzy search) or end "{q}=" (default exact search)
      • For symbols that separate queries, like "AND", "OR" or "-" (range):
        • Add one additional {q} tag.
        • -
        • For example, to add a default "OR" search, use "{q} OR {q}".
        • -
        • If the user enters "a b c d" the column will be filtered using "a OR b OR c OR d", so there is no need to add more {q} tags within the string; adding more will likely mess up the results.
        • -
        • If the user only enters "a", then the column will be filtered using "a OR a" so as not to cause other issues.
        • +
        • For example, to add a default "OR" search, use "{q} OR {q}".
        • +
        • If the user enters "a b c d" the column will be filtered using "a OR b OR c OR d", so there is no need to add more {q} tags within the string; adding more will likely mess up the results.
        • +
        • If the user only enters "a", then the column will be filtered using "a OR a" so as not to cause other issues.
      • Note It is not possible to set up a default filter search within a query. So the "wild" filter search will not work as intended (e.g. {q}* and {q}? are essentially the same as {q}.
      • @@ -2556,8 +2556,8 @@ filter_cssFilter : [ '', 'hidden', '', 'hidden' ] }); Exclusion names must be separated by a comma. Here is a full list of filter type names:
          -
        • and - logical " AND " or && type filter.
        • -
        • exact - exact match (using " or =).
        • +
        • and - logical " AND " or && type filter.
        • +
        • exact - exact match (using " or =).
        • fuzzy - fuzzy match (~)
        • notMatch - not match (! or !=)
        • operators - comparison filters (< <= >= >)
        • @@ -2589,7 +2589,7 @@ filter_cssFilter : [ '', 'hidden', '', 'hidden' ] } }); }); - These external inputs have one requirement, they must have a data-column="#", where the # targets the column (zero-based index), pointing to a specific column to search.
          + These external inputs have one requirement, they must have a data-column="#", where the # targets the column (zero-based index), pointing to a specific column to search.
          <input class="search" type="search" data-column="0" placeholder="Search first column">
          If you want to search all columns, using the updated "any match" method, set the data column value to "all":
          <input class="search" type="search" data-column="all" placeholder="Search entire table">
          @@ -2627,7 +2627,7 @@ filter_cssFilter : [ '', 'hidden', '', 'hidden' ] }); } } - Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.
          + Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

          A new file has been included named "widget-filter-formatter-jui.js" & "widget-filter-formatter-html5.js". The files include code to add jQuery UI and HTML5 controls via the filter_formatter option.

          @@ -2698,7 +2698,7 @@ filter_cssFilter : [ '', 'hidden', '', 'hidden' ] ... } } - Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.
          + Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

          Use the "filter_functions" option in three different ways:
          @@ -3049,7 +3049,7 @@ $('table').trigger('search', false);
    • The last search (for all columns) was not completely empty - all rows will be searched anyway.
    • If there were no changes to the search from the beginning of the search string (changing the above search to "bright" will force a new search of all rows).
    • If the search does not contain a logical or ( or or |), or a range delimiter ( - or to ) within the search query.
    • -
    • If the search is not looking for an exact match (" or =) or a logical not search (!).
    • +
    • If the search is not looking for an exact match (" or =) or a logical not search (!).
    • Or, if the search is using a select dropdown without a "filter-match" class name (looking for an exact match).
    • If the search does not contain an operator greater than or equal to a negative number (>=-10) or less than or equal to a positive number (<=10).
    • And lastly, only search filtered rows if all rows are not hidden.
    • @@ -3103,7 +3103,7 @@ $('table').trigger('search', false);
    filter_selectSource : {
       ".model-number" : [ "abc", "def", "ghi", "xyz" ]
     }
    - Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.
    + Warning What won't work is if you try to target the header using a filtering selector that uses an index, e.g. "th:eq()", ":gt()", ":lt()", ":first", ":last", ":even" or ":odd", ":first-child", ":last-child", ":nth-child()", ":nth-last-child()", etc.

    A column will have a filter select dropdown when a "filter-select" class name is added to the header cell, or if the filter_functions column value is set to true

    @@ -3703,7 +3703,7 @@ $('table').trigger('search', false); String - "" + "" Storage widget: This option allows setting an alternate table id so multiple tables on a page have the settings grouped together
    @@ -3718,12 +3718,12 @@ $('table').trigger('search', false);
    String - "" + "" Storage widget: Set a table (data) attribute to use to obtain a table id, which allows grouping multiple tables on one page together - they share a common saved setting.

    If a value is set in this option, the storage widget looks in that defined table data-attribute for a table id.

    -

    If this option is not defined, then the default data-attribute for the table becomes "data-table-group".

    +

    If this option is not defined, then the default data-attribute for the table becomes "data-table-group".

    The value in the data-attribute sets a table id, if not found, the storage widget then looks for an id in the storage_tableId option.

    @@ -3733,7 +3733,7 @@ $('table').trigger('search', false); String - "" + "" Storage widget: This option allows setting an alternate table url so that tables on multiple pages will have their settings grouped together
    @@ -3748,12 +3748,12 @@ $('table').trigger('search', false);
    String - "" + "" Storage widget: Set a table (data) attribute to use to obtain a table url, which allows grouping tables across multiple pages together - they share a common saved setting.

    If a value is set in this option, the storage widget looks in that defined table data-attribute for a table url.

    -

    If this option is not defined, then the default data-attribute for the table becomes "data-table-page".

    +

    If this option is not defined, then the default data-attribute for the table becomes "data-table-page".

    The value in the data-attribute sets a table url, if not found, the storage widget then looks for a url in the storage_fixedUrl option.

    @@ -3822,7 +3822,6 @@ $('table').trigger('search', false); .tablesorterPager({ container: $(".pager") }); - }); }); Example @@ -3839,7 +3838,7 @@ $('table').trigger('search', false); Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_ajaxUrl

    The tags within the ajaxUrl string are optional. If do not want the user to change the page size, then you only need to include the page in this string: -
    ajaxUrl: "http://mydatabase.com?start={page}"
    +
    ajaxUrl: "http://mydatabase.com?start={page}"
    If you need to send your server a page offset (actual starting record number), then you'll need to use the customAjaxUrl option.

    Here is an example of how to include the option, it should always be paired with an ajaxProcessing function: @@ -4008,6 +4007,33 @@ $('table').trigger('search', false); + + + Object + undefined + + When processAjaxOnInit is set to false, set this option to contain the total number of rows and filtered rows to prevent an initial ajax call (v2.25.4). +
    +
    + Note The pager widget equivalent option is within the widgetOptions and accessed via widgetOptions.pager_initialRows +

    Use this option as follows:

    +
    $(function(){
    +  $("table")
    +    .tablesorter()
    +    .tablesorterPager({
    +      processAjaxOnInit: false,
    +      initialRows: {
    +        total: 100,
    +        filtered: 100
    +      },
    +      // other ajax settings...
    +    });
    +});
    +
    + + + + Boolean @@ -4238,7 +4264,7 @@ $('table').trigger('search', false); String - "{page}/{totalPages}" + "{page}/{totalPages}" This option allows you to format the output display which can show the current page, total pages, filtered pages, current start and end rows, total rows and filtered rows (v2.0.9; v2.17.6).

    @@ -4253,7 +4279,6 @@ $('table').trigger('search', false);
    .tablesorterPager({ output: '{startRow} to {endRow} of {totalRows} rows' }); - }); });The following tags are replaced within the output string: @@ -5234,7 +5259,7 @@ or, directly add the search string to the filter input as follows: - @@ -6913,7 +6938,7 @@ $.tablesorter.isValueInArray(2, sortList);
    Internal list of all table header cells (v2.8)

    - *NOTE* The header cells within rows with the cssIgnoreRow class (default is "tablesorter-ignoreRow" will not be included in this variable.

    + *NOTE* The header cells within rows with the cssIgnoreRow class (default is "tablesorter-ignoreRow" will not be included in this variable.

    Header cells in not-ignored rows are targeted using the jQuery selector from the selectorHeaders option

    Please note that the headers cells are simply an array of targetted header cells and should not be targeted using a column index. For example, given the following table thead markup, the header-index counts the header th cells and does not actually match the data-column index when extra rows and/or colspan or rowspan are included in any of the header cells:
    <thead>
    @@ -6277,7 +6302,7 @@ var wo = $('#mytable').data('tablesorter').widgetOptions;
     			
    jQuery ObjectOnly available when the filter widget is active. This variable contains all external search inputs with data-column="all", bound using the bindSearch function. + Only available when the filter widget is active. This variable contains all external search inputs with data-column="all", bound using the bindSearch function.

    The table.config.widgetOptions.filter_$anyMatch variable contains one more more search inputs, and is dynamically updated if the bindSearch function is called; make sure to set the flag to force a new search so that the values of the altered filters is updated appropriately. @@ -6821,7 +6846,7 @@ myArray.sort(function(a,b) { return $.tablesorter.sortText(a, b); });
  • string - a string to process & replace accented characters.
  • Here is a basic example of how this function is used: -
    $.tablesorter.replaceAccents("áàâãä"); // result: "aaaaa"
    +
    $.tablesorter.replaceAccents("áàâãä"); // result: "aaaaa"
    This function is used when the sortLocaleCompare option is set to true. Please refer to the option and the demo for more details on the defaults values and how to add more accented characters.
    This function allows the adding of custom widget scripts to the tablesorter core (v2.19.0).

    - In v2.19.0, a "refreshing" parameter was added to the remove widget function to indicate that the widget will be refreshed so it will only be temporarily removed (see this demo for more details).
    + In v2.19.0, a "refreshing" parameter was added to the remove widget function to indicate that the widget will be refreshed so it will only be temporarily removed (see this demo for more details).

    Access it as follows:
    $.tablesorter.addWidget(myWidget);
    @@ -6969,7 +6994,7 @@ widget.format( table, table.config, table.config.widgetOptions );
    This function removes, then reapplies all currently selected widgets on a table (v2.4; v2.19.0).

    - In v2.19.0, this function was modified to internally use the removeWidget function & a "refreshComplete" event is now triggered upon completion.
    + In v2.19.0, this function was modified to internally use the removeWidget function & a "refreshComplete" event is now triggered upon completion.

    Use it as follows:
    $.tablesorter.refreshWidgets( table, doAll, dontapply );
    @@ -7014,7 +7039,7 @@ widget.format( table, table.config, table.config.widgetOptions );
  • object - object containing zero-based column indexes or column class names as a key (e.g. table.config.headers or table.config.widgetOptions.filter_functions; any data found as the value (of the key : value pair) will be returned.
  • key - key to be Object key; this can be a zero-based column index or header class name/id.
  • - As a full example, say you have a header cell with a class name of "event". And you want to use the textExtraction function for that column, then you would use this function as follows: + As a full example, say you have a header cell with a class name of "event". And you want to use the textExtraction function for that column, then you would use this function as follows:
    var table = $('table')[0],
     textExtractionFunction = $.tablesorter.getColumnData( table, table.config.textExtraction, ".event" );
    The ".event" key can be replaced with a zero-based column index, if the textExtraction option is set up using indexes. @@ -7035,7 +7060,7 @@ textExtractionFunction = $.tablesorter.getColumnData( table, table.config.textEx
  • table - table DOM element (or jQuery object).
  • column - zero-based column index or 'all'.
  • callback - callback function that is called while obtaining data for each cell within the specified column.
  • -
  • rowFilter - can be a jQuery selector, function or element to allow targeting specific rows (e.g. ":visible" or ":not(.child-row)"); this parameter is used in a jQuery .is() function (v2.24.0).
  • +
  • rowFilter - can be a jQuery selector, function or element to allow targeting specific rows (e.g. ":visible" or ":not(.child-row)"); this parameter is used in a jQuery .is() function (v2.24.0).
  • When using the callback, there is only one argument (object) passed to this function; it contains the following:
      @@ -7251,9 +7276,9 @@ $.tablesorter.computeColumnIndex($rows, config);

      The table element will only process one table. So if you pass in a jQuery object, only the first table will be bound to the elements ($els).

      The external elements ($els) will allow searching the table using "search" and "keyup" events (enter to start & escape to cancel the search), and uses the filter_liveSearch option, or delayed search.

      - Include a data-column="#" attribute (where # is the column number) in the search input, to specify to which column the search should apply ~ see this demo for a full example. Warning!, if no data-column attribute is added to the input, the input will be ignored.
      + Include a data-column="#" attribute (where # is the column number) in the search input, to specify to which column the search should apply ~ see this demo for a full example. Warning!, if no data-column attribute is added to the input, the input will be ignored.

      - In v2.15, use a data-column="all" to bind an external any-match search filter; but note that adding an external any-match filter using this method will not override the filter set by the filter_external option.
      + In v2.15, use a data-column="all" to bind an external any-match search filter; but note that adding an external any-match filter using this method will not override the filter set by the filter_external option.

      The third function parameter, false, is optional. When set to false it forces the inputs to update their values (same as setting the apply flag when using the setFilters function), and reapplies (forces) the current search to be applied again, even if the filter values have not changed; this allows changing the data column attribute dynamically. See the filter external inputs demo for an example.

      @@ -7290,7 +7315,7 @@ $.tablesorter.filter.buildSelect( $('table'), 1, $('<option>Aaron</opti
    This filter widget function returns all the cached values of the set table column (v2.16.0):

    - This function respects the parsed data setting for the column, so it uses the filter_useParsedData option, "filter-parsed" class on the header, or the parser parsed flag settinng (ref). + This function respects the parsed data setting for the column, so it uses the filter_useParsedData option, "filter-parsed" class on the header, or the parser parsed flag settinng (ref).

    Use it as follows:

    $.tablesorter.filter.getOptions( table, column, onlyAvail );
      @@ -7357,7 +7382,7 @@ $('select.external').html( opts );
      // use $('table') or $('table.hasFilters') to make sure the table has a filter row
       // only required if the stickyHeaders or scroller widget is being used (they duplicate the table)
       $.tablesorter.getFilters( $('table') );
      - This function returns an array of filter values (e.g. [ '', '', '', '', '', '2?%' ]), or false if the selected table does not have a filter row. It will also return an additional parameter if an external input with data-column="all" containing the value used when matching any table column.
      + This function returns an array of filter values (e.g. [ '', '', '', '', '', '2?%' ]), or false if the selected table does not have a filter row. It will also return an additional parameter if an external input with data-column="all" containing the value used when matching any table column.

      In v2.15, this function will also return values from any external filters (set either by the filter_external option or using the bindSearch function) - with or without an internal filter row.

      @@ -7385,7 +7410,7 @@ $.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ], false ); $.tablesorter.setFilters( $('table'), [ '', '', '', '', '', '2?%' ] ); // this will now use the search method This function returns true if the filters were sucessfully applied, or false if the table does not have a filter row.

      In v2.24.3, if the apply parameter is left undefined, it will now default to true.

      - As of v2.15, this function will also set values in any external filters (set either by the filter_external option or using the bindSearch function). An additional search parameter can be included to match any column, but please include an external input with data-column="all" using the bindSearch function so your users will know that a search has been applied.
      + As of v2.15, this function will also set values in any external filters (set either by the filter_external option or using the bindSearch function). An additional search parameter can be included to match any column, but please include an external input with data-column="all" using the bindSearch function so your users will know that a search has been applied.

      Also, changed is that when a true value is passed as a third parameter, the search is forced to refresh on the table; otherwise, if the filters set in the search exactly match the previous search, it would be ignored - this was added to prevent numerous ajax calls with exactly the same search or sort parameters (when using the pager).
    @@ -7481,7 +7506,7 @@ $.tablesorter.addHeaderResizeEvent( table, true ); The priority of table ID settings is as follows:
    1. options.id setting
    2. -
    3. Table data attribute ("data-table-group" by default) value
    4. +
    5. Table data attribute ("data-table-group" by default) value
    6. widgetOptions.storage_tableId option
    7. Table id attribute
    8. Index of the table (compared to other tables with a "tablesorter" class name) on the page
    9. @@ -7489,7 +7514,7 @@ $.tablesorter.addHeaderResizeEvent( table, true ); The priority of table url (group) settings is as follows:
      1. options.url setting
      2. -
      3. Table data attribute ("data-table-page" by default) value
      4. +
      5. Table data attribute ("data-table-page" by default) value
      6. widgetOptions.storage_fixedUrl option value
      7. config.fixedUrl option value
      8. window.location.pathname
      9. diff --git a/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index 57e0b7a6..3cf7f39b 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -1030,7 +1030,8 @@ if ( pageMoved !== false && p.initialized && $.isEmptyObject( c.cache ) ) { return tsp.updateCache( c ); } - var table = c.table, + var tmp, + table = c.table, wo = c.widgetOptions, l = p.last; @@ -1068,7 +1069,17 @@ optAjaxUrl: wo.pager_ajaxUrl }; if ( p.ajax ) { - tsp.getAjax( c ); + if ( !wo.pager_processAjaxOnInit && !$.isEmptyObject(wo.pager_initialRows) ) { + wo.pager_processAjaxOnInit = true; + tmp = wo.pager_initialRows; + p.totalRows = typeof tmp.total !== 'undefined' ? tmp.total : + ( c.debug ? console.error('Pager: no initial total page set!') || 0 : 0 ); + p.filteredRows = typeof tmp.filtered !== 'undefined' ? tmp.filtered : + ( c.debug ? console.error('Pager: no initial filtered page set!') || 0 : 0 ); + tsp.updatePageDisplay( c, false ); + } else { + tsp.getAjax( c ); + } } else if ( !p.ajax ) { tsp.renderTable( c, c.rowsCopy ); }