6 lines
28 KiB
JavaScript
6 lines
28 KiB
JavaScript
/*!
|
|
* TableSorter 2.16.2 min - Client-side table sorting with ease!
|
|
* Copyright (c) 2007 Christian Bach
|
|
*/
|
|
!function(g){g.extend({tablesorter:new function(){function d(){var a=arguments[0],b=1<arguments.length?Array.prototype.slice.call(arguments):a;if("undefined"!==typeof console&&"undefined"!==typeof console.log)console[/error/i.test(a)?"error":/warn/i.test(a)?"warn":"log"](b);else alert(b)}function u(a,b){d(a+" ("+((new Date).getTime()-b.getTime())+"ms)")}function n(a){for(var b in a)return!1;return!0}function p(a,b,c){if(!b)return"";var h=a.config,e=h.textExtraction||"",f="",f="basic"===e?g(b).attr(h.textAttribute)|| b.textContent||b.innerText||g(b).text()||"":"function"===typeof e?e(b,a,c):"object"===typeof e&&e.hasOwnProperty(c)?e[c](b,a,c):b.textContent||b.innerText||g(b).text()||"";return g.trim(f)}function s(a){var b=a.config,c=b.$tbodies=b.$table.children("tbody:not(."+b.cssInfoBlock+")"),h,e,t,k,l,m,g,n,w=0,q="",r=c.length;if(0===r)return b.debug?d("Warning: *Empty table!* Not building a parser cache"):"";b.debug&&(n=new Date,d("Detecting parsers for each column"));for(e=[];w<r;){h=c[w].rows;if(h[w])for(t= h[w].cells.length,k=0;k<t;k++){l=b.$headers.filter(":not([colspan])");l=l.add(b.$headers.filter('[colspan="1"]')).filter('[data-column="'+k+'"]:last');m=b.headers[k];g=f.getParserById(f.getData(l,m,"sorter"));b.empties[k]=f.getData(l,m,"empty")||b.emptyTo||(b.emptyToBottom?"bottom":"top");b.strings[k]=f.getData(l,m,"string")||b.stringTo||"max";if(!g)a:{l=a;m=h;g=-1;for(var s=k,A=void 0,x=f.parsers.length,y=!1,F="",A=!0;""===F&&A;)g++,m[g]?(y=m[g].cells[s],F=p(l,y,s),l.config.debug&&d("Checking if value was empty on row "+ g+", column: "+s+': "'+F+'"')):A=!1;for(;0<=--x;)if((A=f.parsers[x])&&"text"!==A.id&&A.is&&A.is(F,l,y)){g=A;break a}g=f.getParserById("text")}b.debug&&(q+="column:"+k+"; parser:"+g.id+"; string:"+b.strings[k]+"; empty: "+b.empties[k]+"\n");e.push(g)}w+=e.length?r:1}b.debug&&(d(q?q:"No parsers detected"),u("Completed detecting parsers",n));b.parsers=e}function x(a){var b,c,h,e,t,k,l,m,z,n,w,q=a.config,r=q.$table.children("tbody"),s=q.parsers;q.cache={};if(!s)return q.debug?d("Warning: *Empty table!* Not building a cache"): "";q.debug&&(m=new Date);q.showProcessing&&f.isProcessing(a,!0);for(t=0;t<r.length;t++)if(w=[],b=q.cache[t]={normalized:[]},!r.eq(t).hasClass(q.cssInfoBlock)){z=r[t]&&r[t].rows.length||0;for(h=0;h<z;++h)if(n={child:[]},k=g(r[t].rows[h]),l=[],k.hasClass(q.cssChildRow)&&0!==h)c=b.normalized.length-1,b.normalized[c][q.columns].$row=b.normalized[c][q.columns].$row.add(k),k.prev().hasClass(q.cssChildRow)||k.prev().addClass(f.css.cssHasChild),n.child[c]=g.trim(k[0].textContent||k[0].innerText||k.text()|| "");else{n.$row=k;n.order=h;for(e=0;e<q.columns;++e)"undefined"===typeof s[e]?q.debug&&d("No parser found for cell:",k[0].cells[e],"does it have a header?"):(c=p(a,k[0].cells[e],e),c=s[e].format(c,a,k[0].cells[e],e),l.push(c),"numeric"===(s[e].type||"").toLowerCase()&&(w[e]=Math.max(Math.abs(c)||0,w[e]||0)));l[q.columns]=n;b.normalized.push(l)}b.colMax=w}q.showProcessing&&f.isProcessing(a);q.debug&&u("Building cache for "+z+" rows",m)}function y(a,b){var c=a.config,h=c.widgetOptions,e=a.tBodies,t= [],k=c.cache,d,m,z,p,w,q;if(n(k))return c.appender?c.appender(a,t):a.isUpdating?c.$table.trigger("updateComplete",a):"";c.debug&&(q=new Date);for(w=0;w<e.length;w++)if(d=g(e[w]),d.length&&!d.hasClass(c.cssInfoBlock)){z=f.processTbody(a,d,!0);d=k[w].normalized;m=d.length;for(p=0;p<m;p++)t.push(d[p][c.columns].$row),c.appender&&(!c.pager||c.pager.removeRows&&h.pager_removeRows||c.pager.ajax)||z.append(d[p][c.columns].$row);f.processTbody(a,z,!1)}c.appender&&c.appender(a,t);c.debug&&u("Rebuilt table", q);b||c.appender||f.applyWidget(a);a.isUpdating&&c.$table.trigger("updateComplete",a)}function C(a){return/^d/i.test(a)||1===a}function D(a){var b,c,h,e,t,k,l,m=a.config;m.headerList=[];m.headerContent=[];m.debug&&(l=new Date);m.columns=f.computeColumnIndex(m.$table.children("thead, tfoot").children("tr"));e=m.cssIcon?'<i class="'+(m.cssIcon===f.css.icon?f.css.icon:m.cssIcon+" "+f.css.icon)+'"></i>':"";m.$headers=g(a).find(m.selectorHeaders).each(function(a){c=g(this);b=m.headers[a];m.headerContent[a]= g(this).html();t=m.headerTemplate.replace(/\{content\}/g,g(this).html()).replace(/\{icon\}/g,e);m.onRenderTemplate&&(h=m.onRenderTemplate.apply(c,[a,t]))&&"string"===typeof h&&(t=h);g(this).html('<div class="'+f.css.headerIn+'">'+t+"</div>");m.onRenderHeader&&m.onRenderHeader.apply(c,[a]);this.column=parseInt(g(this).attr("data-column"),10);this.order=C(f.getData(c,b,"sortInitialOrder")||m.sortInitialOrder)?[1,0,2]:[0,1,2];this.count=-1;this.lockedOrder=!1;k=f.getData(c,b,"lockedOrder")||!1;"undefined"!== typeof k&&!1!==k&&(this.order=this.lockedOrder=C(k)?[1,1,1]:[0,0,0]);c.addClass(f.css.header+" "+m.cssHeader);m.headerList[a]=this;c.parent().addClass(f.css.headerRow+" "+m.cssHeaderRow).attr("role","row");m.tabIndex&&c.attr("tabindex",0)}).attr({scope:"col",role:"columnheader"});B(a);m.debug&&(u("Built headers:",l),d(m.$headers))}function E(a,b,c){var h=a.config;h.$table.find(h.selectorRemove).remove();s(a);x(a);H(h.$table,b,c)}function B(a){var b,c,h=a.config;h.$headers.each(function(e,t){c=g(t); b="false"===f.getData(t,h.headers[e],"sorter");t.sortDisabled=b;c[b?"addClass":"removeClass"]("sorter-false").attr("aria-disabled",""+b);a.id&&(b?c.removeAttr("aria-controls"):c.attr("aria-controls",a.id))})}function G(a){var b,c,h=a.config,e=h.sortList,t=e.length,d=f.css.sortNone+" "+h.cssNone,l=[f.css.sortAsc+" "+h.cssAsc,f.css.sortDesc+" "+h.cssDesc],m=["ascending","descending"],n=g(a).find("tfoot tr").children().add(h.$extraHeaders).removeClass(l.join(" "));h.$headers.removeClass(l.join(" ")).addClass(d).attr("aria-sort", "none");for(b=0;b<t;b++)if(2!==e[b][1]&&(a=h.$headers.not(".sorter-false").filter('[data-column="'+e[b][0]+'"]'+(1===t?":last":"")),a.length)){for(c=0;c<a.length;c++)a[c].sortDisabled||a.eq(c).removeClass(d).addClass(l[e[b][1]]).attr("aria-sort",m[e[b][1]]);n.length&&n.filter('[data-column="'+e[b][0]+'"]').removeClass(d).addClass(l[e[b][1]])}h.$headers.not(".sorter-false").each(function(){var a=g(this),b=this.order[(this.count+1)%(h.sortReset?3:2)],b=a.text()+": "+f.language[a.hasClass(f.css.sortAsc)? "sortAsc":a.hasClass(f.css.sortDesc)?"sortDesc":"sortNone"]+f.language[0===b?"nextAsc":1===b?"nextDesc":"nextNone"];a.attr("aria-label",b)})}function L(a){if(a.config.widthFixed&&0===g(a).find("colgroup").length){var b=g("<colgroup>"),c=g(a).width();g(a.tBodies[0]).find("tr:first").children("td:visible").each(function(){b.append(g("<col>").css("width",parseInt(g(this).width()/c*1E3,10)/10+"%"))});g(a).prepend(b)}}function M(a,b,c){var h,e,f,d=a.config;a=b||d.sortList;d.sortList=[];g.each(a,function(a, b){h=[parseInt(b[0],10),parseInt(b[1],10)];if(f=d.$headers.filter('[data-column="'+h[0]+'"]:last')[0])d.sortList.push(h),e=g.inArray(h[1],f.order),c&&(f.count+=1),f.count=0<=e?e:h[1]%(d.sortReset?3:2)})}function N(a,b){return a&&a[b]?a[b].type||"":""}function O(a,b,c){var h,e,d,k=a.config,l=!c[k.sortMultiSortKey],m=k.$table;m.trigger("sortStart",a);b.count=c[k.sortResetKey]?2:(b.count+1)%(k.sortReset?3:2);k.sortRestart&&(e=b,k.$headers.each(function(){this===e||!l&&g(this).is("."+f.css.sortDesc+",."+ f.css.sortAsc)||(this.count=-1)}));e=b.column;if(l){k.sortList=[];if(null!==k.sortForce)for(h=k.sortForce,c=0;c<h.length;c++)h[c][0]!==e&&k.sortList.push(h[c]);h=b.order[b.count];if(2>h&&(k.sortList.push([e,h]),1<b.colSpan))for(c=1;c<b.colSpan;c++)k.sortList.push([e+c,h])}else{if(k.sortAppend&&1<k.sortList.length)for(c=0;c<k.sortAppend.length;c++)d=f.isValueInArray(k.sortAppend[c][0],k.sortList),0<=d&&k.sortList.splice(d,1);if(0<=f.isValueInArray(e,k.sortList))for(c=0;c<k.sortList.length;c++)d=k.sortList[c], h=k.$headers.filter('[data-column="'+d[0]+'"]:last')[0],d[0]===e&&(d[1]=h.order[b.count],2===d[1]&&(k.sortList.splice(c,1),h.count=-1));else if(h=b.order[b.count],2>h&&(k.sortList.push([e,h]),1<b.colSpan))for(c=1;c<b.colSpan;c++)k.sortList.push([e+c,h])}if(null!==k.sortAppend)for(h=k.sortAppend,c=0;c<h.length;c++)h[c][0]!==e&&k.sortList.push(h[c]);m.trigger("sortBegin",a);setTimeout(function(){G(a);I(a);y(a);m.trigger("sortEnd",a)},1)}function I(a){var b,c,h,e,d,k,g,m,z,p,w,q=0,r=a.config,s=r.textSorter|| "",v=r.sortList,x=v.length,y=a.tBodies.length;if(!r.serverSideSorting&&!n(r.cache)){r.debug&&(d=new Date);for(c=0;c<y;c++)k=r.cache[c].colMax,g=r.cache[c].normalized,g.sort(function(c,d){for(b=0;b<x;b++){e=v[b][0];m=v[b][1];q=0===m;if(r.sortStable&&c[e]===d[e]&&1===x)break;(h=/n/i.test(N(r.parsers,e)))&&r.strings[e]?(h="boolean"===typeof r.string[r.strings[e]]?(q?1:-1)*(r.string[r.strings[e]]?-1:1):r.strings[e]?r.string[r.strings[e]]||0:0,z=r.numberSorter?r.numberSorter(c[e],d[e],q,k[e],a):f["sortNumeric"+ (q?"Asc":"Desc")](c[e],d[e],h,k[e],e,a)):(p=q?c:d,w=q?d:c,z="function"===typeof s?s(p[e],w[e],q,e,a):"object"===typeof s&&s.hasOwnProperty(e)?s[e](p[e],w[e],q,e,a):f["sortNatural"+(q?"Asc":"Desc")](c[e],d[e],e,a,r));if(z)return z}return c[r.columns].order-d[r.columns].order});r.debug&&u("Sorting on "+v.toString()+" and dir "+m+" time",d)}}function J(a,b){a[0].isUpdating&&a.trigger("updateComplete");g.isFunction(b)&&b(a[0])}function H(a,b,c){var h=a[0].config.sortList;!1!==b&&!a[0].isProcessing&&h.length? a.trigger("sorton",[h,function(){J(a,c)},!0]):(J(a,c),f.applyWidget(a[0],!1))}function K(a){var b=a.config,c=b.$table;c.unbind("sortReset update updateRows updateCell updateAll addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave ".split(" ").join(b.namespace+" ")).bind("sortReset"+b.namespace,function(c,e){c.stopPropagation();b.sortList=[];G(a);I(a);y(a);g.isFunction(e)&&e(a)}).bind("updateAll"+b.namespace,function(c,e,d){c.stopPropagation(); a.isUpdating=!0;f.refreshWidgets(a,!0,!0);f.restoreHeaders(a);D(a);f.bindEvents(a,b.$headers,!0);K(a);E(a,e,d)}).bind("update"+b.namespace+" updateRows"+b.namespace,function(b,c,d){b.stopPropagation();a.isUpdating=!0;B(a);E(a,c,d)}).bind("updateCell"+b.namespace,function(h,e,d,f){h.stopPropagation();a.isUpdating=!0;c.find(b.selectorRemove).remove();var l,m;l=c.find("tbody");m=g(e);h=l.index(m.parents("tbody").filter(":first"));var n=m.parents("tr").filter(":first");e=m[0];l.length&&0<=h&&(l=l.eq(h).find("tr").index(n), m=m.index(),b.cache[h].normalized[l][b.columns].$row=n,e=b.cache[h].normalized[l][m]=b.parsers[m].format(p(a,e,m),a,e,m),"numeric"===(b.parsers[m].type||"").toLowerCase()&&(b.cache[h].colMax[m]=Math.max(Math.abs(e)||0,b.cache[h].colMax[m]||0)),H(c,d,f))}).bind("addRows"+b.namespace,function(h,e,d,f){h.stopPropagation();a.isUpdating=!0;if(n(b.cache))B(a),E(a,d,f);else{e=g(e);var l,m,u,x,w=e.filter("tr").length,q=c.find("tbody").index(e.parents("tbody").filter(":first"));b.parsers&&b.parsers.length|| s(a);for(h=0;h<w;h++){m=e[h].cells.length;x=[];u={child:[],$row:e.eq(h),order:b.cache[q].normalized.length};for(l=0;l<m;l++)x[l]=b.parsers[l].format(p(a,e[h].cells[l],l),a,e[h].cells[l],l),"numeric"===(b.parsers[l].type||"").toLowerCase()&&(b.cache[q].colMax[l]=Math.max(Math.abs(x[l])||0,b.cache[q].colMax[l]||0));x.push(u);b.cache[q].normalized.push(x)}H(c,d,f)}}).bind("updateComplete"+b.namespace,function(){a.isUpdating=!1}).bind("sorton"+b.namespace,function(b,e,d,k){var l=a.config;b.stopPropagation(); c.trigger("sortStart",this);M(a,e,!0);G(a);l.delayInit&&n(l.cache)&&x(a);c.trigger("sortBegin",this);I(a);y(a,k);c.trigger("sortEnd",this);f.applyWidget(a);g.isFunction(d)&&d(a)}).bind("appendCache"+b.namespace,function(b,c,d){b.stopPropagation();y(a,d);g.isFunction(c)&&c(a)}).bind("updateCache"+b.namespace,function(c,e){b.parsers&&b.parsers.length||s(a);x(a);g.isFunction(e)&&e(a)}).bind("applyWidgetId"+b.namespace,function(c,e){c.stopPropagation();f.getWidgetById(e).format(a,b,b.widgetOptions)}).bind("applyWidgets"+ b.namespace,function(b,c){b.stopPropagation();f.applyWidget(a,c)}).bind("refreshWidgets"+b.namespace,function(b,c,d){b.stopPropagation();f.refreshWidgets(a,c,d)}).bind("destroy"+b.namespace,function(b,c,d){b.stopPropagation();f.destroy(a,c,d)})}var f=this;f.version="2.16.2";f.parsers=[];f.widgets=[];f.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,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,initialized:null,tableClass:"",cssAsc:"",cssDesc:"",cssNone:"",cssHeader:"",cssHeaderRow:"",cssProcessing:"", cssChildRow:"tablesorter-childRow",cssIcon:"tablesorter-icon",cssInfoBlock:"tablesorter-infoOnly",selectorHeaders:"> thead th, > thead td",selectorSort:"th, td",selectorRemove:".remove-me",debug:!1,headerList:[],empties:{},strings:{},parsers:[]};f.css={table:"tablesorter",cssHasChild:"tablesorter-hasChildRow",childRow:"tablesorter-childRow",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"};f.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"};f.log=d;f.benchmark=u;f.construct=function(a){return this.each(function(){var b=g.extend(!0,{},f.defaults,a);!this.hasInitialized&&f.buildTable&&"TABLE"!== this.tagName?f.buildTable(this,b):f.setup(this,b)})};f.setup=function(a,b){if(!a||!a.tHead||0===a.tBodies.length||!0===a.hasInitialized)return b.debug?d("ERROR: stopping initialization! No table, thead, tbody or tablesorter has already been initialized"):"";var c="",h=g(a),e=g.metadata;a.hasInitialized=!1;a.isProcessing=!0;a.config=b;g.data(a,"tablesorter",b);b.debug&&g.data(a,"startoveralltimer",new Date);b.supportsDataObject=function(a){a[0]=parseInt(a[0],10);return 1<a[0]||1===a[0]&&4<=parseInt(a[1], 10)}(g.fn.jquery.split("."));b.string={max:1,min:-1,emptyMin:1,emptyMax:-1,zero:0,none:0,"null":0,top:!0,bottom:!1};/tablesorter\-/.test(h.attr("class"))||(c=""!==b.theme?" tablesorter-"+b.theme:"");b.$table=h.addClass(f.css.table+" "+b.tableClass+c).attr({role:"grid"});b.namespace=b.namespace?"."+b.namespace.replace(/\W/g,""):".tablesorter"+Math.random().toString(16).slice(2);b.$tbodies=h.children("tbody:not(."+b.cssInfoBlock+")").attr({"aria-live":"polite","aria-relevant":"all"});b.$table.find("caption").length&& b.$table.attr("aria-labelledby","theCaption");b.widgetInit={};b.textExtraction=b.$table.attr("data-text-extraction")||b.textExtraction||"basic";D(a);L(a);s(a);b.delayInit||x(a);f.bindEvents(a,b.$headers,!0);K(a);b.supportsDataObject&&"undefined"!==typeof h.data().sortlist?b.sortList=h.data().sortlist:e&&h.metadata()&&h.metadata().sortlist&&(b.sortList=h.metadata().sortlist);f.applyWidget(a,!0);0<b.sortList.length?h.trigger("sorton",[b.sortList,{},!b.initWidgets,!0]):(G(a),b.initWidgets&&setTimeout(function(){f.applyWidget(a, !1)},0));b.showProcessing&&h.unbind("sortBegin"+b.namespace+" sortEnd"+b.namespace).bind("sortBegin"+b.namespace+" sortEnd"+b.namespace,function(b){f.isProcessing(a,"sortBegin"===b.type)});a.hasInitialized=!0;a.isProcessing=!1;b.debug&&f.benchmark("Overall initialization time",g.data(a,"startoveralltimer"));h.trigger("tablesorter-initialized",a);"function"===typeof b.initialized&&b.initialized(a)};f.computeColumnIndex=function(a){var b=[],c=0,h,e,d,f,l,m,n,u,p,q;for(h=0;h<a.length;h++)for(l=a[h].cells, e=0;e<l.length;e++){d=l[e];f=g(d);m=d.parentNode.rowIndex;f.index();n=d.rowSpan||1;u=d.colSpan||1;"undefined"===typeof b[m]&&(b[m]=[]);for(d=0;d<b[m].length+1;d++)if("undefined"===typeof b[m][d]){p=d;break}c=Math.max(p,c);f.attr({"data-column":p});for(d=m;d<m+n;d++)for("undefined"===typeof b[d]&&(b[d]=[]),q=b[d],f=p;f<p+u;f++)q[f]="x"}return c+1};f.isProcessing=function(a,b,c){a=g(a);var d=a[0].config;a=c||a.find("."+f.css.header);b?("undefined"!==typeof c&&0<d.sortList.length&&(a=a.filter(function(){return this.sortDisabled? !1:0<=f.isValueInArray(parseFloat(g(this).attr("data-column")),d.sortList)})),a.addClass(f.css.processing+" "+d.cssProcessing)):a.removeClass(f.css.processing+" "+d.cssProcessing)};f.processTbody=function(a,b,c){a=g(a)[0];if(c)return a.isProcessing=!0,b.before('<span class="tablesorter-savemyplace"/>'),c=g.fn.detach?b.detach():b.remove();c=g(a).find("span.tablesorter-savemyplace");b.insertAfter(c);c.remove();a.isProcessing=!1};f.clearTableBody=function(a){g(a)[0].config.$tbodies.empty()};f.bindEvents= function(a,b,c){a=g(a)[0];var d,e=a.config;!0!==c&&(e.$extraHeaders=e.$extraHeaders?e.$extraHeaders.add(b):b);b.find(e.selectorSort).add(b.filter(e.selectorSort)).unbind(["mousedown","mouseup","sort","keyup",""].join(e.namespace+" ")).bind(["mousedown","mouseup","sort","keyup",""].join(e.namespace+" "),function(c,f){var l;l=c.type;if(!(1!==(c.which||c.button)&&!/sort|keyup/.test(l)||"keyup"===l&&13!==c.which||"mouseup"===l&&!0!==f&&250<(new Date).getTime()-d)){if("mousedown"===l)return d=(new Date).getTime(), "INPUT"===c.target.tagName?"":!e.cancelSelection;e.delayInit&&n(e.cache)&&x(a);l=/TH|TD/.test(this.tagName)?this:g(this).parents("th, td")[0];l=e.$headers[b.index(l)];l.sortDisabled||O(a,l,c)}});e.cancelSelection&&b.attr("unselectable","on").bind("selectstart",!1).css({"user-select":"none",MozUserSelect:"none"})};f.restoreHeaders=function(a){var b=g(a)[0].config;b.$table.find(b.selectorHeaders).each(function(a){g(this).find("."+f.css.headerIn).length&&g(this).html(b.headerContent[a])})};f.destroy= function(a,b,c){a=g(a)[0];if(a.hasInitialized){f.refreshWidgets(a,!0,!0);var d=g(a),e=a.config,t=d.find("thead:first"),k=t.find("tr."+f.css.headerRow).removeClass(f.css.headerRow+" "+e.cssHeaderRow),l=d.find("tfoot:first > tr").children("th, td");!1===b&&0<=g.inArray("uitheme",e.widgets)&&(d.trigger("applyWidgetId",["uitheme"]),d.trigger("applyWidgetId",["zebra"]));t.find("tr").not(k).remove();d.removeData("tablesorter").unbind("sortReset update updateAll updateRows updateCell addRows updateComplete sorton appendCache updateCache applyWidgetId applyWidgets refreshWidgets destroy mouseup mouseleave keypress sortBegin sortEnd ".split(" ").join(e.namespace+ " "));e.$headers.add(l).removeClass([f.css.header,e.cssHeader,e.cssAsc,e.cssDesc,f.css.sortAsc,f.css.sortDesc,f.css.sortNone].join(" ")).removeAttr("data-column").removeAttr("aria-label").attr("aria-disabled","true");k.find(e.selectorSort).unbind(["mousedown","mouseup","keypress",""].join(e.namespace+" "));f.restoreHeaders(a);d.toggleClass(f.css.table+" "+e.tableClass+" tablesorter-"+e.theme,!1===b);a.hasInitialized=!1;delete a.config.cache;"function"===typeof c&&c(a)}};f.regex={chunk:/(^([+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?)?$|^0x[0-9a-f]+$|\d+)/gi, chunks:/(^\\0|\\0$)/,hex:/^0x[0-9a-f]+$/i};f.sortNatural=function(a,b){if(a===b)return 0;var c,d,e,g,k,l;d=f.regex;if(d.hex.test(b)){c=parseInt(a.match(d.hex),16);e=parseInt(b.match(d.hex),16);if(c<e)return-1;if(c>e)return 1}c=a.replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0");d=b.replace(d.chunk,"\\0$1\\0").replace(d.chunks,"").split("\\0");l=Math.max(c.length,d.length);for(k=0;k<l;k++){e=isNaN(c[k])?c[k]||0:parseFloat(c[k])||0;g=isNaN(d[k])?d[k]||0:parseFloat(d[k])||0;if(isNaN(e)!== isNaN(g))return isNaN(e)?1:-1;typeof e!==typeof g&&(e+="",g+="");if(e<g)return-1;if(e>g)return 1}return 0};f.sortNaturalAsc=function(a,b,c,d,e){if(a===b)return 0;c=e.string[e.empties[c]||e.emptyTo];return""===a&&0!==c?"boolean"===typeof c?c?-1:1:-c||-1:""===b&&0!==c?"boolean"===typeof c?c?1:-1:c||1:f.sortNatural(a,b)};f.sortNaturalDesc=function(a,b,c,d,e){if(a===b)return 0;c=e.string[e.empties[c]||e.emptyTo];return""===a&&0!==c?"boolean"===typeof c?c?-1:1:c||1:""===b&&0!==c?"boolean"===typeof c?c? 1:-1:-c||-1:f.sortNatural(b,a)};f.sortText=function(a,b){return a>b?1:a<b?-1:0};f.getTextValue=function(a,b,c){if(c){var d=a?a.length:0,e=c+b;for(c=0;c<d;c++)e+=a.charCodeAt(c);return b*e}return 0};f.sortNumericAsc=function(a,b,c,d,e,g){if(a===b)return 0;g=g.config;e=g.string[g.empties[e]||g.emptyTo];if(""===a&&0!==e)return"boolean"===typeof e?e?-1:1:-e||-1;if(""===b&&0!==e)return"boolean"===typeof e?e?1:-1:e||1;isNaN(a)&&(a=f.getTextValue(a,c,d));isNaN(b)&&(b=f.getTextValue(b,c,d));return a-b};f.sortNumericDesc= function(a,b,c,d,e,g){if(a===b)return 0;g=g.config;e=g.string[g.empties[e]||g.emptyTo];if(""===a&&0!==e)return"boolean"===typeof e?e?-1:1:e||1;if(""===b&&0!==e)return"boolean"===typeof e?e?1:-1:-e||-1;isNaN(a)&&(a=f.getTextValue(a,c,d));isNaN(b)&&(b=f.getTextValue(b,c,d));return b-a};f.sortNumeric=function(a,b){return a-b};f.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"};f.replaceAccents=function(a){var b,c="[",d=f.characterEquivalents;if(!f.characterRegex){f.characterRegexArray={};for(b in d)"string"===typeof b&&(c+=d[b],f.characterRegexArray[b]=RegExp("["+d[b]+"]","g"));f.characterRegex= RegExp(c+"]")}if(f.characterRegex.test(a))for(b in d)"string"===typeof b&&(a=a.replace(f.characterRegexArray[b],b));return a};f.isValueInArray=function(a,b){var c,d=b.length;for(c=0;c<d;c++)if(b[c][0]===a)return c;return-1};f.addParser=function(a){var b,c=f.parsers.length,d=!0;for(b=0;b<c;b++)f.parsers[b].id.toLowerCase()===a.id.toLowerCase()&&(d=!1);d&&f.parsers.push(a)};f.getParserById=function(a){var b,c=f.parsers.length;for(b=0;b<c;b++)if(f.parsers[b].id.toLowerCase()===a.toString().toLowerCase())return f.parsers[b]; return!1};f.addWidget=function(a){f.widgets.push(a)};f.getWidgetById=function(a){var b,c,d=f.widgets.length;for(b=0;b<d;b++)if((c=f.widgets[b])&&c.hasOwnProperty("id")&&c.id.toLowerCase()===a.toLowerCase())return c};f.applyWidget=function(a,b){a=g(a)[0];var c=a.config,d=c.widgetOptions,e=[],n,k,l;!1!==b&&a.hasInitialized&&(a.isApplyingWidgets||a.isUpdating)||(c.debug&&(n=new Date),c.widgets.length&&(a.isApplyingWidgets=!0,c.widgets=g.grep(c.widgets,function(a,b){return g.inArray(a,c.widgets)===b}), g.each(c.widgets||[],function(a,b){(l=f.getWidgetById(b))&&l.id&&(l.priority||(l.priority=10),e[a]=l)}),e.sort(function(a,b){return a.priority<b.priority?-1:a.priority===b.priority?0:1}),g.each(e,function(e,f){if(f){if(b||!c.widgetInit[f.id])f.hasOwnProperty("options")&&(d=a.config.widgetOptions=g.extend(!0,{},f.options,d)),f.hasOwnProperty("init")&&f.init(a,f,c,d),c.widgetInit[f.id]=!0;!b&&f.hasOwnProperty("format")&&f.format(a,c,d,!1)}})),setTimeout(function(){a.isApplyingWidgets=!1},0),c.debug&& (k=c.widgets.length,u("Completed "+(!0===b?"initializing ":"applying ")+k+" widget"+(1!==k?"s":""),n)))};f.refreshWidgets=function(a,b,c){a=g(a)[0];var h,e=a.config,n=e.widgets,k=f.widgets,l=k.length;for(h=0;h<l;h++)k[h]&&k[h].id&&(b||0>g.inArray(k[h].id,n))&&(e.debug&&d('Refeshing widgets: Removing "'+k[h].id+'"'),k[h].hasOwnProperty("remove")&&e.widgetInit[k[h].id]&&(k[h].remove(a,e,e.widgetOptions),e.widgetInit[k[h].id]=!1));!0!==c&&f.applyWidget(a,b)};f.getData=function(a,b,c){var d="";a=g(a); var e,f;if(!a.length)return"";e=g.metadata?a.metadata():!1;f=" "+(a.attr("class")||"");"undefined"!==typeof a.data(c)||"undefined"!==typeof a.data(c.toLowerCase())?d+=a.data(c)||a.data(c.toLowerCase()):e&&"undefined"!==typeof e[c]?d+=e[c]:b&&"undefined"!==typeof b[c]?d+=b[c]:" "!==f&&f.match(" "+c+"-")&&(d=f.match(RegExp("\\s"+c+"-([\\w-]+)"))[1]||"");return g.trim(d)};f.formatFloat=function(a,b){if("string"!==typeof a||""===a)return a;var c;a=(b&&b.config?!1!==b.config.usNumberFormat:"undefined"!== typeof b?b:1)?a.replace(/,/g,""):a.replace(/[\s|\.]/g,"").replace(/,/g,".");/^\s*\([.\d]+\)/.test(a)&&(a=a.replace(/^\s*\(([.\d]+)\)/,"-$1"));c=parseFloat(a);return isNaN(c)?g.trim(a):c};f.isDigit=function(a){return isNaN(a)?/^[\-+(]?\d+[)]?$/.test(a.toString().replace(/[,.'"\s]/g,"")):!0}}});var p=g.tablesorter;g.fn.extend({tablesorter:p.construct});p.addParser({id:"text",is:function(){return!0},format:function(d,u){var n=u.config;d&&(d=g.trim(n.ignoreCase?d.toLocaleLowerCase():d),d=n.sortLocaleCompare? p.replaceAccents(d):d);return d},type:"text"});p.addParser({id:"digit",is:function(d){return p.isDigit(d)},format:function(d,u){var n=p.formatFloat((d||"").replace(/[^\w,. \-()]/g,""),u);return d&&"number"===typeof n?n:d?g.trim(d&&u.config.ignoreCase?d.toLocaleLowerCase():d):d},type:"numeric"});p.addParser({id:"currency",is:function(d){return/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/.test((d||"").replace(/[+\-,. ]/g,""))},format:function(d,u){var n=p.formatFloat((d|| "").replace(/[^\w,. \-()]/g,""),u);return d&&"number"===typeof n?n:d?g.trim(d&&u.config.ignoreCase?d.toLocaleLowerCase():d):d},type:"numeric"});p.addParser({id:"ipAddress",is:function(d){return/^\d{1,3}[\.]\d{1,3}[\.]\d{1,3}[\.]\d{1,3}$/.test(d)},format:function(d,g){var n,v=d?d.split("."):"",s="",x=v.length;for(n=0;n<x;n++)s+=("00"+v[n]).slice(-3);return d?p.formatFloat(s,g):d},type:"numeric"});p.addParser({id:"url",is:function(d){return/^(https?|ftp|file):\/\//.test(d)},format:function(d){return d? g.trim(d.replace(/(https?|ftp|file):\/\//,"")):d},type:"text"});p.addParser({id:"isoDate",is:function(d){return/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/.test(d)},format:function(d,g){return d?p.formatFloat(""!==d?(new Date(d.replace(/-/g,"/"))).getTime()||d:"",g):d},type:"numeric"});p.addParser({id:"percent",is:function(d){return/(\d\s*?%|%\s*?\d)/.test(d)&&15>d.length},format:function(d,g){return d?p.formatFloat(d.replace(/%/g,""),g):d},type:"numeric"});p.addParser({id:"usLongDate",is:function(d){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(d)|| /^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i.test(d)},format:function(d,g){return d?p.formatFloat((new Date(d.replace(/(\S)([AP]M)$/i,"$1 $2"))).getTime()||d,g):d},type:"numeric"});p.addParser({id:"shortDate",is:function(d){return/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/.test((d||"").replace(/\s+/g," ").replace(/[\-.,]/g,"/"))},format:function(d,g,n,v){if(d){n=g.config;var s=n.$headers.filter("[data-column="+v+"]:last");v=s.length&&s[0].dateFormat||p.getData(s,n.headers[v],"dateFormat")|| n.dateFormat;d=d.replace(/\s+/g," ").replace(/[\-.,]/g,"/");"mmddyyyy"===v?d=d.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,"$3/$1/$2"):"ddmmyyyy"===v?d=d.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,"$3/$2/$1"):"yyyymmdd"===v&&(d=d.replace(/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,"$1/$2/$3"))}return d?p.formatFloat((new Date(d)).getTime()||d,g):d},type:"numeric"});p.addParser({id:"time",is:function(d){return/^(([0-2]?\d:[0-5]\d)|([0-1]?\d:[0-5]\d\s?([AP]M)))$/i.test(d)},format:function(d,g){return d? p.formatFloat((new Date("2000/01/01 "+d.replace(/(\S)([AP]M)$/i,"$1 $2"))).getTime()||d,g):d},type:"numeric"});p.addParser({id:"metadata",is:function(){return!1},format:function(d,p,n){d=p.config;d=d.parserMetadataName?d.parserMetadataName:"sortValue";return g(n).metadata()[d]},type:"numeric"});p.addWidget({id:"zebra",priority:90,format:function(d,u,n){var v,s,x,y,C,D,E=RegExp(u.cssChildRow,"i"),B=u.$tbodies;u.debug&&(C=new Date);for(d=0;d<B.length;d++)v=B.eq(d),D=v.children("tr").length,1<D&&(x= 0,v=v.children("tr:visible").not(u.selectorRemove),v.each(function(){s=g(this);E.test(this.className)||x++;y=0===x%2;s.removeClass(n.zebra[y?1:0]).addClass(n.zebra[y?0:1])}));u.debug&&p.benchmark("Applying Zebra widget",C)},remove:function(d,p,n){var v;p=p.$tbodies;var s=(n.zebra||["even","odd"]).join(" ");for(n=0;n<p.length;n++)v=g.tablesorter.processTbody(d,p.eq(n),!0),v.children().removeClass(s),g.tablesorter.processTbody(d,v,!1)}})}(jQuery);
|