mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-12-05 05:04:20 +00:00
2 lines
42 KiB
JavaScript
2 lines
42 KiB
JavaScript
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&"object"==typeof module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return function(b){"use strict";var c=b.tablesorter={version:"2.28.6",parsers:[],widgets:[],defaults:{theme:"default",widthFixed:!1,showProcessing:!1,headerTemplate:"{content}",onRenderTemplate:null,onRenderHeader:null,cancelSelection:!0,tabIndex:!0,dateFormat:"mmddyyyy",sortMultiSortKey:"shiftKey",sortResetKey:"ctrlKey",usNumberFormat:!0,delayInit:!1,serverSideSorting:!1,resort:!0,headers:{},ignoreCase:!0,sortForce:null,sortList:[],sortAppend:null,sortStable:!1,sortInitialOrder:"asc",sortLocaleCompare:!1,sortReset:!1,sortRestart:!1,emptyTo:"bottom",stringTo:"max",duplicateSpan:!0,textExtraction:"basic",textAttribute:"data-text",textSorter:null,numberSorter:null,initWidgets:!0,widgetClass:"widget-{name}",widgets:[],widgetOptions:{zebra:["even","odd"]},initialized:null,tableClass:"",cssAsc:"",cssDesc:"",cssNone:"",cssHeader:"",cssHeaderRow:"",cssProcessing:"",cssChildRow:"tablesorter-childRow",cssInfoBlock:"tablesorter-infoOnly",cssNoSort:"tablesorter-noSort",cssIgnoreRow:"tablesorter-ignoreRow",cssIcon:"tablesorter-icon",cssIconNone:"",cssIconAsc:"",cssIconDesc:"",pointerClick:"click",pointerDown:"mousedown",pointerUp:"mouseup",selectorHeaders:"> thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[],globalize:0,imgAttr:0},css:{table:"tablesorter",cssHasChild:"tablesorter-hasChildRow",childRow:"tablesorter-childRow",colgroup:"tablesorter-colgroup",header:"tablesorter-header",headerRow:"tablesorter-headerRow",headerIn:"tablesorter-header-inner",icon:"tablesorter-icon",processing:"tablesorter-processing",sortAsc:"tablesorter-headerAsc",sortDesc:"tablesorter-headerDesc",sortNone:"tablesorter-headerUnSorted"},language:{sortAsc:"Ascending sort applied, ",sortDesc:"Descending sort applied, ",sortNone:"No sort applied, ",sortDisabled:"sorting is disabled",nextAsc:"activate to apply an ascending sort",nextDesc:"activate to apply a descending sort",nextNone:"activate to remove the sort"},regex:{templateContent:/\{content\}/g,templateIcon:/\{icon\}/g,templateName:/\{name\}/i,spaces:/\s+/g,nonWord:/\W/g,formElements:/(input|select|button|textarea)/i,chunk:/(^([+\-]?(?:\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi,chunks:/(^\\0|\\0$)/,hex:/^0x[0-9a-f]+$/i,comma:/,/g,digitNonUS:/[\s|\.]/g,digitNegativeTest:/^\s*\([.\d]+\)/,digitNegativeReplace:/^\s*\(([.\d]+)\)/,digitTest:/^[\-+(]?\d+[)]?$/,digitReplace:/[,.'"\s]/g},string:{max:1,min:-1,emptymin:1,emptymax:-1,zero:0,none:0,null:0,top:!0,bottom:!1},keyCodes:{enter:13},dates:{},instanceMethods:{},setup:function(a,d){if(!a||!a.tHead||0===a.tBodies.length||a.hasInitialized===!0)return void(d.debug&&(a.hasInitialized?console.warn("Stopping initialization. Tablesorter has already been initialized"):console.error("Stopping initialization! No table, thead or tbody",a)));var e="",f=b(a),g=b.metadata;a.hasInitialized=!1,a.isProcessing=!0,a.config=d,b.data(a,"tablesorter",d),d.debug&&(console[console.group?"group":"log"]("Initializing tablesorter v"+c.version),b.data(a,"startoveralltimer",new Date)),d.supportsDataObject=function(a){return a[0]=parseInt(a[0],10),a[0]>1||1===a[0]&&parseInt(a[1],10)>=4}(b.fn.jquery.split(".")),d.emptyTo=d.emptyTo.toLowerCase(),d.stringTo=d.stringTo.toLowerCase(),d.last={sortList:[],clickedIndex:-1},/tablesorter\-/.test(f.attr("class"))||(e=""!==d.theme?" tablesorter-"+d.theme:""),d.table=a,d.$table=f.addClass(c.css.table+" "+d.tableClass+e).attr("role","grid"),d.$headers=f.find(d.selectorHeaders),d.namespace?d.namespace="."+d.namespace.replace(c.regex.nonWord,""):d.namespace=".tablesorter"+Math.random().toString(16).slice(2),d.$table.children().children("tr").attr("role","row"),d.$tbodies=f.children("tbody:not(."+d.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"}),d.$table.children("caption").length&&(e=d.$table.children("caption")[0],e.id||(e.id=d.namespace.slice(1)+"caption"),d.$table.attr("aria-labelledby",e.id)),d.widgetInit={},d.textExtraction=d.$table.attr("data-text-extraction")||d.textExtraction||"basic",c.buildHeaders(d),c.fixColumnWidth(a),c.addWidgetFromClass(a),c.applyWidgetOptions(a),c.setupParsers(d),d.totalRows=0,c.validateOptions(d),d.delayInit||c.buildCache(d),c.bindEvents(a,d.$headers,!0),c.bindMethods(d),d.supportsDataObject&&void 0!==f.data().sortlist?d.sortList=f.data().sortlist:g&&f.metadata()&&f.metadata().sortlist&&(d.sortList=f.metadata().sortlist),c.applyWidget(a,!0),d.sortList.length>0?c.sortOn(d,d.sortList,{},!d.initWidgets):(c.setHeadersCss(d),d.initWidgets&&c.applyWidget(a,!1)),d.showProcessing&&f.unbind("sortBegin"+d.namespace+" sortEnd"+d.namespace).bind("sortBegin"+d.namespace+" sortEnd"+d.namespace,function(b){clearTimeout(d.timerProcessing),c.isProcessing(a),"sortBegin"===b.type&&(d.timerProcessing=setTimeout(function(){c.isProcessing(a,!0)},500))}),a.hasInitialized=!0,a.isProcessing=!1,d.debug&&(console.log("Overall initialization time:"+c.benchmark(b.data(a,"startoveralltimer"))),d.debug&&console.groupEnd&&console.groupEnd()),f.triggerHandler("tablesorter-initialized",a),"function"==typeof d.initialized&&d.initialized(a)},bindMethods:function(a){var d=a.$table,e=a.namespace,f="sortReset update updateRows updateAll updateHeaders addRows updateCell updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(e+" ");d.unbind(f.replace(c.regex.spaces," ")).bind("sortReset"+e,function(a,b){a.stopPropagation(),c.sortReset(this.config,function(a){a.isApplyingWidgets?setTimeout(function(){c.applyWidget(a,"",b)},100):c.applyWidget(a,"",b)})}).bind("updateAll"+e,function(a,b,d){a.stopPropagation(),c.updateAll(this.config,b,d)}).bind("update"+e+" updateRows"+e,function(a,b,d){a.stopPropagation(),c.update(this.config,b,d)}).bind("updateHeaders"+e,function(a,b){a.stopPropagation(),c.updateHeaders(this.config,b)}).bind("updateCell"+e,function(a,b,d,e){a.stopPropagation(),c.updateCell(this.config,b,d,e)}).bind("addRows"+e,function(a,b,d,e){a.stopPropagation(),c.addRows(this.config,b,d,e)}).bind("updateComplete"+e,function(){this.isUpdating=!1}).bind("sorton"+e,function(a,b,d,e){a.stopPropagation(),c.sortOn(this.config,b,d,e)}).bind("appendCache"+e,function(a,d,e){a.stopPropagation(),c.appendCache(this.config,e),b.isFunction(d)&&d(this)}).bind("updateCache"+e,function(a,b,d){a.stopPropagation(),c.updateCache(this.config,b,d)}).bind("applyWidgetId"+e,function(a,b){a.stopPropagation(),c.applyWidgetId(this,b)}).bind("applyWidgets"+e,function(a,b){a.stopPropagation(),c.applyWidget(this,b)}).bind("refreshWidgets"+e,function(a,b,d){a.stopPropagation(),c.refreshWidgets(this,b,d)}).bind("removeWidget"+e,function(a,b,d){a.stopPropagation(),c.removeWidget(this,b,d)}).bind("destroy"+e,function(a,b,d){a.stopPropagation(),c.destroy(this,b,d)}).bind("resetToLoadState"+e,function(d){d.stopPropagation(),c.removeWidget(this,!0,!1);var e=b.extend(!0,{},a.originalSettings);a=b.extend(!0,{},c.defaults,e),a.originalSettings=e,this.hasInitialized=!1,c.setup(this,a)})},bindEvents:function(a,d,e){a=b(a)[0];var f,g=a.config,h=g.namespace,i=null;e!==!0&&(d.addClass(h.slice(1)+"_extra_headers"),(f=b.fn.closest?d.closest("table")[0]:d.parents("table")[0])&&"TABLE"===f.nodeName&&f!==a&&b(f).addClass(h.slice(1)+"_extra_table")),f=(g.pointerDown+" "+g.pointerUp+" "+g.pointerClick+" sort keyup ").replace(c.regex.spaces," ").split(" ").join(h+" "),d.find(g.selectorSort).add(d.filter(g.selectorSort)).unbind(f).bind(f,function(a,e){var f,h,j,k=b(a.target),l=" "+a.type+" ";if(!(1!==(a.which||a.button)&&!l.match(" "+g.pointerClick+" | sort | keyup ")||" keyup "===l&&a.which!==c.keyCodes.enter||l.match(" "+g.pointerClick+" ")&&void 0!==a.which||l.match(" "+g.pointerUp+" ")&&i!==a.target&&e!==!0)){if(l.match(" "+g.pointerDown+" "))return i=a.target,j=k.jquery.split("."),void("1"===j[0]&&j[1]<4&&a.preventDefault());if(i=null,c.regex.formElements.test(a.target.nodeName)||k.hasClass(g.cssNoSort)||k.parents("."+g.cssNoSort).length>0||k.parents("button").length>0)return!g.cancelSelection;g.delayInit&&c.isEmptyObject(g.cache)&&c.buildCache(g),f=b.fn.closest?b(this).closest("th, td"):/TH|TD/.test(this.nodeName)?b(this):b(this).parents("th, td"),j=d.index(f),g.last.clickedIndex=j<0?f.attr("data-column"):j,h=g.$headers[g.last.clickedIndex],h&&!h.sortDisabled&&c.initSort(g,h,a)}}),g.cancelSelection&&d.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})},buildHeaders:function(a){var d,e,f,g;for(a.headerList=[],a.headerContent=[],a.sortVars=[],a.debug&&(f=new Date),a.columns=c.computeColumnIndex(a.$table.children("thead, tfoot").children("tr")),e=a.cssIcon?'<i class="'+(a.cssIcon===c.css.icon?c.css.icon:a.cssIcon+" "+c.css.icon)+'"></i>':"",a.$headers=b(b.map(a.$table.find(a.selectorHeaders),function(d,f){var g,h,i,j,k,l=b(d);if(!l.parent().hasClass(a.cssIgnoreRow))return g=c.getColumnData(a.table,a.headers,f,!0),a.headerContent[f]=l.html(),""===a.headerTemplate||l.find("."+c.css.headerIn).length||(j=a.headerTemplate.replace(c.regex.templateContent,l.html()).replace(c.regex.templateIcon,l.find("."+c.css.icon).length?"":e),a.onRenderTemplate&&(h=a.onRenderTemplate.apply(l,[f,j]))&&"string"==typeof h&&(j=h),l.html('<div class="'+c.css.headerIn+'">'+j+"</div>")),a.onRenderHeader&&a.onRenderHeader.apply(l,[f,a,a.$table]),i=parseInt(l.attr("data-column"),10),d.column=i,k=c.getOrder(c.getData(l,g,"sortInitialOrder")||a.sortInitialOrder),a.sortVars[i]={count:-1,order:k?a.sortReset?[1,0,2]:[1,0]:a.sortReset?[0,1,2]:[0,1],lockedOrder:!1},k=c.getData(l,g,"lockedOrder")||!1,void 0!==k&&k!==!1&&(a.sortVars[i].lockedOrder=!0,a.sortVars[i].order=c.getOrder(k)?[1,1]:[0,0]),a.headerList[f]=d,l.addClass(c.css.header+" "+a.cssHeader).parent().addClass(c.css.headerRow+" "+a.cssHeaderRow).attr("role","row"),a.tabIndex&&l.attr("tabindex",0),d})),a.$headerIndexed=[],g=0;g<a.columns;g++)c.isEmptyObject(a.sortVars[g])&&(a.sortVars[g]={}),d=a.$headers.filter('[data-column="'+g+'"]'),a.$headerIndexed[g]=d.length?d.not(".sorter-false").length?d.not(".sorter-false").filter(":last"):d.filter(":last"):b();a.$table.find(a.selectorHeaders).attr({scope:"col",role:"columnheader"}),c.updateHeader(a),a.debug&&(console.log("Built headers:"+c.benchmark(f)),console.log(a.$headers))},addInstanceMethods:function(a){b.extend(c.instanceMethods,a)},setupParsers:function(a,b){var d,e,f,g,h,i,j,k,l,m,n,o,p,q,r=a.table,s=0,t={};if(a.$tbodies=a.$table.children("tbody:not(."+a.cssInfoBlock+")"),p=void 0===b?a.$tbodies:b,0===(q=p.length))return a.debug?console.warn("Warning: *Empty table!* Not building a parser cache"):"";for(a.debug&&(o=new Date,console[console.group?"group":"log"]("Detecting parsers for each column")),e={extractors:[],parsers:[]};s<q;){if(d=p[s].rows,d.length)for(h=0,g=a.columns,i=0;i<g;i++){if((j=a.$headerIndexed[h])&&j.length&&(k=c.getColumnData(r,a.headers,h),n=c.getParserById(c.getData(j,k,"extractor")),m=c.getParserById(c.getData(j,k,"sorter")),l="false"===c.getData(j,k,"parser"),a.empties[h]=(c.getData(j,k,"empty")||a.emptyTo||(a.emptyToBottom?"bottom":"top")).toLowerCase(),a.strings[h]=(c.getData(j,k,"string")||a.stringTo||"max").toLowerCase(),l&&(m=c.getParserById("no-parser")),n||(n=!1),m||(m=c.detectParserForColumn(a,d,-1,h)),a.debug&&(t["("+h+") "+j.text()]={parser:m.id,extractor:n?n.id:"none",string:a.strings[h],empty:a.empties[h]}),e.parsers[h]=m,e.extractors[h]=n,(f=j[0].colSpan-1)>0))for(h+=f,g+=f;f+1>0;)e.parsers[h-f]=m,e.extractors[h-f]=n,f--;h++}s+=e.parsers.length?q:1}a.debug&&(c.isEmptyObject(t)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](t),console.log("Completed detecting parsers"+c.benchmark(o)),console.groupEnd&&console.groupEnd()),a.parsers=e.parsers,a.extractors=e.extractors},addParser:function(a){var b,d=c.parsers.length,e=!0;for(b=0;b<d;b++)c.parsers[b].id.toLowerCase()===a.id.toLowerCase()&&(e=!1);e&&(c.parsers[c.parsers.length]=a)},getParserById:function(a){if("false"==a)return!1;var b,d=c.parsers.length;for(b=0;b<d;b++)if(c.parsers[b].id.toLowerCase()===a.toString().toLowerCase())return c.parsers[b];return!1},detectParserForColumn:function(a,d,e,f){for(var g,h,i,j=c.parsers.length,k=!1,l="",m=!0;""===l&&m;)e++,i=d[e],i&&e<50?i.className.indexOf(c.cssIgnoreRow)<0&&(k=d[e].cells[f],l=c.getElementText(a,k,f),h=b(k),a.debug&&console.log("Checking if value was empty on row "+e+", column: "+f+': "'+l+'"')):m=!1;for(;--j>=0;)if((g=c.parsers[j])&&"text"!==g.id&&g.is&&g.is(l,a.table,k,h))return g;return c.getParserById("text")},getElementText:function(a,d,e){if(!d)return"";var f,g=a.textExtraction||"",h=d.jquery?d:b(d);return"string"==typeof g?"basic"===g&&void 0!==(f=h.attr(a.textAttribute))?b.trim(f):b.trim(d.textContent||h.text()):"function"==typeof g?b.trim(g(h[0],a.table,e)):"function"==typeof(f=c.getColumnData(a.table,g,e))?b.trim(f(h[0],a.table,e)):b.trim(h[0].textContent||h.text())},getParsedText:function(a,b,d,e){void 0===e&&(e=c.getElementText(a,b,d));var f=""+e,g=a.parsers[d],h=a.extractors[d];return g&&(h&&"function"==typeof h.format&&(e=h.format(e,a.table,b,d)),f="no-parser"===g.id?"":g.format(""+e,a.table,b,d),a.ignoreCase&&"string"==typeof f&&(f=f.toLowerCase())),f},buildCache:function(a,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B=a.table,C=a.parsers;if(a.$tbodies=a.$table.children("tbody:not(."+a.cssInfoBlock+")"),l=void 0===e?a.$tbodies:e,a.cache={},a.totalRows=0,!C)return a.debug?console.warn("Warning: *Empty table!* Not building a cache"):"";for(a.debug&&(q=new Date),a.showProcessing&&c.isProcessing(B,!0),k=0;k<l.length;k++){for(u=[],f=a.cache[k]={normalized:[]},r=l[k]&&l[k].rows.length||0,i=0;i<r;++i)if(s={child:[],raw:[]},m=b(l[k].rows[i]),n=[],!m.hasClass(a.selectorRemove.slice(1)))if(m.hasClass(a.cssChildRow)&&0!==i)for(z=f.normalized.length-1,t=f.normalized[z][a.columns],t.$row=t.$row.add(m),m.prev().hasClass(a.cssChildRow)||m.prev().addClass(c.css.cssHasChild),o=m.children("th, td"),z=t.child.length,t.child[z]=[],w=0,y=a.columns,j=0;j<y;j++)p=o[j],p&&(t.child[z][j]=c.getParsedText(a,p,j),(v=o[j].colSpan-1)>0&&(w+=v,y+=v)),w++;else{for(s.$row=m,s.order=i,w=0,y=a.columns,j=0;j<y;++j){if((p=m[0].cells[j])&&w<a.columns&&(x=void 0!==C[w],!x&&a.debug&&console.warn("No parser found for row: "+i+", column: "+j+'; cell containing: "'+b(p).text()+'"; does it have a header?'),g=c.getElementText(a,p,w),s.raw[w]=g,h=c.getParsedText(a,p,w,g),n[w]=h,x&&"numeric"===(C[w].type||"").toLowerCase()&&(u[w]=Math.max(Math.abs(h)||0,u[w]||0)),(v=p.colSpan-1)>0)){for(A=0;A<=v;)h=a.duplicateSpan||0===A?g:"string"!=typeof a.textExtraction?c.getElementText(a,p,w+A)||"":"",s.raw[w+A]=h,n[w+A]=h,A++;w+=v,y+=v}w++}n[a.columns]=s,f.normalized[f.normalized.length]=n}f.colMax=u,a.totalRows+=f.normalized.length}if(a.showProcessing&&c.isProcessing(B),a.debug){for(z=Math.min(5,a.cache[0].normalized.length),console[console.group?"group":"log"]("Building cache for "+a.totalRows+" rows (showing "+z+" rows in log) and "+a.columns+" columns"+c.benchmark(q)),g={},j=0;j<a.columns;j++)for(w=0;w<z;w++)g["row: "+w]||(g["row: "+w]={}),g["row: "+w][a.$headerIndexed[j].text()]=a.cache[0].normalized[w][j];console[console.table?"table":"log"](g),console.groupEnd&&console.groupEnd()}b.isFunction(d)&&d(B)},getColumnText:function(a,d,e,f){a=b(a)[0];var g,h,i,j,k,l,m,n,o,p,q="function"==typeof e,r="all"===d,s={raw:[],parsed:[],$cell:[]},t=a.config;if(!c.isEmptyObject(t)){for(k=t.$tbodies.length,g=0;g<k;g++)for(i=t.cache[g].normalized,l=i.length,h=0;h<l;h++)j=i[h],f&&!j[t.columns].$row.is(f)||(p=!0,n=r?j.slice(0,t.columns):j[d],j=j[t.columns],m=r?j.raw:j.raw[d],o=r?j.$row.children():j.$row.children().eq(d),q&&(p=e({tbodyIndex:g,rowIndex:h,parsed:n,raw:m,$row:j.$row,$cell:o})),p!==!1&&(s.parsed[s.parsed.length]=n,s.raw[s.raw.length]=m,s.$cell[s.$cell.length]=o));return s}t.debug&&console.warn("No cache found - aborting getColumnText function!")},setHeadersCss:function(a){var d,e,f,g=a.sortList,h=g.length,i=c.css.sortNone+" "+a.cssNone,j=[c.css.sortAsc+" "+a.cssAsc,c.css.sortDesc+" "+a.cssDesc],k=[a.cssIconAsc,a.cssIconDesc,a.cssIconNone],l=["ascending","descending"],m=a.$table.find("tfoot tr").children("td, th").add(b(a.namespace+"_extra_headers")).removeClass(j.join(" "));for(a.$headers.add(b("thead "+a.namespace+"_extra_headers")).removeClass(j.join(" ")).addClass(i).attr("aria-sort","none").find("."+c.css.icon).removeClass(k.join(" ")).addClass(k[2]),e=0;e<h;e++)if(2!==g[e][1]&&(d=a.$headers.filter(function(b){for(var d=!0,e=a.$headers.eq(b),f=parseInt(e.attr("data-column"),10),g=f+a.$headers[b].colSpan;f<g;f++)d=!!d&&(d||c.isValueInArray(f,a.sortList)>-1);return d}),d=d.not(".sorter-false").filter('[data-column="'+g[e][0]+'"]'+(1===h?":last":"")),d.length)){for(f=0;f<d.length;f++)d[f].sortDisabled||d.eq(f).removeClass(i).addClass(j[g[e][1]]).attr("aria-sort",l[g[e][1]]).find("."+c.css.icon).removeClass(k[2]).addClass(k[g[e][1]]);m.length&&m.filter('[data-column="'+g[e][0]+'"]').removeClass(i).addClass(j[g[e][1]])}for(h=a.$headers.length,e=0;e<h;e++)c.setColumnAriaLabel(a,a.$headers.eq(e))},setColumnAriaLabel:function(a,d,e){if(d.length){var f=parseInt(d.attr("data-column"),10),g=a.sortVars[f],h=d.hasClass(c.css.sortAsc)?"sortAsc":d.hasClass(c.css.sortDesc)?"sortDesc":"sortNone",i=b.trim(d.text())+": "+c.language[h];d.hasClass("sorter-false")||e===!1?i+=c.language.sortDisabled:(h=(g.count+1)%g.order.length,e=g.order[h],i+=c.language[0===e?"nextAsc":1===e?"nextDesc":"nextNone"]),d.attr("aria-label",i)}},updateHeader:function(a){var b,d,e,f,g=a.table,h=a.$headers.length;for(b=0;b<h;b++)e=a.$headers.eq(b),f=c.getColumnData(g,a.headers,b,!0),d="false"===c.getData(e,f,"sorter")||"false"===c.getData(e,f,"parser"),c.setColumnSort(a,e,d)},setColumnSort:function(a,b,c){var d=a.table.id;b[0].sortDisabled=c,b[c?"addClass":"removeClass"]("sorter-false").attr("aria-disabled",""+c),a.tabIndex&&(c?b.removeAttr("tabindex"):b.attr("tabindex","0")),d&&(c?b.removeAttr("aria-controls"):b.attr("aria-controls",d))},updateHeaderSortCount:function(a,d){var e,f,g,h,i,j,k,l,m=d||a.sortList,n=m.length;for(a.sortList=[],h=0;h<n;h++)if(k=m[h],(e=parseInt(k[0],10))<a.columns){switch(a.sortVars[e].order||(l=c.getOrder(a.sortInitialOrder)?a.sortReset?[1,0,2]:[1,0]:a.sortReset?[0,1,2]:[0,1],a.sortVars[e].order=l,a.sortVars[e].count=0),l=a.sortVars[e].order,f=(""+k[1]).match(/^(1|d|s|o|n)/),f=f?f[0]:""){case"1":case"d":f=1;break;case"s":f=i||0;break;case"o":j=l[(i||0)%l.length],f=0===j?1:1===j?0:2;break;case"n":f=l[++a.sortVars[e].count%l.length];break;default:f=0}i=0===h?f:i,g=[e,parseInt(f,10)||0],a.sortList[a.sortList.length]=g,f=b.inArray(g[1],l),a.sortVars[e].count=f>=0?f:g[1]%l.length}},updateAll:function(a,b,d){var e=a.table;e.isUpdating=!0,c.refreshWidgets(e,!0,!0),c.buildHeaders(a),c.bindEvents(e,a.$headers,!0),c.bindMethods(a),c.commonUpdate(a,b,d)},update:function(a,b,d){a.table.isUpdating=!0,c.updateHeader(a),c.commonUpdate(a,b,d)},updateHeaders:function(a,b){a.table.isUpdating=!0,c.buildHeaders(a),c.bindEvents(a.table,a.$headers,!0),c.resortComplete(a,b)},updateCell:function(a,d,e,f){if(c.isEmptyObject(a.cache))return c.updateHeader(a),void c.commonUpdate(a,e,f);a.table.isUpdating=!0,a.$table.find(a.selectorRemove).remove();var g,h,i,j,k,l,m=a.$tbodies,n=b(d),o=m.index(b.fn.closest?n.closest("tbody"):n.parents("tbody").filter(":first")),p=a.cache[o],q=b.fn.closest?n.closest("tr"):n.parents("tr").filter(":first");if(d=n[0],m.length&&o>=0){if(i=m.eq(o).find("tr").index(q),k=p.normalized[i],(l=q[0].cells.length)!==a.columns)for(j=0,g=!1,h=0;h<l;h++)g||q[0].cells[h]===d?g=!0:j+=q[0].cells[h].colSpan;else j=n.index();g=c.getElementText(a,d,j),k[a.columns].raw[j]=g,g=c.getParsedText(a,d,j,g),k[j]=g,k[a.columns].$row=q,"numeric"===(a.parsers[j].type||"").toLowerCase()&&(p.colMax[j]=Math.max(Math.abs(g)||0,p.colMax[j]||0)),g="undefined"!==e?e:a.resort,g!==!1?c.checkResort(a,g,f):c.resortComplete(a,f)}else a.debug&&console.error("updateCell aborted, tbody missing or not within the indicated table"),a.table.isUpdating=!1},addRows:function(d,e,f,g){var h,i,j,k,l,m,n,o,p,q,r,s,t,u="string"==typeof e&&1===d.$tbodies.length&&/<tr/.test(e||""),v=d.table;if(u)e=b(e),d.$tbodies.append(e);else if(!(e&&e instanceof a&&(b.fn.closest?e.closest("table")[0]:e.parents("table")[0])===d.table))return d.debug&&console.error("addRows method requires (1) a jQuery selector reference to rows that have already been added to the table, or (2) row HTML string to be added to a table with only one tbody"),!1;if(v.isUpdating=!0,c.isEmptyObject(d.cache))c.updateHeader(d),c.commonUpdate(d,f,g);else{for(l=e.filter("tr").attr("role","row").length,j=d.$tbodies.index(e.parents("tbody").filter(":first")),d.parsers&&d.parsers.length||c.setupParsers(d),k=0;k<l;k++){for(p=0,n=e[k].cells.length,o=d.cache[j].normalized.length,r=[],q={child:[],raw:[],$row:e.eq(k),order:o},m=0;m<n;m++)s=e[k].cells[m],h=c.getElementText(d,s,p),q.raw[p]=h,i=c.getParsedText(d,s,p,h),r[p]=i,"numeric"===(d.parsers[p].type||"").toLowerCase()&&(d.cache[j].colMax[p]=Math.max(Math.abs(i)||0,d.cache[j].colMax[p]||0)),t=s.colSpan-1,t>0&&(p+=t),p++;r[d.columns]=q,d.cache[j].normalized[o]=r}c.checkResort(d,f,g)}},updateCache:function(a,b,d){a.parsers&&a.parsers.length||c.setupParsers(a,d),c.buildCache(a,b,d)},appendCache:function(a,b){var d,e,f,g,h,i,j,k=a.table,l=a.widgetOptions,m=a.$tbodies,n=[],o=a.cache;if(c.isEmptyObject(o))return a.appender?a.appender(k,n):k.isUpdating?a.$table.triggerHandler("updateComplete",k):"";for(a.debug&&(j=new Date),i=0;i<m.length;i++)if(f=m.eq(i),f.length){for(g=c.processTbody(k,f,!0),d=o[i].normalized,e=d.length,h=0;h<e;h++)n[n.length]=d[h][a.columns].$row,a.appender&&(!a.pager||a.pager.removeRows&&l.pager_removeRows||a.pager.ajax)||g.append(d[h][a.columns].$row);c.processTbody(k,g,!1)}a.appender&&a.appender(k,n),a.debug&&console.log("Rebuilt table"+c.benchmark(j)),b||a.appender||c.applyWidget(k),k.isUpdating&&a.$table.triggerHandler("updateComplete",k)},commonUpdate:function(a,b,d){a.$table.find(a.selectorRemove).remove(),c.setupParsers(a),c.buildCache(a),c.checkResort(a,b,d)},initSort:function(a,d,e){if(a.table.isUpdating)return setTimeout(function(){c.initSort(a,d,e)},50);var f,g,h,i,j,k,l,m=!e[a.sortMultiSortKey],n=a.table,o=a.$headers.length,p=parseInt(b(d).attr("data-column"),10),q=a.sortVars[p].order;if(a.$table.triggerHandler("sortStart",n),k=(a.sortVars[p].count+1)%q.length,a.sortVars[p].count=e[a.sortResetKey]?2:k,a.sortRestart)for(h=0;h<o;h++)l=a.$headers.eq(h),k=parseInt(l.attr("data-column"),10),p!==k&&(m||l.hasClass(c.css.sortNone))&&(a.sortVars[k].count=-1);if(m){if(a.sortList=[],a.last.sortList=[],null!==a.sortForce)for(f=a.sortForce,g=0;g<f.length;g++)f[g][0]!==p&&(a.sortList[a.sortList.length]=f[g]);if((i=q[a.sortVars[p].count])<2&&(a.sortList[a.sortList.length]=[p,i],d.colSpan>1))for(g=1;g<d.colSpan;g++)a.sortList[a.sortList.length]=[p+g,i],a.sortVars[p+g].count=b.inArray(i,q)}else if(a.sortList=b.extend([],a.last.sortList),c.isValueInArray(p,a.sortList)>=0)for(g=0;g<a.sortList.length;g++)k=a.sortList[g],k[0]===p&&(k[1]=q[a.sortVars[p].count],2===k[1]&&(a.sortList.splice(g,1),a.sortVars[p].count=-1));else if((i=q[a.sortVars[p].count])<2&&(a.sortList[a.sortList.length]=[p,i],d.colSpan>1))for(g=1;g<d.colSpan;g++)a.sortList[a.sortList.length]=[p+g,i],a.sortVars[p+g].count=b.inArray(i,q);if(a.last.sortList=b.extend([],a.sortList),a.sortList.length&&a.sortAppend&&(f=b.isArray(a.sortAppend)?a.sortAppend:a.sortAppend[a.sortList[0][0]],!c.isEmptyObject(f)))for(g=0;g<f.length;g++)if(f[g][0]!==p&&c.isValueInArray(f[g][0],a.sortList)<0){if(i=f[g][1],j=(""+i).match(/^(a|d|s|o|n)/))switch(k=a.sortList[0][1],j[0]){case"d":i=1;break;case"s":i=k;break;case"o":i=0===k?1:0;break;case"n":i=(k+1)%q.length;break;default:i=0}a.sortList[a.sortList.length]=[f[g][0],i]}a.$table.triggerHandler("sortBegin",n),setTimeout(function(){c.setHeadersCss(a),c.multisort(a),c.appendCache(a),a.$table.triggerHandler("sortBeforeEnd",n),a.$table.triggerHandler("sortEnd",n)},1)},multisort:function(a){var b,d,e,f,g,h=a.table,i=[],j=0,k=a.textSorter||"",l=a.sortList,m=l.length,n=a.$tbodies.length;if(!a.serverSideSorting&&!c.isEmptyObject(a.cache)){if(a.debug&&(d=new Date),"object"==typeof k)for(e=a.columns;e--;)"function"==typeof(g=c.getColumnData(h,k,e))&&(i[e]=g);for(b=0;b<n;b++)e=a.cache[b].colMax,f=a.cache[b].normalized,f.sort(function(b,d){var f,g,n,o,p,q,r;for(f=0;f<m;f++){if(n=l[f][0],o=l[f][1],j=0===o,a.sortStable&&b[n]===d[n]&&1===m)return b[a.columns].order-d[a.columns].order;if(g=/n/i.test(c.getSortType(a.parsers,n)),g&&a.strings[n]?(g="boolean"==typeof c.string[a.strings[n]]?(j?1:-1)*(c.string[a.strings[n]]?-1:1):a.strings[n]?c.string[a.strings[n]]||0:0,p=a.numberSorter?a.numberSorter(b[n],d[n],j,e[n],h):c["sortNumeric"+(j?"Asc":"Desc")](b[n],d[n],g,e[n],n,a)):(q=j?b:d,r=j?d:b,p="function"==typeof k?k(q[n],r[n],j,n,h):"function"==typeof i[n]?i[n](q[n],r[n],j,n,h):c["sortNatural"+(j?"Asc":"Desc")](b[n],d[n],n,a)),p)return p}return b[a.columns].order-d[a.columns].order});a.debug&&console.log("Applying sort "+l.toString()+c.benchmark(d))}},resortComplete:function(a,c){a.table.isUpdating&&a.$table.triggerHandler("updateComplete",a.table),b.isFunction(c)&&c(a.table)},checkResort:function(a,d,e){var f=b.isArray(d)?d:a.sortList;(void 0===d?a.resort:d)===!1||a.serverSideSorting||a.table.isProcessing?(c.resortComplete(a,e),c.applyWidget(a.table,!1)):f.length?c.sortOn(a,f,function(){c.resortComplete(a,e)},!0):c.sortReset(a,function(){c.resortComplete(a,e),c.applyWidget(a.table,!1)})},sortOn:function(a,d,e,f){var g=a.table;a.$table.triggerHandler("sortStart",g),c.updateHeaderSortCount(a,d),c.setHeadersCss(a),a.delayInit&&c.isEmptyObject(a.cache)&&c.buildCache(a),a.$table.triggerHandler("sortBegin",g),c.multisort(a),c.appendCache(a,f),a.$table.triggerHandler("sortBeforeEnd",g),a.$table.triggerHandler("sortEnd",g),c.applyWidget(g),b.isFunction(e)&&e(g)},sortReset:function(a,d){a.sortList=[],c.setHeadersCss(a),c.multisort(a),c.appendCache(a);var e;for(e=0;e<a.columns;e++)a.sortVars[e].count=-1;b.isFunction(d)&&d(a.table)},getSortType:function(a,b){return a&&a[b]?a[b].type||"":""},getOrder:function(a){return/^d/i.test(a)||1===a},sortNatural:function(a,b){if(a===b)return 0;var d,e,f,g,h,i,j=c.regex;if(j.hex.test(b)){if(d=parseInt((a||"").match(j.hex),16),e=parseInt((b||"").match(j.hex),16),d<e)return-1;if(d>e)return 1}for(d=(a||"").replace(j.chunk,"\\0$1\\0").replace(j.chunks,"").split("\\0"),e=(b||"").replace(j.chunk,"\\0$1\\0").replace(j.chunks,"").split("\\0"),i=Math.max(d.length,e.length),h=0;h<i;h++){if(f=isNaN(d[h])?d[h]||0:parseFloat(d[h])||0,g=isNaN(e[h])?e[h]||0:parseFloat(e[h])||0,isNaN(f)!==isNaN(g))return isNaN(f)?1:-1;if(typeof f!=typeof g&&(f+="",g+=""),f<g)return-1;if(f>g)return 1}return 0},sortNaturalAsc:function(a,b,d,e){if(a===b)return 0;var f=c.string[e.empties[d]||e.emptyTo];return""===a&&0!==f?"boolean"==typeof f?f?-1:1:-f||-1:""===b&&0!==f?"boolean"==typeof f?f?1:-1:f||1:c.sortNatural(a,b)},sortNaturalDesc:function(a,b,d,e){if(a===b)return 0;var f=c.string[e.empties[d]||e.emptyTo];return""===a&&0!==f?"boolean"==typeof f?f?-1:1:f||1:""===b&&0!==f?"boolean"==typeof f?f?1:-1:-f||-1:c.sortNatural(b,a)},sortText:function(a,b){return a>b?1:a<b?-1:0},getTextValue:function(a,b,c){if(c){var d,e=a?a.length:0,f=c+b;for(d=0;d<e;d++)f+=a.charCodeAt(d);return b*f}return 0},sortNumericAsc:function(a,b,d,e,f,g){if(a===b)return 0;var h=c.string[g.empties[f]||g.emptyTo];return""===a&&0!==h?"boolean"==typeof h?h?-1:1:-h||-1:""===b&&0!==h?"boolean"==typeof h?h?1:-1:h||1:(isNaN(a)&&(a=c.getTextValue(a,d,e)),isNaN(b)&&(b=c.getTextValue(b,d,e)),a-b)},sortNumericDesc:function(a,b,d,e,f,g){if(a===b)return 0;var h=c.string[g.empties[f]||g.emptyTo];return""===a&&0!==h?"boolean"==typeof h?h?-1:1:h||1:""===b&&0!==h?"boolean"==typeof h?h?1:-1:-h||-1:(isNaN(a)&&(a=c.getTextValue(a,d,e)),isNaN(b)&&(b=c.getTextValue(b,d,e)),b-a)},sortNumeric:function(a,b){return a-b},addWidget:function(a){a.id&&!c.isEmptyObject(c.getWidgetById(a.id))&&console.warn('"'+a.id+'" widget was loaded more than once!'),c.widgets[c.widgets.length]=a},hasWidget:function(a,c){return a=b(a),a.length&&a[0].config&&a[0].config.widgetInit[c]||!1},getWidgetById:function(a){var b,d,e=c.widgets.length;for(b=0;b<e;b++)if((d=c.widgets[b])&&d.id&&d.id.toLowerCase()===a.toLowerCase())return d},applyWidgetOptions:function(a){var d,e,f,g=a.config,h=g.widgets.length;if(h)for(d=0;d<h;d++)(e=c.getWidgetById(g.widgets[d]))&&e.options&&(f=b.extend({},e.options),g.widgetOptions=b.extend(!0,f,g.widgetOptions),b.extend(!0,c.defaults.widgetOptions,e.options))},addWidgetFromClass:function(a){var b,d,e=a.config,f="^"+e.widgetClass.replace(c.regex.templateName,"(\\S+)+")+"$",g=new RegExp(f,"g"),h=(a.className||"").split(c.regex.spaces);if(h.length)for(b=h.length,d=0;d<b;d++)h[d].match(g)&&(e.widgets[e.widgets.length]=h[d].replace(g,"$1"))},applyWidgetId:function(a,d,e){a=b(a)[0];var f,g,h,i=a.config,j=i.widgetOptions,k=c.getWidgetById(d);k&&(h=k.id,f=!1,b.inArray(h,i.widgets)<0&&(i.widgets[i.widgets.length]=h),i.debug&&(g=new Date),!e&&i.widgetInit[h]||(i.widgetInit[h]=!0,a.hasInitialized&&c.applyWidgetOptions(a),"function"==typeof k.init&&(f=!0,i.debug&&console[console.group?"group":"log"]("Initializing "+h+" widget"),k.init(a,k,i,j))),e||"function"!=typeof k.format||(f=!0,i.debug&&console[console.group?"group":"log"]("Updating "+h+" widget"),k.format(a,i,j,!1)),i.debug&&f&&(console.log("Completed "+(e?"initializing ":"applying ")+h+" widget"+c.benchmark(g)),console.groupEnd&&console.groupEnd()))},applyWidget:function(a,d,e){a=b(a)[0];var f,g,h,i,j,k=a.config,l=[];if(d===!1||!a.hasInitialized||!a.isApplyingWidgets&&!a.isUpdating){if(k.debug&&(j=new Date),c.addWidgetFromClass(a),clearTimeout(k.timerReady),k.widgets.length){for(a.isApplyingWidgets=!0,k.widgets=b.grep(k.widgets,function(a,c){return b.inArray(a,k.widgets)===c}),h=k.widgets||[],g=h.length,f=0;f<g;f++)i=c.getWidgetById(h[f]),i&&i.id?(i.priority||(i.priority=10),l[f]=i):k.debug&&console.warn('"'+h[f]+'" widget code does not exist!');for(l.sort(function(a,b){return a.priority<b.priority?-1:a.priority===b.priority?0:1}),g=l.length,k.debug&&console[console.group?"group":"log"]("Start "+(d?"initializing":"applying")+" widgets"),f=0;f<g;f++)(i=l[f])&&i.id&&c.applyWidgetId(a,i.id,d);k.debug&&console.groupEnd&&console.groupEnd()}k.timerReady=setTimeout(function(){a.isApplyingWidgets=!1,b.data(a,"lastWidgetApplication",new Date),k.$table.triggerHandler("tablesorter-ready"),d||"function"!=typeof e||e(a),k.debug&&(i=k.widgets.length,console.log("Completed "+(d===!0?"initializing ":"applying ")+i+" widget"+(1!==i?"s":"")+c.benchmark(j)))},10)}},removeWidget:function(a,d,e){a=b(a)[0];var f,g,h,i,j=a.config;if(d===!0)for(d=[],i=c.widgets.length,h=0;h<i;h++)(g=c.widgets[h])&&g.id&&(d[d.length]=g.id);else d=(b.isArray(d)?d.join(","):d||"").toLowerCase().split(/[\s,]+/);for(i=d.length,f=0;f<i;f++)g=c.getWidgetById(d[f]),h=b.inArray(d[f],j.widgets),h>=0&&e!==!0&&j.widgets.splice(h,1),g&&g.remove&&(j.debug&&console.log((e?"Refreshing":"Removing")+' "'+d[f]+'" widget'),g.remove(a,j,j.widgetOptions,e),j.widgetInit[d[f]]=!1)},refreshWidgets:function(a,d,e){a=b(a)[0];var f,g,h=a.config,i=h.widgets,j=c.widgets,k=j.length,l=[],m=function(a){b(a).triggerHandler("refreshComplete")};for(f=0;f<k;f++)(g=j[f])&&g.id&&(d||b.inArray(g.id,i)<0)&&(l[l.length]=g.id);c.removeWidget(a,l.join(","),!0),e!==!0?(c.applyWidget(a,d||!1,m),d&&c.applyWidget(a,!1,m)):m(a)},benchmark:function(a){return" ("+((new Date).getTime()-a.getTime())+" ms)"},log:function(){console.log(arguments)},isEmptyObject:function(a){for(var b in a)return!1;return!0},isValueInArray:function(a,b){var c,d=b&&b.length||0;for(c=0;c<d;c++)if(b[c][0]===a)return c;return-1},formatFloat:function(a,d){
|
|
if("string"!=typeof a||""===a)return a;var e;return a=(d&&d.config?d.config.usNumberFormat!==!1:void 0===d||d)?a.replace(c.regex.comma,""):a.replace(c.regex.digitNonUS,"").replace(c.regex.comma,"."),c.regex.digitNegativeTest.test(a)&&(a=a.replace(c.regex.digitNegativeReplace,"-$1")),e=parseFloat(a),isNaN(e)?b.trim(a):e},isDigit:function(a){return isNaN(a)?c.regex.digitTest.test(a.toString().replace(c.regex.digitReplace,"")):""!==a},computeColumnIndex:function(a,c){var d,e,f,g,h,i,j,k,l,m,n=c&&c.columns||0,o=[],p=new Array(n);for(d=0;d<a.length;d++)for(i=a[d].cells,e=0;e<i.length;e++){for(h=i[e],j=h.parentNode.rowIndex,k=h.rowSpan||1,l=h.colSpan||1,void 0===o[j]&&(o[j]=[]),f=0;f<o[j].length+1;f++)if(void 0===o[j][f]){m=f;break}for(n&&h.cellIndex===m||(h.setAttribute?h.setAttribute("data-column",m):b(h).attr("data-column",m)),f=j;f<j+k;f++)for(void 0===o[f]&&(o[f]=[]),p=o[f],g=m;g<m+l;g++)p[g]="x"}return p.length},fixColumnWidth:function(a){a=b(a)[0];var d,e,f,g,h,i=a.config,j=i.$table.children("colgroup");if(j.length&&j.hasClass(c.css.colgroup)&&j.remove(),i.widthFixed&&0===i.$table.children("colgroup").length){for(j=b('<colgroup class="'+c.css.colgroup+'">'),d=i.$table.width(),f=i.$tbodies.find("tr:first").children(":visible"),g=f.length,h=0;h<g;h++)e=parseInt(f.eq(h).width()/d*1e3,10)/10+"%",j.append(b("<col>").css("width",e));i.$table.prepend(j)}},getData:function(a,c,d){var e,f,g="",h=b(a);return h.length?(e=!!b.metadata&&h.metadata(),f=" "+(h.attr("class")||""),void 0!==h.data(d)||void 0!==h.data(d.toLowerCase())?g+=h.data(d)||h.data(d.toLowerCase()):e&&void 0!==e[d]?g+=e[d]:c&&void 0!==c[d]?g+=c[d]:" "!==f&&f.match(" "+d+"-")&&(g=f.match(new RegExp("\\s"+d+"-([\\w-]+)"))[1]||""),b.trim(g)):""},getColumnData:function(a,c,d,e,f){if("object"!=typeof c||null===c)return c;a=b(a)[0];var g,h,i=a.config,j=f||i.$headers,k=i.$headerIndexed&&i.$headerIndexed[d]||j.filter('[data-column="'+d+'"]:last');if(void 0!==c[d])return e?c[d]:c[j.index(k)];for(h in c)if("string"==typeof h&&(g=k.filter(h).add(k.find(h)),g.length))return c[h]},isProcessing:function(a,d,e){a=b(a);var f=a[0].config,g=e||a.find("."+c.css.header);d?(void 0!==e&&f.sortList.length>0&&(g=g.filter(function(){return!this.sortDisabled&&c.isValueInArray(parseFloat(b(this).attr("data-column")),f.sortList)>=0})),a.add(g).addClass(c.css.processing+" "+f.cssProcessing)):a.add(g).removeClass(c.css.processing+" "+f.cssProcessing)},processTbody:function(a,c,d){if(a=b(a)[0],d)return a.isProcessing=!0,c.before('<colgroup class="tablesorter-savemyplace"/>'),b.fn.detach?c.detach():c.remove();var e=b(a).find("colgroup.tablesorter-savemyplace");c.insertAfter(e),e.remove(),a.isProcessing=!1},clearTableBody:function(a){b(a)[0].config.$tbodies.children().detach()},characterEquivalents:{a:"áàâãäąå",A:"ÁÀÂÃÄĄÅ",c:"çćč",C:"ÇĆČ",e:"éèêëěę",E:"ÉÈÊËĚĘ",i:"íìİîïı",I:"ÍÌİÎÏ",o:"óòôõöō",O:"ÓÒÔÕÖŌ",ss:"ß",SS:"ẞ",u:"úùûüů",U:"ÚÙÛÜŮ"},replaceAccents:function(a){var b,d="[",e=c.characterEquivalents;if(!c.characterRegex){c.characterRegexArray={};for(b in e)"string"==typeof b&&(d+=e[b],c.characterRegexArray[b]=new RegExp("["+e[b]+"]","g"));c.characterRegex=new RegExp(d+"]")}if(c.characterRegex.test(a))for(b in e)"string"==typeof b&&(a=a.replace(c.characterRegexArray[b],b));return a},validateOptions:function(a){var d,e,f,g,h="headers sortForce sortList sortAppend widgets".split(" "),i=a.originalSettings;if(i){a.debug&&(g=new Date);for(d in i)if("undefined"===(f=typeof c.defaults[d]))console.warn('Tablesorter Warning! "table.config.'+d+'" option not recognized');else if("object"===f)for(e in i[d])f=c.defaults[d]&&typeof c.defaults[d][e],b.inArray(d,h)<0&&"undefined"===f&&console.warn('Tablesorter Warning! "table.config.'+d+"."+e+'" option not recognized');a.debug&&console.log("validate options time:"+c.benchmark(g))}},restoreHeaders:function(a){var d,e,f=b(a)[0].config,g=f.$table.find(f.selectorHeaders),h=g.length;for(d=0;d<h;d++)e=g.eq(d),e.find("."+c.css.headerIn).length&&e.html(f.headerContent[d])},destroy:function(a,d,e){if(a=b(a)[0],a.hasInitialized){c.removeWidget(a,!0,!1);var f,g=b(a),h=a.config,i=h.debug,j=g.find("thead:first"),k=j.find("tr."+c.css.headerRow).removeClass(c.css.headerRow+" "+h.cssHeaderRow),l=g.find("tfoot:first > tr").children("th, td");d===!1&&b.inArray("uitheme",h.widgets)>=0&&(g.triggerHandler("applyWidgetId",["uitheme"]),g.triggerHandler("applyWidgetId",["zebra"])),j.find("tr").not(k).remove(),f="sortReset update updateRows updateAll updateHeaders updateCell addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets removeWidget destroy mouseup mouseleave "+"keypress sortBegin sortEnd resetToLoadState ".split(" ").join(h.namespace+" "),g.removeData("tablesorter").unbind(f.replace(c.regex.spaces," ")),h.$headers.add(l).removeClass([c.css.header,h.cssHeader,h.cssAsc,h.cssDesc,c.css.sortAsc,c.css.sortDesc,c.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true"),k.find(h.selectorSort).unbind("mousedown mouseup keypress ".split(" ").join(h.namespace+" ").replace(c.regex.spaces," ")),c.restoreHeaders(a),g.toggleClass(c.css.table+" "+h.tableClass+" tablesorter-"+h.theme,d===!1),a.hasInitialized=!1,delete a.config.cache,"function"==typeof e&&e(a),i&&console.log("tablesorter has been removed")}}};b.fn.tablesorter=function(a){return this.each(function(){var d=this,e=b.extend(!0,{},c.defaults,a,c.instanceMethods);e.originalSettings=a,!d.hasInitialized&&c.buildTable&&"TABLE"!==this.nodeName?c.buildTable(d,e):c.setup(d,e)})},window.console&&window.console.log||(c.logs=[],console={},console.log=console.warn=console.error=console.table=function(){var a=arguments.length>1?arguments:arguments[0];c.logs[c.logs.length]={date:Date.now(),log:a}}),c.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),c.addParser({id:"text",is:function(){return!0},format:function(a,d){var e=d.config;return a&&(a=b.trim(e.ignoreCase?a.toLocaleLowerCase():a),a=e.sortLocaleCompare?c.replaceAccents(a):a),a},type:"text"}),c.regex.nondigit=/[^\w,. \-()]/g,c.addParser({id:"digit",is:function(a){return c.isDigit(a)},format:function(a,d){var e=c.formatFloat((a||"").replace(c.regex.nondigit,""),d);return a&&"number"==typeof e?e:a?b.trim(a&&d.config.ignoreCase?a.toLocaleLowerCase():a):a},type:"numeric"}),c.regex.currencyReplace=/[+\-,. ]/g,c.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,c.addParser({id:"currency",is:function(a){return a=(a||"").replace(c.regex.currencyReplace,""),c.regex.currencyTest.test(a)},format:function(a,d){var e=c.formatFloat((a||"").replace(c.regex.nondigit,""),d);return a&&"number"==typeof e?e:a?b.trim(a&&d.config.ignoreCase?a.toLocaleLowerCase():a):a},type:"numeric"}),c.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,c.regex.urlProtocolReplace=/(https?|ftp|file):\/\/(www\.)?/,c.addParser({id:"url",is:function(a){return c.regex.urlProtocolTest.test(a)},format:function(a){return a?b.trim(a.replace(c.regex.urlProtocolReplace,"")):a},type:"text"}),c.regex.dash=/-/g,c.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,c.addParser({id:"isoDate",is:function(a){return c.regex.isoDate.test(a)},format:function(a,b){var d=a?new Date(a.replace(c.regex.dash,"/")):a;return d instanceof Date&&isFinite(d)?d.getTime():a},type:"numeric"}),c.regex.percent=/%/g,c.regex.percentTest=/(\d\s*?%|%\s*?\d)/,c.addParser({id:"percent",is:function(a){return c.regex.percentTest.test(a)&&a.length<15},format:function(a,b){return a?c.formatFloat(a.replace(c.regex.percent,""),b):a},type:"numeric"}),c.addParser({id:"image",is:function(a,b,c,d){return d.find("img").length>0},format:function(a,c,d){return b(d).find("img").attr(c.config.imgAttr||"alt")||a},parsed:!0,type:"text"}),c.regex.dateReplace=/(\S)([AP]M)$/i,c.regex.usLongDateTest1=/^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i,c.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,c.addParser({id:"usLongDate",is:function(a){return c.regex.usLongDateTest1.test(a)||c.regex.usLongDateTest2.test(a)},format:function(a,b){var d=a?new Date(a.replace(c.regex.dateReplace,"$1 $2")):a;return d instanceof Date&&isFinite(d)?d.getTime():a},type:"numeric"}),c.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,c.regex.shortDateReplace=/[\-.,]/g,c.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,c.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,c.convertFormat=function(a,b){a=(a||"").replace(c.regex.spaces," ").replace(c.regex.shortDateReplace,"/"),"mmddyyyy"===b?a=a.replace(c.regex.shortDateXXY,"$3/$1/$2"):"ddmmyyyy"===b?a=a.replace(c.regex.shortDateXXY,"$3/$2/$1"):"yyyymmdd"===b&&(a=a.replace(c.regex.shortDateYMD,"$1/$2/$3"));var d=new Date(a);return d instanceof Date&&isFinite(d)?d.getTime():""},c.addParser({id:"shortDate",is:function(a){return a=(a||"").replace(c.regex.spaces," ").replace(c.regex.shortDateReplace,"/"),c.regex.shortDateTest.test(a)},format:function(a,b,d,e){if(a){var f=b.config,g=f.$headerIndexed[e],h=g.length&&g.data("dateFormat")||c.getData(g,c.getColumnData(b,f.headers,e),"dateFormat")||f.dateFormat;return g.length&&g.data("dateFormat",h),c.convertFormat(a,h)||a}return a},type:"numeric"}),c.regex.timeTest=/^(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)$|^((?:[01]\d|[2][0-4]):[0-5]\d)$/i,c.regex.timeMatch=/(0?[1-9]|1[0-2]):([0-5]\d)(\s[AP]M)|((?:[01]\d|[2][0-4]):[0-5]\d)/i,c.addParser({id:"time",is:function(a){return c.regex.timeTest.test(a)},format:function(a,b){var d,e=(a||"").match(c.regex.timeMatch),f=new Date(a),g=a&&(null!==e?e[0]:"00:00 AM"),h=g?new Date("2000/01/01 "+g.replace(c.regex.dateReplace,"$1 $2")):g;return h instanceof Date&&isFinite(h)?(d=f instanceof Date&&isFinite(f)?f.getTime():0,d?parseFloat(h.getTime()+"."+f.getTime()):h.getTime()):a},type:"numeric"}),c.addParser({id:"metadata",is:function(){return!1},format:function(a,c,d){var e=c.config,f=e.parserMetadataName?e.parserMetadataName:"sortValue";return b(d).metadata()[f]},type:"numeric"}),c.addWidget({id:"zebra",priority:90,format:function(a,c,d){var e,f,g,h,i,j,k,l=new RegExp(c.cssChildRow,"i"),m=c.$tbodies.add(b(c.namespace+"_extra_table").children("tbody:not(."+c.cssInfoBlock+")"));for(i=0;i<m.length;i++)for(g=0,e=m.eq(i).children("tr:visible").not(c.selectorRemove),k=e.length,j=0;j<k;j++)f=e.eq(j),l.test(f[0].className)||g++,h=g%2==0,f.removeClass(d.zebra[h?1:0]).addClass(d.zebra[h?0:1])},remove:function(a,b,d,e){if(!e){var f,g,h=b.$tbodies,i=(d.zebra||["even","odd"]).join(" ");for(f=0;f<h.length;f++)g=c.processTbody(a,h.eq(f),!0),g.children().removeClass(i),c.processTbody(a,g,!1)}}})}(a),a.tablesorter}); |