mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
1 line
19 KiB
JavaScript
1 line
19 KiB
JavaScript
!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_ajaxObject:{dataType:"json"},pager_processAjaxOnInit:!0,pager_ajaxProcessing:function(){return[0,[],null]},pager_css:{container:"tablesorter-pager",errorRow:"tablesorter-errorRow",disabled:"disabled"},pager_selectors:{container:".pager",first:".first",prev:".prev",next:".next",last:".last",gotoPage:".gotoPage",pageDisplay:".pagedisplay",pageSize:".pagesize"}},init:function(a){b.init(a)},format:function(a,c){return c.pager&&c.pager.initialized?void b.moveToPage(a,c.pager,!1):b.initComplete(a,c)},remove:function(a,c,d,e){b.destroyPager(a,c,e)}}),b=c.pager={init:function(d){if(!d.hasInitialized||!d.config.pager.initialized){var e,f=d.config,g=f.widgetOptions,h=g.pager_selectors,i=f.pager=a.extend({totalPages:0,filteredRows:0,filteredPages:0,currentFilters:[],page:g.pager_startPage,startRow:0,endRow:0,ajaxCounter:0,$size:null,last:{},setSize:g.pager_size,setPage:g.pager_startPage,events:"filterInit filterStart filterEnd sortEnd disable enable destroy updateComplete pageSize pageSet pageAndSize pagerUpdate "},f.pager);i.isInitializing||(i.isInitializing=!0,f.debug&&c.log("Pager initializing"),i.size=a.data(d,"pagerLastSize")||g.pager_size,i.$container=a(h.container).addClass(g.pager_css.container).show(),i.$goto=i.$container.find(h.gotoPage),i.$size=i.$container.find(h.pageSize),i.totalRows=f.$tbodies.eq(0).children("tr").not(g.pager_countChildRows?"":"."+f.cssChildRow).length,i.oldAjaxSuccess=i.oldAjaxSuccess||g.pager_ajaxObject.success,f.appender=b.appender,i.initializing=!0,g.pager_savePages&&c.storage&&(e=c.storage(d,g.pager_storageKey)||{},i.page=(isNaN(e.page)?i.page:e.page)||i.setPage||0,i.size=(isNaN(e.size)?i.size:e.size)||i.setSize||10,a.data(d,"pagerLastSize",i.size)),i.regexRows=new RegExp("("+(g.filter_filteredRow||"filtered")+"|"+f.selectorRemove.slice(1)+"|"+f.cssChildRow+")"),i.initialized=!1,f.$table.trigger("pagerBeforeInitialized",f),b.enablePager(d,f,!1),i.ajaxObject=g.pager_ajaxObject,i.ajaxObject.url=g.pager_ajaxUrl,"string"==typeof g.pager_ajaxUrl?(i.ajax=!0,g.filter_serversideFiltering=!0,f.serverSideSorting=!0,b.moveToPage(d,i)):(i.ajax=!1,f.$table.trigger("appendCache",[{},!0])))}},initComplete:function(a,d){var e=d.pager;b.bindEvents(a,d),b.setPageSize(a,0,d),e.ajax||b.hideRowsSetup(a,d),e.initialized=!0,e.initializing=!1,e.isInitializing=!1,d.$table.trigger("pagerInitialized",d),d.widgetOptions.filter_initialized&&c.hasWidget(a,"filter")||b.updatePageDisplay(a,d,!e.ajax)},bindEvents:function(c,d){var e,f,g=d.pager,h=d.widgetOptions,i=h.pager_selectors;d.$table.off(a.trim(g.events.split(" ").join(".pager "))).on("filterInit.pager filterStart.pager",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.pager sortEnd.pager",function(){g.currentFilters=d.$table.data("lastSearch"),(g.initialized||g.initializing)&&(d.delayInit&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(c),b.updatePageDisplay(c,d,!1),d.$table.trigger("applyWidgets"))}).on("disable.pager",function(a){a.stopPropagation(),b.showAllRows(c,d)}).on("enable.pager",function(a){a.stopPropagation(),b.enablePager(c,d,!0)}).on("destroy.pager",function(a,e){a.stopPropagation(),b.destroyPager(c,d,e)}).on("updateComplete.pager",function(a,c,e){if(a.stopPropagation(),c&&!e){var f=d.$tbodies.eq(0).children("tr").not(d.selectorRemove);g.totalRows=f.length-(h.pager_countChildRows?0:f.filter("."+d.cssChildRow).length),g.totalPages=Math.ceil(g.totalRows/g.size),f.length&&d.rowsCopy&&0===d.rowsCopy.length&&b.updateCache(c),g.page>=g.totalPages&&b.moveToLastPage(c,g),b.hideRows(c,d),b.changeHeight(c,d),b.updatePageDisplay(c,d,!1),d.$table.trigger("applyWidgets"),b.updatePageDisplay(c,d)}}).on("pageSize.pager refreshComplete.pager",function(a,e){a.stopPropagation(),b.setPageSize(c,parseInt(e,10)||g.setSize||10,d),b.hideRows(c,d),b.updatePageDisplay(c,d,!1)}).on("pageSet.pager pagerUpdate.pager",function(a,e){a.stopPropagation(),g.page=(parseInt(e,10)||1)-1,"pagerUpdate"===a.type&&(g.last.page=!0),b.moveToPage(c,g,!0),b.updatePageDisplay(c,d,!1)}).on("pageAndSize.pager",function(a,e,f){a.stopPropagation(),g.page=(parseInt(e,10)||1)-1,b.setPageSize(c,parseInt(f,10)||g.setSize||10,d),b.moveToPage(c,g,!0),b.hideRows(c,d),b.updatePageDisplay(c,d,!1)}),e=[i.first,i.prev,i.next,i.last],f=["moveToFirstPage","moveToPrevPage","moveToNextPage","moveToLastPage"],g.$container.find(e.join(",")).attr("tabindex",0).off("click.pager").on("click.pager",function(d){d.stopPropagation();var i,j=a(this),k=e.length;if(!j.hasClass(h.pager_css.disabled))for(i=0;k>i;i++)if(j.is(e[i])){b[f[i]](c,g);break}}),g.$goto.length&&g.$goto.off("change.pager").on("change.pager",function(){g.page=a(this).val()-1,b.moveToPage(c,g,!0),b.updatePageDisplay(c,d,!1)}),g.$size.length&&(g.$size.find("option").removeAttr("selected"),g.$size.off("change.pager").on("change.pager",function(){return g.$size.val(a(this).val()),a(this).hasClass(h.pager_css.disabled)||(b.setPageSize(c,parseInt(a(this).val(),10),d),b.changeHeight(c,d)),!1}))},pagerArrows:function(a,b){var c=a.pager,d=!!b,e=d||0===c.page,f=Math.min(c.totalPages,c.filteredPages),g=d||c.page===f-1||0===f,h=a.widgetOptions,i=h.pager_selectors;h.pager_updateArrows&&(c.$container.find(i.first+","+i.prev).toggleClass(h.pager_css.disabled,e).attr("aria-disabled",e),c.$container.find(i.next+","+i.last).toggleClass(h.pager_css.disabled,g).attr("aria-disabled",g))},calcFilters:function(b,c){var d=c.widgetOptions,e=c.pager,f=c.$table.hasClass("hasFilters");f&&!d.pager_ajaxUrl?a.isEmptyObject(c.cache)?e.filteredRows=e.totalRows=c.$tbodies.eq(0).children("tr").not(d.pager_countChildRows?"":"."+c.cssChildRow).length:(e.filteredRows=0,a.each(c.cache[0].normalized,function(a,b){e.filteredRows+=e.regexRows.test(b[c.columns].$row[0].className)?0:1})):f||(e.filteredRows=e.totalRows)},updatePageDisplay:function(d,e,f){if(!e.pager.initializing){var g,h,i,j=e.widgetOptions,k=e.pager,l=k.size||k.setSize||10;j.pager_countChildRows&&h.push(e.cssChildRow),k.$size.add(k.$goto).removeClass(j.pager_css.disabled).removeAttr("disabled").attr("aria-disabled","false"),k.totalPages=Math.ceil(k.totalRows/l),e.totalRows=k.totalRows,b.calcFilters(d,e),e.filteredRows=k.filteredRows,k.filteredPages=Math.ceil(k.filteredRows/l)||0,Math.min(k.totalPages,k.filteredPages)>=0&&(h=k.size*k.page>k.filteredRows&&f,k.page=h?j.pager_pageReset||0:k.page,k.startRow=h?k.size*k.page+1:0===k.filteredRows?0:k.size*k.page+1,k.endRow=Math.min(k.filteredRows,k.totalRows,k.size*(k.page+1)),i=k.$container.find(j.pager_selectors.pageDisplay),g=(k.ajaxData&&k.ajaxData.output?k.ajaxData.output||j.pager_output:j.pager_output).replace(/\{page([\-+]\d+)?\}/gi,function(a,b){return k.totalPages?k.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=k.ajaxData,g=/(rows?|pages?)$/i.test(d)?0:"";return/(startRow|page)/.test(e[0])&&"input"===e[1]?(b=(""+("page"===e[0]?k.totalPages:k.totalRows)).length,c="page"===e[0]?k.page+1:k.startRow,'<input type="text" class="ts-'+e[0]+'" style="max-width:'+b+'em" value="'+c+'"/>'):e.length>1&&f&&f[e[0]]?f[e[0]][e[1]]:k[d]||(f?f[d]:g)||g}),k.$goto.length&&(h="",a.each(b.buildPageSelect(k,e),function(a,b){h+='<option value="'+b+'">'+b+"</option>"}),k.$goto.html(h).val(k.page+1)),i.length&&(i["INPUT"===i[0].tagName?"val":"html"](g),i.find(".ts-startRow, .ts-page").off("change.pager").on("change.pager",function(){var b=a(this).val(),c=a(this).hasClass("ts-startRow")?Math.floor(b/k.size)+1:b;e.$table.trigger("pageSet.pager",[c])}))),b.pagerArrows(e),b.fixHeight(d,e),k.initialized&&f!==!1&&(e.$table.trigger("pagerComplete",e),j.pager_savePages&&c.storage&&c.storage(d,j.pager_storageKey,{page:k.page,size:k.size}))}},buildPageSelect:function(b,c){var d,e,f,g,h,i,j=c.widgetOptions,k=Math.min(b.totalPages,b.filteredPages)||1,l=5*Math.ceil(k/j.pager_maxOptionSize/5),m=k>j.pager_maxOptionSize,n=b.page+1,o=l,p=k-l,q=[1],r=m?l:1;for(d=r;k>=d;)q.push(d),d+=m?l:1;if(q.push(k),m){for(f=[],e=Math.max(Math.floor(j.pager_maxOptionSize/l)-1,5),o=n-e,1>o&&(o=1),p=n+e,p>k&&(p=k),d=o;p>=d;d++)f.push(d);q=a.grep(q,function(b,c){return a.inArray(b,q)===c}),h=q.length,i=f.length,h-i>l/2&&h+i>j.pager_maxOptionSize&&(g=Math.floor(h/2)-Math.floor(i/2),Array.prototype.splice.apply(q,[g,i])),q=q.concat(f)}return q=a.grep(q,function(b,c){return a.inArray(b,q)===c}).sort(function(a,b){return a-b})},fixHeight:function(b,c){var d,e,f=c.pager,g=c.widgetOptions,h=c.$tbodies.eq(0);h.find("tr.pagerSavedHeightSpacer").remove(),g.pager_fixedHeight&&!f.isDisabled&&(e=a.data(b,"pagerSavedHeight"),e&&(d=e-h.height(),d>5&&a.data(b,"pagerLastSize")===f.size&&h.children("tr:visible").length<f.size&&h.append('<tr class="pagerSavedHeightSpacer '+c.selectorRemove.slice(1)+'" style="height:'+d+'px;"></tr>')))},changeHeight:function(c,d){var e,f=d.$tbodies.eq(0);f.find("tr.pagerSavedHeightSpacer").remove(),f.children("tr:visible").length||f.append('<tr class="pagerSavedHeightSpacer '+d.selectorRemove.slice(1)+'"><td> </td></tr>'),e=f.children("tr").eq(0).height()*d.pager.size,a.data(c,"pagerSavedHeight",e),b.fixHeight(c,d),a.data(c,"pagerLastSize",d.pager.size)},hideRows:function(a,b){if(!b.widgetOptions.pager_ajaxUrl){var d,e=0,f=b.pager,g=b.widgetOptions,h=b.$tbodies.eq(0).children("tr"),i=h.length,j=f.page*f.size,k=j+f.size,l=g&&g.filter_filteredRow||"filtered",m=0,n=0;for(f.cacheIndex=[],d=0;i>d;d++)h[d].className.match(l)||(n===j&&h[d].className.match(b.cssChildRow)?h[d].style.display="none":(h[d].style.display=n>=j&&k>n?"":"none",m!==n&&n>=j&&k>n&&(f.cacheIndex.push(d),m=n),n+=h[d].className.match(b.cssChildRow+"|"+b.selectorRemove.slice(1))&&!g.pager_countChildRows?0:1,n===k&&"none"!==h[d].style.display&&h[d].className.match(c.css.cssHasChild)&&(e=d)));if(e>0&&h[e].className.match(c.css.cssHasChild))for(;++e<i&&h[e].className.match(b.cssChildRow);)h[e].style.display=""}},hideRowsSetup:function(c,d){var e=d.pager;e.size=parseInt(e.$size.val(),10)||e.size||e.setSize||10,a.data(c,"pagerLastSize",e.size),b.pagerArrows(d),d.widgetOptions.pager_removeRows||(b.hideRows(c,d),d.$table.on("sortEnd.pager filterEnd.pager",function(){b.hideRows(c,d)}))},renderAjax:function(d,e,f,g,h){var i=f.pager,j=f.widgetOptions;if(a.isFunction(j.pager_ajaxProcessing)){var k,l,m,n,o,p,q,r,s,t,u=f.$table,v="",w=j.pager_ajaxProcessing(d,e,g)||[0,[]],x=u.find("thead th").length;if(c.showError(e),h)f.debug&&c.log("Ajax Error",g,h),c.showError(e,h.message+" ("+g.status+")"),f.$tbodies.eq(0).children("tr").detach(),i.totalRows=0;else{if(a.isArray(w)?(m=isNaN(w[0])&&!isNaN(w[1]),t=w[m?1:0],i.totalRows=isNaN(t)?i.totalRows||0:t,f.totalRows=f.filteredRows=i.filteredRows=i.totalRows,r=0===i.totalRows?[""]:w[m?0:1]||[],q=w[2]):(i.ajaxData=w,f.totalRows=i.totalRows=w.total,f.filteredRows=i.filteredRows="undefined"!=typeof w.filteredRows?w.filteredRows:w.total,q=w.headers,r=w.rows),s=r&&r.length,r instanceof jQuery)j.pager_processAjaxOnInit&&(f.$tbodies.eq(0).children("tr").detach(),f.$tbodies.eq(0).append(r));else if(s){for(k=0;s>k;k++){for(v+="<tr>",l=0;l<r[k].length;l++)v+=/^\s*<td/.test(r[k][l])?a.trim(r[k][l]):"<td>"+r[k][l]+"</td>";v+="</tr>"}j.pager_processAjaxOnInit&&f.$tbodies.eq(0).html(v)}j.pager_processAjaxOnInit=!0,q&&q.length===x&&(n=u.hasClass("hasStickyHeaders"),p=n?j.$sticky.children("thead:first").children("tr").children():"",o=u.find("tfoot tr:first").children(),f.$headers.filter("th").each(function(b){var d,e=a(this);e.find("."+c.css.icon).length?(d=e.find("."+c.css.icon).clone(!0),e.find(".tablesorter-header-inner").html(q[b]).append(d),n&&p.length&&(d=p.eq(b).find("."+c.css.icon).clone(!0),p.eq(b).find(".tablesorter-header-inner").html(q[b]).append(d))):(e.find(".tablesorter-header-inner").html(q[b]),n&&p.length&&p.eq(b).find(".tablesorter-header-inner").html(q[b])),o.eq(b).html(q[b])}))}f.showProcessing&&c.isProcessing(e),i.totalPages=Math.ceil(i.totalRows/(i.size||i.setSize||10)),i.last.totalRows=i.totalRows,i.last.currentFilters=i.currentFilters,i.last.sortList=(f.sortList||[]).join(","),i.initializing=!1,b.updatePageDisplay(e,f,!1),u.trigger("updateCache",[function(){i.initialized&&setTimeout(function(){u.trigger("applyWidgets").trigger("pagerChange",i),b.updatePageDisplay(e,f)},0)}])}i.initialized||f.$table.trigger("applyWidgets")},getAjax:function(d,e){var f,g=b.getAjaxUrl(d,e),h=a(document),i=e.pager;""!==g&&(e.showProcessing&&c.isProcessing(d,!0),h.on("ajaxError.pager",function(a,c,f,g){b.renderAjax(null,d,e,c,g),h.off("ajaxError.pager")}),f=++i.ajaxCounter,i.last.ajaxUrl=g,i.ajaxObject.url=g,i.ajaxObject.success=function(a,c,g){f<i.ajaxCounter||(b.renderAjax(a,d,e,g),h.off("ajaxError.pager"),"function"==typeof i.oldAjaxSuccess&&i.oldAjaxSuccess(a))},e.debug&&c.log("ajax initialized",i.ajaxObject),a.ajax(i.ajaxObject))},getAjaxUrl:function(b,d){var e=d.pager,f=d.widgetOptions,g=f.pager_ajaxUrl?f.pager_ajaxUrl.replace(/\{page([\-+]\d+)?\}/,function(a,b){return e.page+(b?parseInt(b,10):0)}).replace(/\{size\}/g,e.size):"",h=d.sortList,i=e.currentFilters||a(b).data("lastSearch")||[],j=g.match(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/),k=g.match(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/),l=[];return j&&(j=j[1],a.each(h,function(a,b){l.push(j+"["+b[0]+"]="+b[1])}),g=g.replace(/\{\s*sort(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):j),l=[]),k&&(k=k[1],a.each(i,function(a,b){b&&l.push(k+"["+a+"]="+encodeURIComponent(b))}),g=g.replace(/\{\s*filter(?:List)?\s*:\s*(\w*)\s*\}/g,l.length?l.join("&"):k),e.currentFilters=i),a.isFunction(f.pager_customAjaxUrl)&&(g=f.pager_customAjaxUrl(b,g)),d.debug&&c.log("Pager ajax url: "+g),g},renderTable:function(a,d){var e,f,g,h,i=a.config,j=i.pager,k=i.widgetOptions,l=i.$table.hasClass("hasFilters"),m=d&&d.length||0,n=j.page*j.size,o=j.size;if(1>m)return void(i.debug&&c.log("Pager: no rows for pager to render"));if(j.page>=j.totalPages)return b.moveToLastPage(a,j);if(j.cacheIndex=[],j.isDisabled=!1,j.initialized&&i.$table.trigger("pagerChange",i),k.pager_removeRows){for(c.clearTableBody(a),e=c.processTbody(a,i.$tbodies.eq(0),!0),f=l?0:n,g=l?0:n,h=0;o>h&&f<d.length;)l&&/filtered/.test(d[f][0].className)||(g++,g>n&&o>=h&&(h++,j.cacheIndex.push(f),e.append(d[f]))),f++;c.processTbody(a,e,!1)}else b.hideRows(a,i);b.updatePageDisplay(a,i),k.pager_startPage=j.page,k.pager_size=j.size,a.isUpdating&&i.$table.trigger("updateComplete",[a,!0])},showAllRows:function(d,e){var f=e.pager,g=e.widgetOptions;f.ajax?b.pagerArrows(e,!0):(f.isDisabled=!0,a.data(d,"pagerLastPage",f.page),a.data(d,"pagerLastSize",f.size),f.page=0,f.size=f.totalRows,f.totalPages=1,e.$table.addClass("pagerDisabled").removeAttr("aria-describedby").find("tr.pagerSavedHeightSpacer").remove(),b.renderTable(d,e.rowsCopy),e.$table.trigger("applyWidgets"),e.debug&&c.log("pager disabled")),f.$size.add(f.$goto).each(function(){a(this).attr("aria-disabled","true").addClass(g.pager_css.disabled)[0].disabled=!0})},updateCache:function(c){var d=c.config,e=d.pager;d.$table.trigger("updateCache",[function(){if(!a.isEmptyObject(c.config.cache)){var f,g=[],h=c.config.cache[0].normalized;for(e.totalRows=h.length,f=0;f<e.totalRows;f++)g.push(h[f][d.columns].$row);d.rowsCopy=g,b.moveToPage(c,e,!0),e.last.currentFilters=[" "]}}])},moveToPage:function(d,e,f){if(!e.isDisabled){if(f!==!1&&e.initialized&&a.isEmptyObject(d.config.cache))return b.updateCache(d);var g,h=d.config,i=h.widgetOptions,j=e.last;e.ajax&&!i.filter_initialized&&c.hasWidget(d,"filter")||(b.calcFilters(d,h),g=Math.min(e.totalPages,e.filteredPages),e.page<0&&(e.page=0),e.page>g-1&&0!==g&&(e.page=g-1),j.currentFilters=""===(j.currentFilters||[]).join("")?[]:j.currentFilters,e.currentFilters=""===(e.currentFilters||[]).join("")?[]:e.currentFilters,(j.page!==e.page||j.size!==e.size||j.totalRows!==e.totalRows||(j.currentFilters||[]).join(",")!==(e.currentFilters||[]).join(",")||(j.ajaxUrl||"")!==(e.ajaxObject.url||"")||(j.optAjaxUrl||"")!==(i.pager_ajaxUrl||"")||j.sortList!==(h.sortList||[]).join(","))&&(h.debug&&c.log("Pager changing to page "+e.page),e.last={page:e.page,size:e.size,sortList:(h.sortList||[]).join(","),totalRows:e.totalRows,currentFilters:e.currentFilters||[],ajaxUrl:e.ajaxObject.url||"",optAjaxUrl:i.pager_ajaxUrl},e.ajax?b.getAjax(d,h):e.ajax||b.renderTable(d,h.rowsCopy),a.data(d,"pagerLastPage",e.page),e.initialized&&f!==!1&&(h.$table.trigger("pageMoved",h).trigger("applyWidgets"),!e.ajax&&d.isUpdating&&h.$table.trigger("updateComplete",[d,!0]))))}},setPageSize:function(c,d,e){var f=e.pager;f.size=d||f.size||f.setSize||10,f.$size.val(f.size),a.data(c,"pagerLastPage",f.page),a.data(c,"pagerLastSize",f.size),f.totalPages=Math.ceil(f.totalRows/f.size),f.filteredPages=Math.ceil(f.filteredRows/f.size),b.moveToPage(c,f,!0)},moveToFirstPage:function(a,c){c.page=0,b.moveToPage(a,c,!0)},moveToLastPage:function(a,c){c.page=Math.min(c.totalPages,c.filteredPages)-1,b.moveToPage(a,c,!0)},moveToNextPage:function(a,c){c.page++,c.page>=Math.min(c.totalPages,c.filteredPages)-1&&(c.page=Math.min(c.totalPages,c.filteredPages)-1),b.moveToPage(a,c,!0)},moveToPrevPage:function(a,c){c.page--,c.page<=0&&(c.page=0),b.moveToPage(a,c,!0)},destroyPager:function(d,e,f){var g=e.pager;g.initialized=!1,e.$table.off(a.trim(g.events.split(" ").join(".pager "))),f||(b.showAllRows(d,e),g.$container.hide(),e.appender=null,delete d.config.rowsCopy,c.storage&&c.storage(d,e.widgetOptions.pager_storageKey,""))},enablePager:function(d,e,f){var g,h=e.pager;h.isDisabled=!1,h.page=a.data(d,"pagerLastPage")||h.page||0,h.size=a.data(d,"pagerLastSize")||parseInt(h.$size.find("option[selected]").val(),10)||h.size||h.setSize||10,h.$size.val(h.size),h.totalPages=Math.ceil(Math.min(h.totalRows,h.filteredRows)/h.size),e.$table.removeClass("pagerDisabled"),d.id&&(g=d.id+"_pager_info",h.$container.find(e.widgetOptions.pager_selectors.pageDisplay).attr("id",g),e.$table.attr("aria-describedby",g)),b.changeHeight(d,e),f&&(e.$table.trigger("updateRows"),b.setPageSize(d,h.size,e),b.hideRowsSetup(d,e),e.debug&&c.log("pager enabled"))},appender:function(c,d){var e=c.config,f=e.widgetOptions,g=e.pager;g.ajax?b.moveToPage(c,g,!0):(e.rowsCopy=d,g.totalRows=f.pager_countChildRows?e.$tbodies.eq(0).children("tr").length:d.length,g.size=a.data(c,"pagerLastSize")||g.size||f.pager_size||g.setSize||10,g.totalPages=Math.ceil(g.totalRows/g.size),b.moveToPage(c,g),b.updatePageDisplay(c,e,!1))}},c.showError=function(b,c){a(b).each(function(){var b,d=this.config,e=d.widgetOptions,f=d.pager&&d.pager.cssErrorRow||e.pager_css&&e.pager_css.errorRow||"tablesorter-errorRow";d&&("undefined"==typeof c?d.$table.find("thead").find(d.selectorRemove).remove():b=a(/tr\>/.test(c)?c:'<tr><td colspan="'+d.columns+'">'+c+"</td></tr>").click(function(){a(this).remove()}).appendTo(d.$table.find("thead:first")).addClass(f+" "+d.selectorRemove.slice(1)).attr({role:"alert","aria-live":"assertive"}))})}}(jQuery); |