diff --git a/addons/pager/jquery.tablesorter.pager.js b/addons/pager/jquery.tablesorter.pager.js index e9541135..17d136d3 100644 --- a/addons/pager/jquery.tablesorter.pager.js +++ b/addons/pager/jquery.tablesorter.pager.js @@ -173,7 +173,7 @@ updatePageDisplay = function(table, p, completed) { if ( p.initializing ) { return; } - var s, t, $out, indx, len, options, + var s, t, $out, $el, indx, len, options, c = table.config, namespace = c.namespace + 'pager', sz = parsePageSize( p, p.size, 'get' ); // don't allow dividing by zero @@ -218,7 +218,8 @@ return extra.length > 1 && data && data[extra[0]] ? data[extra[0]][extra[1]] : p[str] || (data ? data[str] : deflt) || deflt; }); } - if ( p.$goto.length ) { + $el = p.$container.find(p.cssGoto); + if ( $el.length ) { t = ''; options = buildPageSelect( table, p ); len = options.length; @@ -226,7 +227,7 @@ t += ''; } // innerHTML doesn't work in IE9 - http://support2.microsoft.com/kb/276228 - p.$goto.html(t).val( p.page + 1 ); + $el.html(t).val( p.page + 1 ); } if ($out.length) { $out[ ($out[0].nodeName === 'INPUT') ? 'val' : 'html' ](s); @@ -388,8 +389,9 @@ }, hideRowsSetup = function(table, p){ - p.size = parsePageSize( p, p.$size.val(), 'get' ); - p.$size.val( p.size ); + var $el = p.$container.find(p.cssPageSize); + p.size = parsePageSize( p, $el.val(), 'get' ); + $el.val( p.size ); $.data(table, 'pagerLastSize', p.size); pagerArrows( table, p ); if ( !p.removeRows ) { @@ -473,7 +475,9 @@ // only add new header text if the length matches if ( th && th.length === hl ) { hsh = $table.hasClass('hasStickyHeaders'); - $sh = hsh ? c.widgetOptions.$sticky.children('thead:first').children('tr').children() : ''; + $sh = hsh ? + c.widgetOptions.$sticky.children('thead:first').children('tr:not(.' + c.cssIgnoreRow + ')').children() : + ''; $f = $table.find('tfoot tr:first').children(); // don't change td headers (may contain pager) $headers = c.$headers.filter( 'th ' ); @@ -491,6 +495,8 @@ } else { $h.find('.tablesorter-header-inner').html( th[j] ); if (hsh && $sh.length) { + // add sticky header to container just in case it contains pager controls + p.$container = p.$container.add( wo.$sticky ); $sh.eq(j).find('.tablesorter-header-inner').html( th[j] ); } } @@ -693,9 +699,7 @@ } } // disable size selector - $controls = p.$size - .add( p.$goto ) - .add( p.$container.find( '.ts-startRow, .ts-page' ) ); + $controls = p.$container.find( p.cssGoto + ',' + p.cssPageSize + ', .ts-startRow, .ts-page' ); len = $controls.length; for ( index = 0; index < len; index++ ) { $controls.eq( index ).addClass( p.cssDisabled )[0].disabled = true; @@ -798,7 +802,7 @@ parsePageSize = function( p, size, mode ) { var s = parseInt( size, 10 ) || p.size || p.settings.size || 10; return p.initialized && (/all/i.test( size ) || s === p.totalRows) ? - // "get" to get `p.size` or "set" to set `p.$size.val()` + // "get" to get `p.size` or "set" to set `pageSize.val()` 'all' : ( mode === 'get' ? s : p.size ); }, @@ -812,7 +816,7 @@ setPageSize = function(table, size, p) { p.size = parsePageSize( p, size, 'get' ); - p.$size.val( parsePageSize( p, p.size, 'set' ) ); + p.$container.find(p.cssPageSize).val( parsePageSize( p, p.size, 'set' ) ); $.data(table, 'pagerLastPage', parsePageNumber( table, p ) ); $.data(table, 'pagerLastSize', p.size); p.totalPages = p.size === 'all' ? 1 : Math.ceil( p.totalRows / p.size ); @@ -887,7 +891,7 @@ enablePager = function(table, p, triggered) { var info, size, $el, c = table.config; - p.$size.add(p.$goto).add(p.$container.find('.ts-startRow, .ts-page')) + p.$container.find(p.cssGoto + ',' + p.cssPageSize + ',.ts-startRow, .ts-page') .removeClass(p.cssDisabled) .removeAttr('disabled') .each(function(){ @@ -895,9 +899,10 @@ }); p.isDisabled = false; p.page = $.data(table, 'pagerLastPage') || p.page || 0; - size = p.$size.find('option[selected]').val(); + $el = p.$container.find(p.cssPageSize); + size = $el.find('option[selected]').val(); p.size = $.data(table, 'pagerLastSize') || parsePageSize( p, size, 'get' ); - p.$size.val( p.size ); // set page size + $el.val( p.size ); // set page size p.totalPages = p.size === 'all' ? 1 : Math.ceil( getTotalPages( table, p ) / p.size ); // if table id exists, include page display with aria info if ( table.id && !c.$table.attr( 'aria-describedby' ) ) { @@ -923,7 +928,7 @@ }, init = function(table, settings) { - var t, ctrls, fxn, size, + var t, ctrls, fxn, size, $el, c = table.config, wo = c.widgetOptions, p = c.pager = $.extend( true, {}, $.tablesorterPager.defaults, settings ), @@ -1057,9 +1062,9 @@ }); // goto selector - p.$goto = pager.find(p.cssGoto); - if ( p.$goto.length ) { - p.$goto + $el = pager.find(p.cssGoto); + if ( $el.length ) { + $el .unbind('change' + namespace) .bind('change' + namespace, function(){ p.page = $(this).val() - 1; @@ -1070,14 +1075,15 @@ console.warn('Pager: >> Goto selector not found'); } // page size selector - p.$size = pager.find(p.cssPageSize); - if ( p.$size.length ) { + $el = pager.find(p.cssPageSize); + if ( $el.length ) { // setting an option as selected appears to cause issues with initial page size - p.$size.find('option').removeAttr('selected'); - p.$size.unbind('change' + namespace).bind('change' + namespace, function() { + $el.find('option').removeAttr('selected'); + $el.unbind('change' + namespace).bind('change' + namespace, function() { if ( !$(this).hasClass(p.cssDisabled) ) { var size = $(this).val(); - p.$size.val( size ); // in case there are more than one pagers + // in case there are more than one pager + p.$container.find(p.cssGoto).val( size ); setPageSize(table, size, p); changeHeight(table, p); } diff --git a/dist/js/extras/jquery.tablesorter.pager.min.js b/dist/js/extras/jquery.tablesorter.pager.min.js index 6f6319cf..9ae1e09c 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/26/2016 (v2.28.0) */ -!function(a){"use strict";var b=a.tablesorter;a.extend({tablesorterPager:new function(){this.defaults={container:null,ajaxUrl:null,customAjaxUrl:function(a,b){return b},ajaxError:null,ajaxObject:{dataType:"json"},processAjaxOnInit:!0,ajaxProcessing:function(a){return[0,[],null]},output:"{startRow} to {endRow} of {totalRows} rows",updateArrows:!0,page:0,pageReset:0,size:10,maxOptionSize:20,savePages:!0,storageKey:"tablesorter-pager",fixedHeight:!1,countChildRows:!1,removeRows:!1,cssFirst:".first",cssPrev:".prev",cssNext:".next",cssLast:".last",cssGoto:".gotoPage",cssPageDisplay:".pagedisplay",cssPageSize:".pagesize",cssErrorRow:"tablesorter-errorRow",cssDisabled:"disabled",totalRows:0,totalPages:0,filteredRows:0,filteredPages:0,ajaxCounter:0,currentFilters:[],startRow:0,endRow:0,$size:null,last:{}};var c="filterInit filterStart filterEnd sortEnd disablePager enablePager destroyPager updateComplete pageSize pageSet pageAndSize pagerUpdate refreshComplete ",d=this,e=function(a,b,c){var d,e="addClass",f="removeClass",g=b.cssDisabled,h=!!c,i=h||0===b.page,j=t(a,b),k=h||b.page===j-1||0===j;b.updateArrows&&(d=b.$container.find(b.cssFirst+","+b.cssPrev),d[i?e:f](g),d.each(function(){this.ariaDisabled=i}),d=b.$container.find(b.cssNext+","+b.cssLast),d[k?e:f](g),d.each(function(){this.ariaDisabled=k}))},f=function(a,c){var d,e,f,g=a.config,h=g.$table.hasClass("hasFilters");if(h&&!c.ajax)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;e=0){if(k=r*d.page>d.filteredRows&&g,d.page=k?d.pageReset||0:d.page,d.startRow=k?r*d.page+1:0===d.filteredRows?0:r*d.page+1,d.endRow=Math.min(d.filteredRows,d.totalRows,r*(d.page+1)),l=d.$container.find(d.cssPageDisplay),j="function"==typeof d.output?d.output(c,d):(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;m'+o[m]+"";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/r)+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:r===d.totalRows?"all":r}))}},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;d<=j;)p[p.length]=d,d+=l?k:1;if(p[p.length]=j,l){for(f=[],e=Math.max(Math.floor(c.maxOptionSize/k)-1,5),n=m-e,n<1&&(n=1),o=m+e,o>j&&(o=j),d=n;d<=o;d++)f[f.length]=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<("all"===c.size?c.totalRows:c.size)&&g.append('')))},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()*("all"===c.size?c.totalRows: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="all"===c.size?c.totalRows:c.size,j=c.page*i,k=j+i,l=0,m=0;for(c.cacheIndex=[],d=0;d=j&&m=j&&m0&&g[e].className.match(b.css.cssHasChild))for(;++e> Ajax Error",f,h,i),b.showError(d,f,h,i),z.$tbodies.eq(0).children("tr").detach(),e.totalRows=0;else{if(a.isArray(D)?(l=isNaN(D[0])&&!isNaN(D[1]),w=D[l?1:0],e.totalRows=isNaN(w)?e.totalRows||0:w,z.totalRows=z.filteredRows=e.filteredRows=e.totalRows,t=0===e.totalRows?[]:D[l?0:1]||[],s=D[2]):(e.ajaxData=D,z.totalRows=e.totalRows=D.total,z.filteredRows=e.filteredRows="undefined"!=typeof D.filteredRows?D.filteredRows:D.total,s=D.headers,t=D.rows||[]),v=t&&t.length,t instanceof jQuery)e.processAjaxOnInit&&(z.$tbodies.eq(0).empty(),z.$tbodies.eq(0).append(t));else if(v){for(j=0;j",k=0;k"+t[j][k]+"";C+=""}e.processAjaxOnInit&&z.$tbodies.eq(0).html(C)}if(e.processAjaxOnInit=!0,s&&s.length===E)for(m=A.hasClass("hasStickyHeaders"),o=m?z.widgetOptions.$sticky.children("thead:first").children("tr").children():"",n=A.find("tfoot tr:first").children(),p=z.$headers.filter("th "),x=p.length,k=0;k> 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:q,i=n?0:q,j=0;jq&&j<=p&&(j++,e.cacheIndex[e.cacheIndex.length]=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="all",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;fc&&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="all"===d.size?1:Math.ceil(d.totalRows/d.size),d.filteredPages="all"===d.size?1: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(b,c){var d=b.config;d.pager=a.extend(!0,{},a.tablesorterPager.defaults,c.settings),F(b,c.settings)},D=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},E=function(c,d,e){var f,g,h,i=c.config;d.$size.add(d.$goto).add(d.$container.find(".ts-startRow, .ts-page")).removeClass(d.cssDisabled).removeAttr("disabled").each(function(){this.ariaDisabled=!1}),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,g,"get"),d.$size.val(d.size),d.totalPages="all"===d.size?1:Math.ceil(t(c,d)/d.size),c.id&&!i.$table.attr("aria-describedby")&&(h=d.$container.find(d.cssPageDisplay),f=h.attr("id"),f||(f=c.id+"_pager_info",h.attr("id",f)),i.$table.attr("aria-describedby",f)),j(c,d),e&&(b.update(i),w(c,d.size,d),l(c,d),i.debug&&console.log("Pager: Enabled"))},F=function(e,f){var h,i,m,n=e.config,o=n.widgetOptions,p=n.pager=a.extend(!0,{},a.tablesorterPager.defaults,f),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,f),n.debug&&console.log("Pager: Initializing"),p.oldAjaxSuccess=p.oldAjaxSuccess||p.ajaxObject.success,n.appender=d.appender,p.initializing=!0,p.savePages&&b.storage&&(h=b.storage(e,p.storageKey)||{},p.page=isNaN(h.page)?p.page:h.page,p.size="all"===h.size?h.size:(isNaN(h.size)?p.size:h.size)||p.setSize||10,a.data(e,"pagerLastSize",p.size),B.find(p.cssPageSize).val(p.size)),p.regexRows=new RegExp("("+(o.filter_filteredRow||"filtered")+"|"+n.selectorRemove.slice(1)+"|"+n.cssChildRow+")"),p.regexFiltered=new RegExp(o.filter_filteredRow||"filtered"),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(e),g(e,p,!1),s(e,p,!1),b.applyWidget(e))}).bind("disablePager"+v,function(a){a.stopPropagation(),q(e,p)}).bind("enablePager"+v,function(a){a.stopPropagation(),E(e,p,!0)}).bind("destroyPager"+v,function(a){a.stopPropagation(),D(e,p)}).bind("resetToLoadState"+v,function(a){a.stopPropagation(),C(e,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="all"===p.size?1: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(e,u(p,b,"get"),p),k(e,p),g(e,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(e,p,!0),g(e,p,!1)}).bind("pageAndSize"+v,function(a,b,c){a.stopPropagation(),p.page=(parseInt(b,10)||1)-1,w(e,u(p,c,"get"),p),s(e,p,!0),k(e,p),g(e,p,!1)}),i=[p.cssFirst,p.cssPrev,p.cssNext,p.cssLast],m=[x,A,z,y],n.debug&&!B.length&&console.warn("Pager: >> Container not found"),B.find(i.join(",")).attr("tabindex",0).unbind("click"+v).bind("click"+v,function(b){b.stopPropagation();var c,d=a(this),f=i.length;if(!d.hasClass(p.cssDisabled))for(c=0;c> 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(e,b,p),j(e,p)}return!1})):n.debug&&console.warn("Pager: >> Size selector not found"),p.initialized=!1,t.triggerHandler("pagerBeforeInitialized",p),E(e,p,!1),"string"==typeof p.ajaxUrl?(p.ajax=!0,n.widgetOptions.filter_serversideFiltering=!0,n.serverSideSorting=!0,s(e,p)):(p.ajax=!1,b.appendCache(n,!0),l(e,p)),p.ajax||p.initialized||(p.initializing=!1,p.initialized=!0,s(e,p),n.debug&&console.log("Pager: Triggering pagerInitialized"),n.$table.triggerHandler("pagerInitialized",p),n.widgetOptions.filter_initialized&&b.hasWidget(e,"filter")||g(e,p,!1)),n.widgetInit.pager=!0};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="all"===e.size?1:Math.ceil(e.totalRows/e.size),p(b,c,e),g(b,e,!1))},d.construct=function(a){return this.each(function(){this.config&&this.hasInitialized&&F(this,a)})}}}),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,e="addClass",f="removeClass",g=b.cssDisabled,h=!!c,i=h||0===b.page,j=t(a,b),k=h||b.page===j-1||0===j;b.updateArrows&&(d=b.$container.find(b.cssFirst+","+b.cssPrev),d[i?e:f](g),d.each(function(){this.ariaDisabled=i}),d=b.$container.find(b.cssNext+","+b.cssLast),d[k?e:f](g),d.each(function(){this.ariaDisabled=k}))},f=function(a,c){var d,e,f,g=a.config,h=g.$table.hasClass("hasFilters");if(h&&!c.ajax)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;e=0){if(k=s*d.page>d.filteredRows&&g,d.page=k?d.pageReset||0:d.page,d.startRow=k?s*d.page+1:0===d.filteredRows?0:s*d.page+1,d.endRow=Math.min(d.filteredRows,d.totalRows,s*(d.page+1)),l=d.$container.find(d.cssPageDisplay),j="function"==typeof d.output?d.output(c,d):(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}),m=d.$container.find(d.cssGoto),m.length){for(k="",p=h(c,d),o=p.length,n=0;n'+p[n]+"";m.html(k).val(d.page+1)}l.length&&(l["INPUT"===l[0].nodeName?"val":"html"](j),l.find(".ts-startRow, .ts-page").unbind("change"+r).bind("change"+r,function(){var b=a(this).val(),c=a(this).hasClass("ts-startRow")?Math.floor(b/s)+1:b;q.$table.triggerHandler("pageSet"+r,[c])}))}e(c,d),i(c,d),d.initialized&&g!==!1&&(q.debug&&console.log("Pager: Triggering pagerComplete"),q.$table.triggerHandler("pagerComplete",d),d.savePages&&b.storage&&b.storage(c,d.storageKey,{page:d.page,size:s===d.totalRows?"all":s}))}},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;d<=j;)p[p.length]=d,d+=l?k:1;if(p[p.length]=j,l){for(f=[],e=Math.max(Math.floor(c.maxOptionSize/k)-1,5),n=m-e,n<1&&(n=1),o=m+e,o>j&&(o=j),d=n;d<=o;d++)f[f.length]=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<("all"===c.size?c.totalRows:c.size)&&g.append('')))},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()*("all"===c.size?c.totalRows: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="all"===c.size?c.totalRows:c.size,j=c.page*i,k=j+i,l=0,m=0;for(c.cacheIndex=[],d=0;d=j&&m=j&&m0&&g[e].className.match(b.css.cssHasChild))for(;++e> Ajax Error",f,h,i),b.showError(d,f,h,i),z.$tbodies.eq(0).children("tr").detach(),e.totalRows=0;else{if(a.isArray(D)?(l=isNaN(D[0])&&!isNaN(D[1]),w=D[l?1:0],e.totalRows=isNaN(w)?e.totalRows||0:w,z.totalRows=z.filteredRows=e.filteredRows=e.totalRows,t=0===e.totalRows?[]:D[l?0:1]||[],s=D[2]):(e.ajaxData=D,z.totalRows=e.totalRows=D.total,z.filteredRows=e.filteredRows="undefined"!=typeof D.filteredRows?D.filteredRows:D.total,s=D.headers,t=D.rows||[]),v=t&&t.length,t instanceof jQuery)e.processAjaxOnInit&&(z.$tbodies.eq(0).empty(),z.$tbodies.eq(0).append(t));else if(v){for(j=0;j",k=0;k"+t[j][k]+"";C+=""}e.processAjaxOnInit&&z.$tbodies.eq(0).html(C)}if(e.processAjaxOnInit=!0,s&&s.length===E)for(m=A.hasClass("hasStickyHeaders"),o=m?z.widgetOptions.$sticky.children("thead:first").children("tr:not(."+z.cssIgnoreRow+")").children():"",n=A.find("tfoot tr:first").children(),p=z.$headers.filter("th "),x=p.length,k=0;k> 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:q,i=n?0:q,j=0;jq&&j<=p&&(j++,e.cacheIndex[e.cacheIndex.length]=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="all",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.$container.find(d.cssGoto+","+d.cssPageSize+", .ts-startRow, .ts-page"),h=g.length,f=0;fc&&c>=0&&(b.page=c),b.page},w=function(b,c,d){d.size=u(d,c,"get"),d.$container.find(d.cssPageSize).val(u(d,d.size,"set")),a.data(b,"pagerLastPage",v(b,d)),a.data(b,"pagerLastSize",d.size),d.totalPages="all"===d.size?1:Math.ceil(d.totalRows/d.size),d.filteredPages="all"===d.size?1: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(b,c){var d=b.config;d.pager=a.extend(!0,{},a.tablesorterPager.defaults,c.settings),F(b,c.settings)},D=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},E=function(c,d,e){var f,g,h,i=c.config;d.$container.find(d.cssGoto+","+d.cssPageSize+",.ts-startRow, .ts-page").removeClass(d.cssDisabled).removeAttr("disabled").each(function(){this.ariaDisabled=!1}),d.isDisabled=!1,d.page=a.data(c,"pagerLastPage")||d.page||0,h=d.$container.find(d.cssPageSize),g=h.find("option[selected]").val(),d.size=a.data(c,"pagerLastSize")||u(d,g,"get"),h.val(d.size),d.totalPages="all"===d.size?1:Math.ceil(t(c,d)/d.size),c.id&&!i.$table.attr("aria-describedby")&&(h=d.$container.find(d.cssPageDisplay),f=h.attr("id"),f||(f=c.id+"_pager_info",h.attr("id",f)),i.$table.attr("aria-describedby",f)),j(c,d),e&&(b.update(i),w(c,d.size,d),l(c,d),i.debug&&console.log("Pager: Enabled"))},F=function(e,f){var h,i,m,n,o=e.config,p=o.widgetOptions,t=o.pager=a.extend(!0,{},a.tablesorterPager.defaults,f),v=o.$table,B=o.namespace+"pager",F=t.$container=a(t.container).addClass("tablesorter-pager").show();t.settings=a.extend(!0,{},a.tablesorterPager.defaults,f),o.debug&&console.log("Pager: Initializing"),t.oldAjaxSuccess=t.oldAjaxSuccess||t.ajaxObject.success,o.appender=d.appender,t.initializing=!0,t.savePages&&b.storage&&(h=b.storage(e,t.storageKey)||{},t.page=isNaN(h.page)?t.page:h.page,t.size="all"===h.size?h.size:(isNaN(h.size)?t.size:h.size)||t.setSize||10,a.data(e,"pagerLastSize",t.size),F.find(t.cssPageSize).val(t.size)),t.regexRows=new RegExp("("+(p.filter_filteredRow||"filtered")+"|"+o.selectorRemove.slice(1)+"|"+o.cssChildRow+")"),t.regexFiltered=new RegExp(p.filter_filteredRow||"filtered"),v.unbind(c.split(" ").join(B+" ").replace(/\s+/g," ")).bind("filterInit filterStart ".split(" ").join(B+" "),function(b,c){t.currentFilters=a.isArray(c)?c:o.$table.data("lastSearch"),"filterStart"===b.type&&t.pageReset!==!1&&(o.lastCombinedFilter||"")!==(t.currentFilters||[]).join("")&&(t.page=t.pageReset)}).bind("filterEnd sortEnd ".split(" ").join(B+" "),function(){t.currentFilters=o.$table.data("lastSearch"),(t.initialized||t.initializing)&&(o.delayInit&&o.rowsCopy&&0===o.rowsCopy.length&&r(e),g(e,t,!1),s(e,t,!1),b.applyWidget(e))}).bind("disablePager"+B,function(a){a.stopPropagation(),q(e,t)}).bind("enablePager"+B,function(a){a.stopPropagation(),E(e,t,!0)}).bind("destroyPager"+B,function(a){a.stopPropagation(),D(e,t)}).bind("resetToLoadState"+B,function(a){a.stopPropagation(),C(e,t)}).bind("updateComplete"+B,function(a,b,c){if(a.stopPropagation(),b&&!c&&!t.ajax){var d=o.$tbodies.eq(0).children("tr").not(o.selectorRemove);t.totalRows=d.length-(t.countChildRows?0:d.filter("."+o.cssChildRow).length),t.totalPages="all"===t.size?1:Math.ceil(t.totalRows/t.size),d.length&&o.rowsCopy&&0===o.rowsCopy.length&&r(b),t.page>=t.totalPages&&y(b,t),k(b,t),j(b,t),g(b,t,!0)}}).bind("pageSize refreshComplete ".split(" ").join(B+" "),function(a,b){a.stopPropagation(),w(e,u(t,b,"get"),t),k(e,t),g(e,t,!1)}).bind("pageSet pagerUpdate ".split(" ").join(B+" "),function(a,b){a.stopPropagation(),"pagerUpdate"===a.type&&(b="undefined"==typeof b?t.page+1:b,t.last.page=!0),t.page=(parseInt(b,10)||1)-1,s(e,t,!0),g(e,t,!1)}).bind("pageAndSize"+B,function(a,b,c){a.stopPropagation(),t.page=(parseInt(b,10)||1)-1,w(e,u(t,c,"get"),t),s(e,t,!0),k(e,t),g(e,t,!1)}),i=[t.cssFirst,t.cssPrev,t.cssNext,t.cssLast],m=[x,A,z,y],o.debug&&!F.length&&console.warn("Pager: >> Container not found"),F.find(i.join(",")).attr("tabindex",0).unbind("click"+B).bind("click"+B,function(b){b.stopPropagation();var c,d=a(this),f=i.length;if(!d.hasClass(t.cssDisabled))for(c=0;c> Goto selector not found"),n=F.find(t.cssPageSize),n.length?(n.find("option").removeAttr("selected"),n.unbind("change"+B).bind("change"+B,function(){if(!a(this).hasClass(t.cssDisabled)){var b=a(this).val();t.$container.find(t.cssGoto).val(b),w(e,b,t),j(e,t)}return!1})):o.debug&&console.warn("Pager: >> Size selector not found"),t.initialized=!1,v.triggerHandler("pagerBeforeInitialized",t),E(e,t,!1),"string"==typeof t.ajaxUrl?(t.ajax=!0,o.widgetOptions.filter_serversideFiltering=!0,o.serverSideSorting=!0,s(e,t)):(t.ajax=!1,b.appendCache(o,!0),l(e,t)),t.ajax||t.initialized||(t.initializing=!1,t.initialized=!0,s(e,t),o.debug&&console.log("Pager: Triggering pagerInitialized"),o.$table.triggerHandler("pagerInitialized",t),o.widgetOptions.filter_initialized&&b.hasWidget(e,"filter")||g(e,t,!1)),o.widgetInit.pager=!0};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="all"===e.size?1:Math.ceil(e.totalRows/e.size),p(b,c,e),g(b,e,!1))},d.construct=function(a){return this.each(function(){this.config&&this.hasInitialized&&F(this,a)})}}}),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 c4060b06..08d740d8 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/26/2016 (v2.28.0) */ -!function(a){"use strict";var b,c=a.tablesorter;c.addWidget({id:"pager",priority:55,options:{pager_output:"{startRow} to {endRow} of {totalRows} rows",pager_updateArrows:!0,pager_startPage:0,pager_pageReset:0,pager_size:10,pager_maxOptionSize:20,pager_savePages:!0,pager_storageKey:"tablesorter-pager",pager_fixedHeight:!1,pager_countChildRows:!1,pager_removeRows:!1,pager_ajaxUrl:null,pager_customAjaxUrl:function(a,b){return b},pager_ajaxError:null,pager_ajaxObject:{dataType:"json"},pager_processAjaxOnInit:!0,pager_ajaxProcessing:function(a){return[0,[],null]},pager_css:{container:"tablesorter-pager",errorRow:"tablesorter-errorRow",disabled:"disabled"},pager_selectors:{container:".pager",first:".first",prev:".prev",next:".next",last:".last",gotoPage:".gotoPage",pageDisplay:".pagedisplay",pageSize:".pagesize"}},init:function(a){b.init(a)},format:function(a,c){return c.pager&&c.pager.initialized?void b.moveToPage(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.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="all"===e.size?e.size:(isNaN(e.size)?i.size:e.size)||i.setSize||10,a.data(d,"pagerLastSize",i.size),i.$container.find(h.pageSize).val(i.size)),i.regexRows=new RegExp("("+(g.filter_filteredRow||"filtered")+"|"+f.selectorRemove.slice(1)+"|"+f.cssChildRow+")"),i.regexFiltered=new RegExp(g.filter_filteredRow||"filtered"),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,h=d.pager,i=d.widgetOptions,j=d.namespace+"pager",k=i.pager_selectors;d.$table.off(j).on("filterInit filterStart ".split(" ").join(j+" "),function(b,c){h.currentFilters=a.isArray(c)?c:d.$table.data("lastSearch"),"filterStart"===b.type&&i.pager_pageReset!==!1&&(d.lastCombinedFilter||"")!==(h.currentFilters||[]).join("")&&(h.page=i.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(j+" "),function(){h.currentFilters=d.$table.data("lastSearch"),(h.initialized||h.initializing)&&(d.delayInit&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),b.updatePageDisplay(d,!1),c.applyWidget(d.table))}).on("disablePager"+j,function(a){a.stopPropagation(),b.showAllRows(d)}).on("enablePager"+j,function(a){a.stopPropagation(),b.enablePager(d,!0)}).on("destroyPager"+j,function(a,b){a.stopPropagation(),c.removeWidget(d.table,"pager",!1)}).on("updateComplete"+j,function(a,e,f){if(a.stopPropagation(),e&&!f&&!h.ajax){var g=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);h.totalRows=g.length-(i.pager_countChildRows?0:g.filter("."+d.cssChildRow).length),h.totalPages="all"===h.size?1:Math.ceil(h.totalRows/h.size),g.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),h.page>=h.totalPages&&b.moveToLastPage(d,h),b.hideRows(d),b.changeHeight(d),b.updatePageDisplay(d,!1),c.applyWidget(e),b.updatePageDisplay(d)}}).on("pageSize refreshComplete ".split(" ").join(j+" "),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(j+" "),function(a,c){a.stopPropagation(),"pagerUpdate"===a.type&&(c="undefined"==typeof c?h.page+1:c,h.last.page=!0),h.page=(parseInt(c,10)||1)-1,b.moveToPage(d,h,!0),b.updatePageDisplay(d,!1)}).on("pageAndSize"+j,function(a,c,e){a.stopPropagation(),h.page=(parseInt(c,10)||1)-1,b.setPageSize(d,b.parsePageSize(d,e,"get")),b.moveToPage(d,h,!0),b.hideRows(d),b.updatePageDisplay(d,!1)}),e=[k.first,k.prev,k.next,k.last],f=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],d.debug&&!h.$container.length&&console.warn("Pager: >> Container not found"),h.$container.find(e.join(",")).attr("tabindex",0).off("click"+j).on("click"+j,function(c){c.stopPropagation();var g,j=a(this),k=e.length;if(!j.hasClass(i.pager_css.disabled))for(g=0;g> Goto selector not found"),g=h.$container.find(i.pager_selectors.pageSize),g.length?(g.find("option").removeAttr("selected"),g.off("change"+j).on("change"+j,function(){if(!a(this).hasClass(i.pager_css.disabled)){var c=a(this).val();h.$container.find(i.pager_selectors.pageSize).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).prop("aria-disabled",f),d.$container.find(j.next+","+j.last).toggleClass(i.pager_css.disabled,h).prop("aria-disabled",h))},calcFilters:function(b){var c,d,e,f=b.widgetOptions,g=b.pager,h=b.$table.hasClass("hasFilters");if(h&&!g.ajax)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;d=0){if(g=p*n.page>n.filteredRows&&e,n.page=g?m.pager_pageReset||0:n.page,n.startRow=g?p*n.page+1:0===n.filteredRows?0:p*n.page+1,n.endRow=Math.min(n.filteredRows,n.totalRows,p*(n.page+1)),h=n.$container.find(m.pager_selectors.pageDisplay),f="function"==typeof m.pager_output?m.pager_output(l,n):(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.$container.find(m.pager_selectors.gotoPage).length){for(g="",i=b.buildPageSelect(d,n),k=i.length,j=0;j'+i[j]+"";n.$container.find(m.pager_selectors.gotoPage).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/p)+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:p===n.totalRows?"all":p}))}},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;e<=l;)r[r.length]=e,e+=n?m:1;if(r[r.length]=l,n){for(g=[],f=Math.max(Math.floor(k.pager_maxOptionSize/m)-1,5),p=o-f,p<1&&(p=1),q=o+f,q>l&&(q=l),e=p;e<=q;e++)g[g.length]=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<("all"===f.size?f.totalRows:f.size)&&h.append('')))},changeHeight:function(c){var d,e=c.table,f=c.pager,g="all"===f.size?f.totalRows:f.size,h=c.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),h.children("tr:visible").length||h.append(' '),d=h.children("tr").eq(0).height()*g,a.data(e,"pagerSavedHeight",d),b.fixHeight(c),a.data(e,"pagerLastSize",f.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="all"===h.size?h.totalRows:h.size,l=h.page*k,m=l+k,n=0,o=0;for(h.cacheIndex=[],b=0;b=l&&o=l&&o0&&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(C)?(n=isNaN(C[0])&&!isNaN(C[1]),x=C[n?1:0],j.totalRows=isNaN(x)?j.totalRows||0:x,e.totalRows=e.filteredRows=j.filteredRows=j.totalRows,v=0===j.totalRows?[]:C[n?0:1]||[],u=C[2]):(j.ajaxData=C,e.totalRows=j.totalRows=C.total,e.filteredRows=j.filteredRows="undefined"!=typeof C.filteredRows?C.filteredRows:C.total,u=C.headers,v=C.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;l",m=0;m"+v[l][m]+"";B+=""}k.pager_processAjaxOnInit&&e.$tbodies.eq(0).html(B)}for(k.pager_processAjaxOnInit=!0,o=A.hasClass("hasStickyHeaders"),q=o?k.$sticky.children("thead:first").children("tr").children():"",p=A.find("tfoot tr:first").children(),r=e.$headers.filter("th"),y=r.length,m=0;m> 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:o,g=l?0:o,h=0;ho&&h<=n&&(h++,j.cacheIndex[j.cacheIndex.length]=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="all",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.$container.find(j.pager_selectors.pageSize+","+j.pager_selectors.gotoPage+",.ts-startRow, .ts-page"),g=f.length,e=0;ed&&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.$container.find(c.widgetOptions.pager_selectors.pageSize).val(b.parsePageSize(c,e.size,"set")),a.data(f,"pagerLastPage",b.parsePageNumber(c,e)),a.data(f,"pagerLastSize",e.size),e.totalPages="all"===e.size?1:Math.ceil(e.totalRows/e.size),e.filteredPages="all"===e.size?1: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";if(f){if(f.initialized=!1,a.$table.off(i),f.$container.hide().find(h).off(i),d)return;a.appender=null,b.showAllRows(a),c.storage&&c.storage(e,a.widgetOptions.pager_storageKey,""),f.$container=null,a.pager=null,a.rowsCopy=null}},enablePager:function(d,e){var f,g,h=d.table,i=d.pager,j=d.widgetOptions,k=i.$container.find(j.pager_selectors.pageSize);i.isDisabled=!1,i.page=a.data(h,"pagerLastPage")||i.page||0,g=k.find("option[selected]").val(),i.size=a.data(h,"pagerLastSize")||b.parsePageSize(d,g,"get"),k.val(i.size),i.totalPages="all"===i.size?1:Math.ceil(b.getTotalPages(d,i)/i.size),d.$table.removeClass("pagerDisabled"),h.id&&!d.$table.attr("aria-describedby")&&(k=i.$container.find(j.pager_selectors.pageDisplay),f=k.attr("id"),f||(f=h.id+"_pager_info",k.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="all"===g.size?1: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.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="all"===e.size?e.size:(isNaN(e.size)?i.size:e.size)||i.setSize||10,a.data(d,"pagerLastSize",i.size),i.$container.find(h.pageSize).val(i.size)),i.regexRows=new RegExp("("+(g.filter_filteredRow||"filtered")+"|"+f.selectorRemove.slice(1)+"|"+f.cssChildRow+")"),i.regexFiltered=new RegExp(g.filter_filteredRow||"filtered"),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,h=d.pager,i=d.widgetOptions,j=d.namespace+"pager",k=i.pager_selectors;d.$table.off(j).on("filterInit filterStart ".split(" ").join(j+" "),function(b,c){h.currentFilters=a.isArray(c)?c:d.$table.data("lastSearch"),"filterStart"===b.type&&i.pager_pageReset!==!1&&(d.lastCombinedFilter||"")!==(h.currentFilters||[]).join("")&&(h.page=i.pager_pageReset)}).on("filterEnd sortEnd ".split(" ").join(j+" "),function(){h.currentFilters=d.$table.data("lastSearch"),(h.initialized||h.initializing)&&(d.delayInit&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),b.updatePageDisplay(d,!1),c.applyWidget(d.table))}).on("disablePager"+j,function(a){a.stopPropagation(),b.showAllRows(d)}).on("enablePager"+j,function(a){a.stopPropagation(),b.enablePager(d,!0)}).on("destroyPager"+j,function(a,b){a.stopPropagation(),c.removeWidget(d.table,"pager",!1)}).on("updateComplete"+j,function(a,e,f){if(a.stopPropagation(),e&&!f&&!h.ajax){var g=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);h.totalRows=g.length-(i.pager_countChildRows?0:g.filter("."+d.cssChildRow).length),h.totalPages="all"===h.size?1:Math.ceil(h.totalRows/h.size),g.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(d),h.page>=h.totalPages&&b.moveToLastPage(d,h),b.hideRows(d),b.changeHeight(d),b.updatePageDisplay(d,!1),c.applyWidget(e),b.updatePageDisplay(d)}}).on("pageSize refreshComplete ".split(" ").join(j+" "),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(j+" "),function(a,c){a.stopPropagation(),"pagerUpdate"===a.type&&(c="undefined"==typeof c?h.page+1:c,h.last.page=!0),h.page=(parseInt(c,10)||1)-1,b.moveToPage(d,h,!0),b.updatePageDisplay(d,!1)}).on("pageAndSize"+j,function(a,c,e){a.stopPropagation(),h.page=(parseInt(c,10)||1)-1,b.setPageSize(d,b.parsePageSize(d,e,"get")),b.moveToPage(d,h,!0),b.hideRows(d),b.updatePageDisplay(d,!1)}),e=[k.first,k.prev,k.next,k.last],f=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],d.debug&&!h.$container.length&&console.warn("Pager: >> Container not found"),h.$container.find(e.join(",")).attr("tabindex",0).off("click"+j).on("click"+j,function(c){c.stopPropagation();var g,j=a(this),k=e.length;if(!j.hasClass(i.pager_css.disabled))for(g=0;g> Goto selector not found"),g=h.$container.find(i.pager_selectors.pageSize),g.length?(g.find("option").removeAttr("selected"),g.off("change"+j).on("change"+j,function(){if(!a(this).hasClass(i.pager_css.disabled)){var c=a(this).val();h.$container.find(i.pager_selectors.pageSize).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).prop("aria-disabled",f),d.$container.find(j.next+","+j.last).toggleClass(i.pager_css.disabled,h).prop("aria-disabled",h))},calcFilters:function(b){var c,d,e,f=b.widgetOptions,g=b.pager,h=b.$table.hasClass("hasFilters");if(h&&!g.ajax)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;d=0){if(g=p*n.page>n.filteredRows&&e,n.page=g?m.pager_pageReset||0:n.page,n.startRow=g?p*n.page+1:0===n.filteredRows?0:p*n.page+1,n.endRow=Math.min(n.filteredRows,n.totalRows,p*(n.page+1)),h=n.$container.find(m.pager_selectors.pageDisplay),f="function"==typeof m.pager_output?m.pager_output(l,n):(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.$container.find(m.pager_selectors.gotoPage).length){for(g="",i=b.buildPageSelect(d,n),k=i.length,j=0;j'+i[j]+"";n.$container.find(m.pager_selectors.gotoPage).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/p)+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:p===n.totalRows?"all":p}))}},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;e<=l;)r[r.length]=e,e+=n?m:1;if(r[r.length]=l,n){for(g=[],f=Math.max(Math.floor(k.pager_maxOptionSize/m)-1,5),p=o-f,p<1&&(p=1),q=o+f,q>l&&(q=l),e=p;e<=q;e++)g[g.length]=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<("all"===f.size?f.totalRows:f.size)&&h.append('')))},changeHeight:function(c){var d,e=c.table,f=c.pager,g="all"===f.size?f.totalRows:f.size,h=c.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),h.children("tr:visible").length||h.append(' '),d=h.children("tr").eq(0).height()*g,a.data(e,"pagerSavedHeight",d),b.fixHeight(c),a.data(e,"pagerLastSize",f.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="all"===h.size?h.totalRows:h.size,l=h.page*k,m=l+k,n=0,o=0;for(h.cacheIndex=[],b=0;b=l&&o=l&&o0&&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(C)?(n=isNaN(C[0])&&!isNaN(C[1]),x=C[n?1:0],j.totalRows=isNaN(x)?j.totalRows||0:x,e.totalRows=e.filteredRows=j.filteredRows=j.totalRows,v=0===j.totalRows?[]:C[n?0:1]||[],u=C[2]):(j.ajaxData=C,e.totalRows=j.totalRows=C.total,e.filteredRows=j.filteredRows="undefined"!=typeof C.filteredRows?C.filteredRows:C.total,u=C.headers,v=C.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;l",m=0;m"+v[l][m]+"";B+=""}k.pager_processAjaxOnInit&&e.$tbodies.eq(0).html(B)}for(k.pager_processAjaxOnInit=!0,o=A.hasClass("hasStickyHeaders"),q=o?k.$sticky.children("thead:first").children("tr:not(."+e.cssIgnoreRow+")").children():"",p=A.find("tfoot tr:first").children(),r=e.$headers.filter("th"),y=r.length,m=0;m> 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:o,g=l?0:o,h=0;ho&&h<=n&&(h++,j.cacheIndex[j.cacheIndex.length]=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="all",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.$container.find(j.pager_selectors.pageSize+","+j.pager_selectors.gotoPage+",.ts-startRow, .ts-page"),g=f.length,e=0;ed&&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.$container.find(c.widgetOptions.pager_selectors.pageSize).val(b.parsePageSize(c,e.size,"set")),a.data(f,"pagerLastPage",b.parsePageNumber(c,e)),a.data(f,"pagerLastSize",e.size),e.totalPages="all"===e.size?1:Math.ceil(e.totalRows/e.size),e.filteredPages="all"===e.size?1: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";if(f){if(f.initialized=!1,a.$table.off(i),f.$container.hide().find(h).off(i),d)return;a.appender=null,b.showAllRows(a),c.storage&&c.storage(e,a.widgetOptions.pager_storageKey,""),f.$container=null,a.pager=null,a.rowsCopy=null}},enablePager:function(d,e){var f,g,h=d.table,i=d.pager,j=d.widgetOptions,k=i.$container.find(j.pager_selectors.pageSize);i.isDisabled=!1,i.page=a.data(h,"pagerLastPage")||i.page||0,g=k.find("option[selected]").val(),i.size=a.data(h,"pagerLastSize")||b.parsePageSize(d,g,"get"),k.val(i.size),i.totalPages="all"===i.size?1:Math.ceil(b.getTotalPages(d,i)/i.size),d.$table.removeClass("pagerDisabled"),h.id&&!d.$table.attr("aria-describedby")&&(k=i.$container.find(j.pager_selectors.pageDisplay),f=k.attr("id"),f||(f=h.id+"_pager_info",k.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="all"===g.size?1: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/js/widgets/widget-pager.js b/js/widgets/widget-pager.js index 623e3542..4e34b2a4 100644 --- a/js/widgets/widget-pager.js +++ b/js/widgets/widget-pager.js @@ -775,7 +775,9 @@ } wo.pager_processAjaxOnInit = true; hsh = $table.hasClass( 'hasStickyHeaders' ); - $sh = hsh ? wo.$sticky.children( 'thead:first' ).children( 'tr' ).children() : ''; + $sh = hsh ? + wo.$sticky.children( 'thead:first' ).children( 'tr:not(.' + c.cssIgnoreRow + ')' ).children() : + ''; $f = $table.find( 'tfoot tr:first' ).children(); // don't change td headers (may contain pager) $headers = c.$headers.filter( 'th' ); @@ -794,7 +796,7 @@ $h.find( '.tablesorter-header-inner' ).html( th[ j ] ); if ( hsh && $sh.length ) { // add sticky header to container just in case it contains pager controls - p.$container = p.$container.add($sh); + p.$container = p.$container.add( wo.$sticky ); $sh.eq( j ).find( '.tablesorter-header-inner' ).html( th[ j ] ); } }