mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
6 lines
32 KiB
JavaScript
6 lines
32 KiB
JavaScript
/*!
|
|
* TableSorter (FORK) 2.19.0 min - Client-side table sorting with ease!
|
|
* Copyright (c) 2007 Christian Bach; fork maintained by Rob Garrison
|
|
*/
|
|
(function(h){"function"===typeof define&&define.amd?define(["jquery"],h):"object"===typeof module&&"object"===typeof module.exports?module.exports=h(require("jquery")):h(jQuery)})(function(h){h.extend({tablesorter:new function(){function f(){var b=arguments[0],a=1<arguments.length?Array.prototype.slice.call(arguments):b;if("undefined"!==typeof console&&"undefined"!==typeof console.log)console[/error/i.test(b)?"error":/warn/i.test(b)?"warn":"log"](a);else alert(a)}function y(b,a){f(b+" ("+((new Date).getTime()- a.getTime())+"ms)")}function m(b){for(var a in b)return!1;return!0}function v(b,a,d){if(!a)return"";var e,c=h(a),l=b.config,u=l.textExtraction||"";return"string"===typeof u?h.trim(("basic"===u?c.attr(l.textAttribute)||a.textContent:a.textContent)||c.text()||""):"function"===typeof u?h.trim(u(a,b,d)):"function"===typeof(e=g.getColumnData(b,u,d))?h.trim(e(a,b,d)):h.trim(a.textContent||c.text()||"")}function p(b){var a,d,e=b.config,c=e.$tbodies=e.$table.children("tbody:not(."+e.cssInfoBlock+")"),l,u, k,q,n,w,t,r,m,E=0,A="",x=c.length;if(0===x)return e.debug?f("Warning: *Empty table!* Not building a parser cache"):"";e.debug&&(m=new Date,f("Detecting parsers for each column"));a=[];for(d=[];E<x;){l=c[E].rows;if(l.length)for(u=e.columns,k=0;k<u;k++){q=e.$headers.filter('[data-column="'+k+'"]:last');n=g.getColumnData(b,e.headers,k);r=g.getParserById(g.getData(q,n,"extractor"));t=g.getParserById(g.getData(q,n,"sorter"));w="false"===g.getData(q,n,"parser");e.empties[k]=(g.getData(q,n,"empty")||e.emptyTo|| (e.emptyToBottom?"bottom":"top")).toLowerCase();e.strings[k]=(g.getData(q,n,"string")||e.stringTo||"max").toLowerCase();w&&(t=g.getParserById("no-parser"));r||(r=!1);if(!t)a:{q=b;n=l;w=-1;t=k;for(var C=void 0,M=void 0,N=g.parsers.length,z=!1,B="",C=!0;""===B&&C;)w++,n[w]?(z=n[w].cells[t],B=v(q,z,t),M=h(z),q.config.debug&&f("Checking if value was empty on row "+w+", column: "+t+': "'+B+'"')):C=!1;for(;0<=--N;)if((C=g.parsers[N])&&"text"!==C.id&&C.is&&C.is(B,q,z,M)){t=C;break a}t=g.getParserById("text")}e.debug&& (A+="column:"+k+"; extractor:"+r.id+"; parser:"+t.id+"; string:"+e.strings[k]+"; empty: "+e.empties[k]+"\n");d[k]=t;a[k]=r}E+=d.length?x:1}e.debug&&(f(A?A:"No parsers detected"),y("Completed detecting parsers",m));e.parsers=d;e.extractors=a}function x(b){var a,d,e,c,l,u,k,q,n,w,t,r=b.config,m=r.$table.children("tbody"),p=r.extractors,A=r.parsers;r.cache={};r.totalRows=0;if(!A)return r.debug?f("Warning: *Empty table!* Not building a cache"):"";r.debug&&(q=new Date);r.showProcessing&&g.isProcessing(b, !0);for(l=0;l<m.length;l++)if(t=[],a=r.cache[l]={normalized:[]},!m.eq(l).hasClass(r.cssInfoBlock)){n=m[l]&&m[l].rows.length||0;for(e=0;e<n;++e)if(w={child:[]},u=h(m[l].rows[e]),k=[],u.hasClass(r.cssChildRow)&&0!==e)d=a.normalized.length-1,a.normalized[d][r.columns].$row=a.normalized[d][r.columns].$row.add(u),u.prev().hasClass(r.cssChildRow)||u.prev().addClass(g.css.cssHasChild),w.child[d]=h.trim(u[0].textContent||u[0].innerText||u.text()||"");else{w.$row=u;w.order=e;for(c=0;c<r.columns;++c)"undefined"=== typeof A[c]?r.debug&&f("No parser found for cell:",u[0].cells[c],"does it have a header?"):(d=v(b,u[0].cells[c],c),d="undefined"===typeof p[c].id?d:p[c].format(d,b,u[0].cells[c],c),d="no-parser"===A[c].id?"":A[c].format(d,b,u[0].cells[c],c),k.push(r.ignoreCase&&"string"===typeof d?d.toLowerCase():d),"numeric"===(A[c].type||"").toLowerCase()&&(t[c]=Math.max(Math.abs(d)||0,t[c]||0)));k[r.columns]=w;a.normalized.push(k)}a.colMax=t;r.totalRows+=a.normalized.length}r.showProcessing&&g.isProcessing(b); r.debug&&y("Building cache for "+n+" rows",q)}function B(b,a){var d=b.config,e=d.widgetOptions,c=b.tBodies,l=[],u=d.cache,k,f,n,w,t,r;if(m(u))return d.appender?d.appender(b,l):b.isUpdating?d.$table.trigger("updateComplete",b):"";d.debug&&(r=new Date);for(t=0;t<c.length;t++)if(k=h(c[t]),k.length&&!k.hasClass(d.cssInfoBlock)){n=g.processTbody(b,k,!0);k=u[t].normalized;f=k.length;for(w=0;w<f;w++)l.push(k[w][d.columns].$row),d.appender&&(!d.pager||d.pager.removeRows&&e.pager_removeRows||d.pager.ajax)|| n.append(k[w][d.columns].$row);g.processTbody(b,n,!1)}d.appender&&d.appender(b,l);d.debug&&y("Rebuilt table",r);a||d.appender||g.applyWidget(b);b.isUpdating&&d.$table.trigger("updateComplete",b)}function F(b){return/^d/i.test(b)||1===b}function D(b){var a,d,e,c,l,u,k,q=b.config;q.headerList=[];q.headerContent=[];q.debug&&(k=new Date);q.columns=g.computeColumnIndex(q.$table.children("thead, tfoot").children("tr"));c=q.cssIcon?'<i class="'+(q.cssIcon===g.css.icon?g.css.icon:q.cssIcon+" "+g.css.icon)+ '"></i>':"";q.$headers=h(h.map(h(b).find(q.selectorHeaders),function(k,f){d=h(k);if(!d.parent().hasClass(q.cssIgnoreRow))return a=g.getColumnData(b,q.headers,f,!0),q.headerContent[f]=d.html(),""===q.headerTemplate||d.find("."+g.css.headerIn).length||(l=q.headerTemplate.replace(/\{content\}/g,d.html()).replace(/\{icon\}/g,d.find("."+g.css.icon).length?"":c),q.onRenderTemplate&&(e=q.onRenderTemplate.apply(d,[f,l]))&&"string"===typeof e&&(l=e),d.html('<div class="'+g.css.headerIn+'">'+l+"</div>")),q.onRenderHeader&& q.onRenderHeader.apply(d,[f,q,q.$table]),k.column=parseInt(d.attr("data-column"),10),k.order=F(g.getData(d,a,"sortInitialOrder")||q.sortInitialOrder)?[1,0,2]:[0,1,2],k.count=-1,k.lockedOrder=!1,u=g.getData(d,a,"lockedOrder")||!1,"undefined"!==typeof u&&!1!==u&&(k.order=k.lockedOrder=F(u)?[1,1,1]:[0,0,0]),d.addClass(g.css.header+" "+q.cssHeader),q.headerList[f]=k,d.parent().addClass(g.css.headerRow+" "+q.cssHeaderRow).attr("role","row"),q.tabIndex&&d.attr("tabindex",0),k}));h(b).find(q.selectorHeaders).attr({scope:"col", role:"columnheader"});H(b);q.debug&&(y("Built headers:",k),f(q.$headers))}function I(b,a,d){var e=b.config;e.$table.find(e.selectorRemove).remove();p(b);x(b);J(e,a,d)}function H(b){var a,d,e,c=b.config;c.$headers.each(function(l,f){d=h(f);e=g.getColumnData(b,c.headers,l,!0);a="false"===g.getData(f,e,"sorter")||"false"===g.getData(f,e,"parser");f.sortDisabled=a;d[a?"addClass":"removeClass"]("sorter-false").attr("aria-disabled",""+a);b.id&&(a?d.removeAttr("aria-controls"):d.attr("aria-controls",b.id))})} function G(b){var a,d,e=b.config,c=e.sortList,l=c.length,f=g.css.sortNone+" "+e.cssNone,k=[g.css.sortAsc+" "+e.cssAsc,g.css.sortDesc+" "+e.cssDesc],q=[e.cssIconAsc,e.cssIconDesc,e.cssIconNone],n=["ascending","descending"],m=h(b).find("tfoot tr").children().add(e.$extraHeaders).removeClass(k.join(" "));e.$headers.removeClass(k.join(" ")).addClass(f).attr("aria-sort","none").find("."+e.cssIcon).removeClass(q.join(" ")).addClass(q[2]);for(a=0;a<l;a++)if(2!==c[a][1]&&(b=e.$headers.not(".sorter-false").filter('[data-column="'+ c[a][0]+'"]'+(1===l?":last":"")),b.length)){for(d=0;d<b.length;d++)b[d].sortDisabled||b.eq(d).removeClass(f).addClass(k[c[a][1]]).attr("aria-sort",n[c[a][1]]).find("."+e.cssIcon).removeClass(q[2]).addClass(q[c[a][1]]);m.length&&m.filter('[data-column="'+c[a][0]+'"]').removeClass(f).addClass(k[c[a][1]])}e.$headers.not(".sorter-false").each(function(){var b=h(this),a=this.order[(this.count+1)%(e.sortReset?3:2)],a=h.trim(b.text())+": "+g.language[b.hasClass(g.css.sortAsc)?"sortAsc":b.hasClass(g.css.sortDesc)? "sortDesc":"sortNone"]+g.language[0===a?"nextAsc":1===a?"nextDesc":"nextNone"];b.attr("aria-label",a)})}function Q(b,a){var d,e,c,l,g,k=b.config,f=a||k.sortList;k.sortList=[];h.each(f,function(b,a){l=parseInt(a[0],10);if(c=k.$headers.filter('[data-column="'+l+'"]:last')[0]){e=(e=(""+a[1]).match(/^(1|d|s|o|n)/))?e[0]:"";switch(e){case "1":case "d":e=1;break;case "s":e=g||0;break;case "o":d=c.order[(g||0)%(k.sortReset?3:2)];e=0===d?1:1===d?0:2;break;case "n":c.count+=1;e=c.order[c.count%(k.sortReset? 3:2)];break;default:e=0}g=0===b?e:g;d=[l,parseInt(e,10)||0];k.sortList.push(d);e=h.inArray(d[1],c.order);c.count=0<=e?e:d[1]%(k.sortReset?3:2)}})}function R(b,a){return b&&b[a]?b[a].type||"":""}function O(b,a,d){if(b.isUpdating)return setTimeout(function(){O(b,a,d)},50);var e,c,l,f,k=b.config,q=!d[k.sortMultiSortKey],n=k.$table;n.trigger("sortStart",b);a.count=d[k.sortResetKey]?2:(a.count+1)%(k.sortReset?3:2);k.sortRestart&&(c=a,k.$headers.each(function(){this===c||!q&&h(this).is("."+g.css.sortDesc+ ",."+g.css.sortAsc)||(this.count=-1)}));c=parseInt(h(a).attr("data-column"),10);if(q){k.sortList=[];if(null!==k.sortForce)for(e=k.sortForce,l=0;l<e.length;l++)e[l][0]!==c&&k.sortList.push(e[l]);e=a.order[a.count];if(2>e&&(k.sortList.push([c,e]),1<a.colSpan))for(l=1;l<a.colSpan;l++)k.sortList.push([c+l,e])}else{if(k.sortAppend&&1<k.sortList.length)for(l=0;l<k.sortAppend.length;l++)f=g.isValueInArray(k.sortAppend[l][0],k.sortList),0<=f&&k.sortList.splice(f,1);if(0<=g.isValueInArray(c,k.sortList))for(l= 0;l<k.sortList.length;l++)f=k.sortList[l],e=k.$headers.filter('[data-column="'+f[0]+'"]:last')[0],f[0]===c&&(f[1]=e.order[a.count],2===f[1]&&(k.sortList.splice(l,1),e.count=-1));else if(e=a.order[a.count],2>e&&(k.sortList.push([c,e]),1<a.colSpan))for(l=1;l<a.colSpan;l++)k.sortList.push([c+l,e])}if(null!==k.sortAppend)for(e=k.sortAppend,l=0;l<e.length;l++)e[l][0]!==c&&k.sortList.push(e[l]);n.trigger("sortBegin",b);setTimeout(function(){G(b);K(b);B(b);n.trigger("sortEnd",b)},1)}function K(b){var a, d,e,c,l,f,k,h,n,w,t,r=0,p=b.config,v=p.textSorter||"",A=p.sortList,z=A.length,x=b.tBodies.length;if(!p.serverSideSorting&&!m(p.cache)){p.debug&&(l=new Date);for(d=0;d<x;d++)f=p.cache[d].colMax,k=p.cache[d].normalized,k.sort(function(d,l){for(a=0;a<z;a++){c=A[a][0];h=A[a][1];r=0===h;if(p.sortStable&&d[c]===l[c]&&1===z)break;(e=/n/i.test(R(p.parsers,c)))&&p.strings[c]?(e="boolean"===typeof p.string[p.strings[c]]?(r?1:-1)*(p.string[p.strings[c]]?-1:1):p.strings[c]?p.string[p.strings[c]]||0:0,n=p.numberSorter? p.numberSorter(d[c],l[c],r,f[c],b):g["sortNumeric"+(r?"Asc":"Desc")](d[c],l[c],e,f[c],c,b)):(w=r?d:l,t=r?l:d,n="function"===typeof v?v(w[c],t[c],r,c,b):"object"===typeof v&&v.hasOwnProperty(c)?v[c](w[c],t[c],r,c,b):g["sortNatural"+(r?"Asc":"Desc")](d[c],l[c],c,b,p));if(n)return n}return d[p.columns].order-l[p.columns].order});p.debug&&y("Sorting on "+A.toString()+" and dir "+h+" time",l)}}function L(b,a){b.table.isUpdating&&b.$table.trigger("updateComplete",b.table);h.isFunction(a)&&a(b.table)}function J(b, a,d){var e=h.isArray(a)?a:b.sortList;!1===("undefined"===typeof a?b.resort:a)||b.serverSideSorting||b.table.isProcessing?(L(b,d),g.applyWidget(b.table,!1)):e.length?b.$table.trigger("sorton",[e,function(){L(b,d)},!0]):b.$table.trigger("sortReset",[function(){L(b,d);g.applyWidget(b.table,!1)}])}function P(b){var a=b.config,d=a.$table;d.unbind("sortReset update updateRows updateCell updateAll addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(a.namespace+ " ")).bind("sortReset"+a.namespace,function(e,c){e.stopPropagation();a.sortList=[];G(b);K(b);B(b);h.isFunction(c)&&c(b)}).bind("updateAll"+a.namespace,function(e,c,d){e.stopPropagation();b.isUpdating=!0;g.refreshWidgets(b,!0,!0);D(b);g.bindEvents(b,a.$headers,!0);P(b);I(b,c,d)}).bind("update"+a.namespace+" updateRows"+a.namespace,function(a,c,d){a.stopPropagation();b.isUpdating=!0;H(b);I(b,c,d)}).bind("updateCell"+a.namespace,function(e,c,l,g){e.stopPropagation();b.isUpdating=!0;d.find(a.selectorRemove).remove(); var k,f,n;f=d.find("tbody");n=h(c);e=f.index(h.fn.closest?n.closest("tbody"):n.parents("tbody").filter(":first"));k=h.fn.closest?n.closest("tr"):n.parents("tr").filter(":first");c=n[0];f.length&&0<=e&&(f=f.eq(e).find("tr").index(k),n=n.index(),a.cache[e].normalized[f][a.columns].$row=k,k="undefined"===typeof a.extractors[n].id?v(b,c,n):a.extractors[n].format(v(b,c,n),b,c,n),c="no-parser"===a.parsers[n].id?"":a.parsers[n].format(k,b,c,n),a.cache[e].normalized[f][n]=a.ignoreCase&&"string"===typeof c? c.toLowerCase():c,"numeric"===(a.parsers[n].type||"").toLowerCase()&&(a.cache[e].colMax[n]=Math.max(Math.abs(c)||0,a.cache[e].colMax[n]||0)),c="undefined"!==l?l:a.resort,!1!==c?J(a,c,g):(h.isFunction(g)&&g(b),a.$table.trigger("updateComplete",a.table)))}).bind("addRows"+a.namespace,function(e,c,l,g){e.stopPropagation();b.isUpdating=!0;if(m(a.cache))H(b),I(b,l,g);else{c=h(c).attr("role","row");var k,f,n,y,t,r=c.filter("tr").length,x=d.find("tbody").index(c.parents("tbody").filter(":first"));a.parsers&& a.parsers.length||p(b);for(e=0;e<r;e++){f=c[e].cells.length;t=[];y={child:[],$row:c.eq(e),order:a.cache[x].normalized.length};for(k=0;k<f;k++)n="undefined"===typeof a.extractors[k].id?v(b,c[e].cells[k],k):a.extractors[k].format(v(b,c[e].cells[k],k),b,c[e].cells[k],k),n="no-parser"===a.parsers[k].id?"":a.parsers[k].format(n,b,c[e].cells[k],k),t[k]=a.ignoreCase&&"string"===typeof n?n.toLowerCase():n,"numeric"===(a.parsers[k].type||"").toLowerCase()&&(a.cache[x].colMax[k]=Math.max(Math.abs(t[k])||0, a.cache[x].colMax[k]||0));t.push(y);a.cache[x].normalized.push(t)}J(a,l,g)}}).bind("updateComplete"+a.namespace,function(){b.isUpdating=!1}).bind("sorton"+a.namespace,function(a,c,l,f){var k=b.config;a.stopPropagation();d.trigger("sortStart",this);Q(b,c);G(b);k.delayInit&&m(k.cache)&&x(b);d.trigger("sortBegin",this);K(b);B(b,f);d.trigger("sortEnd",this);g.applyWidget(b);h.isFunction(l)&&l(b)}).bind("appendCache"+a.namespace,function(a,c,d){a.stopPropagation();B(b,d);h.isFunction(c)&&c(b)}).bind("updateCache"+ a.namespace,function(e,c){a.parsers&&a.parsers.length||p(b);x(b);h.isFunction(c)&&c(b)}).bind("applyWidgetId"+a.namespace,function(e,c){e.stopPropagation();g.getWidgetById(c).format(b,a,a.widgetOptions)}).bind("applyWidgets"+a.namespace,function(a,c){a.stopPropagation();g.applyWidget(b,c)}).bind("refreshWidgets"+a.namespace,function(a,c,d){a.stopPropagation();g.refreshWidgets(b,c,d)}).bind("destroy"+a.namespace,function(a,c,d){a.stopPropagation();g.destroy(b,c,d)}).bind("resetToLoadState"+a.namespace, function(){g.removeWidget(b,!0,!1);a=h.extend(!0,g.defaults,a.originalSettings);b.hasInitialized=!1;g.setup(b,a)})}var g=this;g.version="2.19.0";g.parsers=[];g.widgets=[];g.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",textExtraction:"basic",textAttribute:"data-text",textSorter:null,numberSorter:null,widgets:[],widgetOptions:{zebra:["even","odd"]},initWidgets:!0,widgetClass:"widget-{name}",initialized:null,tableClass:"",cssAsc:"",cssDesc:"",cssNone:"",cssHeader:"",cssHeaderRow:"",cssProcessing:"",cssChildRow:"tablesorter-childRow",cssIcon:"tablesorter-icon",cssIconNone:"", cssIconAsc:"",cssIconDesc:"",cssInfoBlock:"tablesorter-infoOnly",cssAllowClicks:"tablesorter-allowClicks",cssIgnoreRow:"tablesorter-ignoreRow",selectorHeaders:"> thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[]};g.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",info:"tablesorter-infoOnly",processing:"tablesorter-processing",sortAsc:"tablesorter-headerAsc",sortDesc:"tablesorter-headerDesc",sortNone:"tablesorter-headerUnSorted"};g.language={sortAsc:"Ascending sort applied, ",sortDesc:"Descending sort applied, ",sortNone:"No sort applied, ",nextAsc:"activate to apply an ascending sort",nextDesc:"activate to apply a descending sort",nextNone:"activate to remove the sort"};g.log=f;g.benchmark=y;g.construct=function(b){return this.each(function(){var a= h.extend(!0,{},g.defaults,b);a.originalSettings=b;!this.hasInitialized&&g.buildTable&&"TABLE"!==this.tagName?g.buildTable(this,a):g.setup(this,a)})};g.setup=function(b,a){if(!b||!b.tHead||0===b.tBodies.length||!0===b.hasInitialized)return a.debug?f("ERROR: stopping initialization! No table, thead, tbody or tablesorter has already been initialized"):"";var d="",e=h(b),c=h.metadata;b.hasInitialized=!1;b.isProcessing=!0;b.config=a;h.data(b,"tablesorter",a);a.debug&&h.data(b,"startoveralltimer",new Date); a.supportsDataObject=function(a){a[0]=parseInt(a[0],10);return 1<a[0]||1===a[0]&&4<=parseInt(a[1],10)}(h.fn.jquery.split("."));a.string={max:1,min:-1,emptymin:1,emptymax:-1,zero:0,none:0,"null":0,top:!0,bottom:!1};a.emptyTo=a.emptyTo.toLowerCase();a.stringTo=a.stringTo.toLowerCase();/tablesorter\-/.test(e.attr("class"))||(d=""!==a.theme?" tablesorter-"+a.theme:"");a.table=b;a.$table=e.addClass(g.css.table+" "+a.tableClass+d).attr("role","grid");a.$headers=e.find(a.selectorHeaders);a.namespace=a.namespace? "."+a.namespace.replace(/\W/g,""):".tablesorter"+Math.random().toString(16).slice(2);a.$table.children().children("tr").attr("role","row");a.$tbodies=e.children("tbody:not(."+a.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"});a.$table.children("caption").length&&(d=a.$table.children("caption")[0],d.id||(d.id=a.namespace.slice(1)+"caption"),a.$table.attr("aria-labelledby",d.id));a.widgetInit={};a.textExtraction=a.$table.attr("data-text-extraction")||a.textExtraction||"basic";D(b); g.fixColumnWidth(b);p(b);a.totalRows=0;a.delayInit||x(b);g.bindEvents(b,a.$headers,!0);P(b);a.supportsDataObject&&"undefined"!==typeof e.data().sortlist?a.sortList=e.data().sortlist:c&&e.metadata()&&e.metadata().sortlist&&(a.sortList=e.metadata().sortlist);g.applyWidget(b,!0);0<a.sortList.length?e.trigger("sorton",[a.sortList,{},!a.initWidgets,!0]):(G(b),a.initWidgets&&g.applyWidget(b,!1));a.showProcessing&&e.unbind("sortBegin"+a.namespace+" sortEnd"+a.namespace).bind("sortBegin"+a.namespace+" sortEnd"+ a.namespace,function(c){clearTimeout(a.processTimer);g.isProcessing(b);"sortBegin"===c.type&&(a.processTimer=setTimeout(function(){g.isProcessing(b,!0)},500))});b.hasInitialized=!0;b.isProcessing=!1;a.debug&&g.benchmark("Overall initialization time",h.data(b,"startoveralltimer"));e.trigger("tablesorter-initialized",b);"function"===typeof a.initialized&&a.initialized(b)};g.fixColumnWidth=function(b){b=h(b)[0];var a,d,e=b.config,c=e.$table.children("colgroup");c.length&&c.hasClass(g.css.colgroup)&& c.remove();e.widthFixed&&0===e.$table.children("colgroup").length&&(c=h('<colgroup class="'+g.css.colgroup+'">'),a=e.$table.width(),h(b.tBodies).not("."+e.cssInfoBlock).find("tr:first").children(":visible").each(function(){d=parseInt(h(this).width()/a*1E3,10)/10+"%";c.append(h("<col>").css("width",d))}),e.$table.prepend(c))};g.getColumnData=function(b,a,d,e,c){if("undefined"!==typeof a&&null!==a){b=h(b)[0];var g;b=b.config;c=c||b.$headers;if(a[d])return e?a[d]:a[c.index(c.filter('[data-column="'+ d+'"]:last'))];for(g in a)if("string"===typeof g&&(e=c.filter('[data-column="'+d+'"]:last').filter(g).add(c.filter('[data-column="'+d+'"]:last').find(g)),e.length))return a[g]}};g.computeColumnIndex=function(b){var a=[],d=0,e,c,g,f,k,q,n,m,t,p;for(e=0;e<b.length;e++)for(k=b[e].cells,c=0;c<k.length;c++){g=k[c];f=h(g);q=g.parentNode.rowIndex;f.index();n=g.rowSpan||1;m=g.colSpan||1;"undefined"===typeof a[q]&&(a[q]=[]);for(g=0;g<a[q].length+1;g++)if("undefined"===typeof a[q][g]){t=g;break}d=Math.max(t, d);f.attr({"data-column":t});for(g=q;g<q+n;g++)for("undefined"===typeof a[g]&&(a[g]=[]),p=a[g],f=t;f<t+m;f++)p[f]="x"}return d+1};g.isProcessing=function(b,a,d){b=h(b);var e=b[0].config,c=d||b.find("."+g.css.header);a?("undefined"!==typeof d&&0<e.sortList.length&&(c=c.filter(function(){return this.sortDisabled?!1:0<=g.isValueInArray(parseFloat(h(this).attr("data-column")),e.sortList)})),b.add(c).addClass(g.css.processing+" "+e.cssProcessing)):b.add(c).removeClass(g.css.processing+" "+e.cssProcessing)}; g.processTbody=function(b,a,d){b=h(b)[0];if(d)return b.isProcessing=!0,a.before('<span class="tablesorter-savemyplace"/>'),d=h.fn.detach?a.detach():a.remove();d=h(b).find("span.tablesorter-savemyplace");a.insertAfter(d);d.remove();b.isProcessing=!1};g.clearTableBody=function(b){h(b)[0].config.$tbodies.children().detach()};g.bindEvents=function(b,a,d){b=h(b)[0];var e,c=b.config;!0!==d&&(c.$extraHeaders=c.$extraHeaders?c.$extraHeaders.add(a):a);a.find(c.selectorSort).add(a.filter(c.selectorSort)).unbind(["mousedown", "mouseup","sort","keyup",""].join(c.namespace+" ")).bind(["mousedown","mouseup","sort","keyup",""].join(c.namespace+" "),function(d,g){var f;f=d.type;if(!(1!==(d.which||d.button)&&!/sort|keyup/.test(f)||"keyup"===f&&13!==d.which||"mouseup"===f&&!0!==g&&250<(new Date).getTime()-e)){if("mousedown"===f)return e=(new Date).getTime(),/(input|select|button|textarea)/i.test(d.target.tagName)||h(d.target).closest("td,th").hasClass(c.cssAllowClicks)?"":!c.cancelSelection;c.delayInit&&m(c.cache)&&x(b);f=h.fn.closest? h(this).closest("th, td")[0]:/TH|TD/.test(this.tagName)?this:h(this).parents("th, td")[0];f=c.$headers[a.index(f)];f.sortDisabled||O(b,f,d)}});c.cancelSelection&&a.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})};g.restoreHeaders=function(b){var a,d=h(b)[0].config;d.$table.find(d.selectorHeaders).each(function(b){a=h(this);a.find("."+g.css.headerIn).length&&a.html(d.headerContent[b])})};g.destroy=function(b,a,d){b=h(b)[0];if(b.hasInitialized){g.removeWidget(b, !0,!1);var e=h(b),c=b.config,f=e.find("thead:first"),m=f.find("tr."+g.css.headerRow).removeClass(g.css.headerRow+" "+c.cssHeaderRow),k=e.find("tfoot:first > tr").children("th, td");!1===a&&0<=h.inArray("uitheme",c.widgets)&&(e.trigger("applyWidgetId",["uitheme"]),e.trigger("applyWidgetId",["zebra"]));f.find("tr").not(m).remove();e.removeData("tablesorter").unbind("sortReset update updateAll updateRows updateCell addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave keypress sortBegin sortEnd resetToLoadState ".split(" ").join(c.namespace+ " "));c.$headers.add(k).removeClass([g.css.header,c.cssHeader,c.cssAsc,c.cssDesc,g.css.sortAsc,g.css.sortDesc,g.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true");m.find(c.selectorSort).unbind(["mousedown","mouseup","keypress",""].join(c.namespace+" "));g.restoreHeaders(b);e.toggleClass(g.css.table+" "+c.tableClass+" tablesorter-"+c.theme,!1===a);b.hasInitialized=!1;delete b.config.cache;"function"===typeof d&&d(b)}};g.regex={chunk:/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi, chunks:/(^\\0|\\0$)/,hex:/^0x[0-9a-f]+$/i};g.sortNatural=function(b,a){if(b===a)return 0;var d,e,c,f,h,k;e=g.regex;if(e.hex.test(a)){d=parseInt(b.match(e.hex),16);c=parseInt(a.match(e.hex),16);if(d<c)return-1;if(d>c)return 1}d=b.replace(e.chunk,"\\0$1\\0").replace(e.chunks,"").split("\\0");e=a.replace(e.chunk,"\\0$1\\0").replace(e.chunks,"").split("\\0");k=Math.max(d.length,e.length);for(h=0;h<k;h++){c=isNaN(d[h])?d[h]||0:parseFloat(d[h])||0;f=isNaN(e[h])?e[h]||0:parseFloat(e[h])||0;if(isNaN(c)!== isNaN(f))return isNaN(c)?1:-1;typeof c!==typeof f&&(c+="",f+="");if(c<f)return-1;if(c>f)return 1}return 0};g.sortNaturalAsc=function(b,a,d,e,c){if(b===a)return 0;d=c.string[c.empties[d]||c.emptyTo];return""===b&&0!==d?"boolean"===typeof d?d?-1:1:-d||-1:""===a&&0!==d?"boolean"===typeof d?d?1:-1:d||1:g.sortNatural(b,a)};g.sortNaturalDesc=function(b,a,d,e,c){if(b===a)return 0;d=c.string[c.empties[d]||c.emptyTo];return""===b&&0!==d?"boolean"===typeof d?d?-1:1:d||1:""===a&&0!==d?"boolean"===typeof d?d? 1:-1:-d||-1:g.sortNatural(a,b)};g.sortText=function(b,a){return b>a?1:b<a?-1:0};g.getTextValue=function(b,a,d){if(d){var e=b?b.length:0,c=d+a;for(d=0;d<e;d++)c+=b.charCodeAt(d);return a*c}return 0};g.sortNumericAsc=function(b,a,d,e,c,f){if(b===a)return 0;f=f.config;c=f.string[f.empties[c]||f.emptyTo];if(""===b&&0!==c)return"boolean"===typeof c?c?-1:1:-c||-1;if(""===a&&0!==c)return"boolean"===typeof c?c?1:-1:c||1;isNaN(b)&&(b=g.getTextValue(b,d,e));isNaN(a)&&(a=g.getTextValue(a,d,e));return b-a};g.sortNumericDesc= function(b,a,d,e,c,f){if(b===a)return 0;f=f.config;c=f.string[f.empties[c]||f.emptyTo];if(""===b&&0!==c)return"boolean"===typeof c?c?-1:1:c||1;if(""===a&&0!==c)return"boolean"===typeof c?c?1:-1:-c||-1;isNaN(b)&&(b=g.getTextValue(b,d,e));isNaN(a)&&(a=g.getTextValue(a,d,e));return a-b};g.sortNumeric=function(b,a){return b-a};g.characterEquivalents={a:"\u00e1\u00e0\u00e2\u00e3\u00e4\u0105\u00e5",A:"\u00c1\u00c0\u00c2\u00c3\u00c4\u0104\u00c5",c:"\u00e7\u0107\u010d",C:"\u00c7\u0106\u010c",e:"\u00e9\u00e8\u00ea\u00eb\u011b\u0119", E:"\u00c9\u00c8\u00ca\u00cb\u011a\u0118",i:"\u00ed\u00ec\u0130\u00ee\u00ef\u0131",I:"\u00cd\u00cc\u0130\u00ce\u00cf",o:"\u00f3\u00f2\u00f4\u00f5\u00f6",O:"\u00d3\u00d2\u00d4\u00d5\u00d6",ss:"\u00df",SS:"\u1e9e",u:"\u00fa\u00f9\u00fb\u00fc\u016f",U:"\u00da\u00d9\u00db\u00dc\u016e"};g.replaceAccents=function(b){var a,d="[",e=g.characterEquivalents;if(!g.characterRegex){g.characterRegexArray={};for(a in e)"string"===typeof a&&(d+=e[a],g.characterRegexArray[a]=new RegExp("["+e[a]+"]","g"));g.characterRegex= new RegExp(d+"]")}if(g.characterRegex.test(b))for(a in e)"string"===typeof a&&(b=b.replace(g.characterRegexArray[a],a));return b};g.isValueInArray=function(b,a){var d,e=a.length;for(d=0;d<e;d++)if(a[d][0]===b)return d;return-1};g.addParser=function(b){var a,d=g.parsers.length,e=!0;for(a=0;a<d;a++)g.parsers[a].id.toLowerCase()===b.id.toLowerCase()&&(e=!1);e&&g.parsers.push(b)};g.getParserById=function(b){if("false"==b)return!1;var a,d=g.parsers.length;for(a=0;a<d;a++)if(g.parsers[a].id.toLowerCase()=== b.toString().toLowerCase())return g.parsers[a];return!1};g.addWidget=function(b){g.widgets.push(b)};g.hasWidget=function(b,a){b=h(b);return b.length&&b[0].config&&b[0].config.widgetInit[a]||!1};g.getWidgetById=function(b){var a,d,e=g.widgets.length;for(a=0;a<e;a++)if((d=g.widgets[a])&&d.hasOwnProperty("id")&&d.id.toLowerCase()===b.toLowerCase())return d};g.applyWidget=function(b,a,d){b=h(b)[0];var e=b.config,c=e.widgetOptions,f=" "+e.table.className+" ",m=[],k,q,n;!1!==a&&b.hasInitialized&&(b.isApplyingWidgets|| b.isUpdating)||(e.debug&&(k=new Date),n=new RegExp("\\s"+e.widgetClass.replace(/\{name\}/i,"([\\w-]+)")+"\\s","g"),f.match(n)&&(f=f.match(n))&&h.each(f,function(a,b){e.widgets.push(b.replace(n,"$1"))}),e.widgets.length&&(b.isApplyingWidgets=!0,e.widgets=h.grep(e.widgets,function(a,b){return h.inArray(a,e.widgets)===b}),h.each(e.widgets||[],function(a,b){(n=g.getWidgetById(b))&&n.id&&(n.priority||(n.priority=10),m[a]=n)}),m.sort(function(a,b){return a.priority<b.priority?-1:a.priority===b.priority? 0:1}),h.each(m,function(d,f){if(f){if(a||!e.widgetInit[f.id])e.widgetInit[f.id]=!0,f.hasOwnProperty("options")&&(c=b.config.widgetOptions=h.extend(!0,{},f.options,c)),f.hasOwnProperty("init")&&(e.debug&&(q=new Date),f.init(b,f,e,c),e.debug&&g.benchmark("Initializing "+f.id+" widget",q));!a&&f.hasOwnProperty("format")&&(e.debug&&(q=new Date),f.format(b,e,c,!1),e.debug&&g.benchmark((a?"Initializing ":"Applying ")+f.id+" widget",q))}}),a||"function"!==typeof d||d(b)),setTimeout(function(){b.isApplyingWidgets= !1;h.data(b,"lastWidgetApplication",new Date)},0),e.debug&&(f=e.widgets.length,y("Completed "+(!0===a?"initializing ":"applying ")+f+" widget"+(1!==f?"s":""),k)))};g.removeWidget=function(b,a,d){b=h(b)[0];!0===a?(a=[],h.each(g.widgets,function(b,c){c&&c.id&&a.push(c.id)})):a=(h.isArray(a)?a.join(","):a||"").toLowerCase().split(/[\s,]+/);var e,c,l,m=b.config,k=a.length;for(e=0;e<k;e++)c=g.getWidgetById(a[e]),l=h.inArray(a[e],m.widgets),c&&"remove"in c&&(m.debug&&0<=l&&f('Removing "'+a[e]+'" widget'), c.remove(b,m,m.widgetOptions,d),m.widgetInit[a[e]]=!1),0<=l&&!0!==d&&m.widgets.splice(l,1)};g.refreshWidgets=function(b,a,d){b=h(b)[0];var e=b.config.widgets,c=[],f=function(a){h(a).trigger("refreshComplete")};h.each(g.widgets,function(b,d){d&&d.id&&(a||0>h.inArray(d.id,e))&&c.push(d.id)});g.removeWidget(b,c.join(","),!0);!0!==d?(g.applyWidget(b,a||!1,f),a&&g.applyWidget(b,!1,f)):f(b)};g.getData=function(b,a,d){var e="";b=h(b);var c,f;if(!b.length)return"";c=h.metadata?b.metadata():!1;f=" "+(b.attr("class")|| "");"undefined"!==typeof b.data(d)||"undefined"!==typeof b.data(d.toLowerCase())?e+=b.data(d)||b.data(d.toLowerCase()):c&&"undefined"!==typeof c[d]?e+=c[d]:a&&"undefined"!==typeof a[d]?e+=a[d]:" "!==f&&f.match(" "+d+"-")&&(e=f.match(new RegExp("\\s"+d+"-([\\w-]+)"))[1]||"");return h.trim(e)};g.formatFloat=function(b,a){if("string"!==typeof b||""===b)return b;var d;b=(a&&a.config?!1!==a.config.usNumberFormat:"undefined"!==typeof a?a:1)?b.replace(/,/g,""):b.replace(/[\s|\.]/g,"").replace(/,/g,"."); /^\s*\([.\d]+\)/.test(b)&&(b=b.replace(/^\s*\(([.\d]+)\)/,"-$1"));d=parseFloat(b);return isNaN(d)?h.trim(b):d};g.isDigit=function(b){return isNaN(b)?/^[\-+(]?\d+[)]?$/.test(b.toString().replace(/[,.'"\s]/g,"")):!0}}});var p=h.tablesorter;h.fn.extend({tablesorter:p.construct});p.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"});p.addParser({id:"text",is:function(){return!0},format:function(f,y){var m=y.config;f&&(f=h.trim(m.ignoreCase?f.toLocaleLowerCase(): f),f=m.sortLocaleCompare?p.replaceAccents(f):f);return f},type:"text"});p.addParser({id:"digit",is:function(f){return p.isDigit(f)},format:function(f,y){var m=p.formatFloat((f||"").replace(/[^\w,. \-()]/g,""),y);return f&&"number"===typeof m?m:f?h.trim(f&&y.config.ignoreCase?f.toLocaleLowerCase():f):f},type:"numeric"});p.addParser({id:"currency",is:function(f){return/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/.test((f||"").replace(/[+\-,. ]/g,""))},format:function(f, y){var m=p.formatFloat((f||"").replace(/[^\w,. \-()]/g,""),y);return f&&"number"===typeof m?m:f?h.trim(f&&y.config.ignoreCase?f.toLocaleLowerCase():f):f},type:"numeric"});p.addParser({id:"url",is:function(f){return/^(https?|ftp|file):\/\//.test(f)},format:function(f){return f?h.trim(f.replace(/(https?|ftp|file):\/\//,"")):f},parsed:!0,type:"text"});p.addParser({id:"isoDate",is:function(f){return/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/.test(f)},format:function(f,h){var m=f?new Date(f.replace(/-/g,"/")): f;return m instanceof Date&&isFinite(m)?m.getTime():f},type:"numeric"});p.addParser({id:"percent",is:function(f){return/(\d\s*?%|%\s*?\d)/.test(f)&&15>f.length},format:function(f,h){return f?p.formatFloat(f.replace(/%/g,""),h):f},type:"numeric"});p.addParser({id:"image",is:function(f,h,m,p){return 0<p.find("img").length},format:function(f,p,m){return h(m).find("img").attr(p.config.imgAttr||"alt")||f},parsed:!0,type:"text"});p.addParser({id:"usLongDate",is:function(f){return/^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i.test(f)|| /^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i.test(f)},format:function(f,h){var m=f?new Date(f.replace(/(\S)([AP]M)$/i,"$1 $2")):f;return m instanceof Date&&isFinite(m)?m.getTime():f},type:"numeric"});p.addParser({id:"shortDate",is:function(f){return/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/.test((f||"").replace(/\s+/g," ").replace(/[\-.,]/g,"/"))},format:function(f,h,m,v){if(f){m=h.config;var z=m.$headers.filter("[data-column="+v+"]:last");v=z.length&&z[0].dateFormat||p.getData(z, p.getColumnData(h,m.headers,v),"dateFormat")||m.dateFormat;h=f.replace(/\s+/g," ").replace(/[\-.,]/g,"/");"mmddyyyy"===v?h=h.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,"$3/$1/$2"):"ddmmyyyy"===v?h=h.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,"$3/$2/$1"):"yyyymmdd"===v&&(h=h.replace(/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,"$1/$2/$3"));h=new Date(h);return h instanceof Date&&isFinite(h)?h.getTime():f}return f},type:"numeric"});p.addParser({id:"time",is:function(f){return/^(([0-2]?\d:[0-5]\d)|([0-1]?\d:[0-5]\d\s?([AP]M)))$/i.test(f)}, format:function(f,h){var m=f?new Date("2000/01/01 "+f.replace(/(\S)([AP]M)$/i,"$1 $2")):f;return m instanceof Date&&isFinite(m)?m.getTime():f},type:"numeric"});p.addParser({id:"metadata",is:function(){return!1},format:function(f,p,m){f=p.config;f=f.parserMetadataName?f.parserMetadataName:"sortValue";return h(m).metadata()[f]},type:"numeric"});p.addWidget({id:"zebra",priority:90,format:function(f,p,m){var v,z,x,B,F=new RegExp(p.cssChildRow,"i"),D=p.$tbodies;for(f=0;f<D.length;f++)x=0,v=D.eq(f),v=v.children("tr:visible").not(p.selectorRemove), v.each(function(){z=h(this);F.test(this.className)||x++;B=0===x%2;z.removeClass(m.zebra[B?1:0]).addClass(m.zebra[B?0:1])})},remove:function(f,h,m,v){if(!v){h=h.$tbodies;var z=(m.zebra||["even","odd"]).join(" ");for(m=0;m<h.length;m++)v=p.processTbody(f,h.eq(m),!0),v.children().removeClass(z),p.processTbody(f,v,!1)}}});return p});
|