tablesorter/js/jquery.tablesorter.min.js
2012-05-19 15:46:14 -05:00

7 lines
19 KiB
JavaScript
Raw Blame History

/*!
* TableSorter 2.3.3 - Client-side table sorting with ease!
* Minified using UglifyJS (http://jscompress.com/)
* Copyright (c) 2007 Christian Bach
*/
!function($){$.extend({tablesorter:new function(){function log(a){if(typeof console!=="undefined"&&typeof console.log!=="undefined"){console.log(a)}else{alert(a)}}function benchmark(a,b){log(a+" ("+((new Date).getTime()-b.getTime())+"ms)")}function getElementText(a,b,c){var d="",e=a.config.textExtraction;if(!b){return""}if(e==="simple"){d=$(b).text()}else{if(typeof e==="function"){d=e(b,a,c)}else if(typeof e==="object"&&e.hasOwnProperty(c)){d=e[c](b,a,c)}else{d=$(b).text()}}return $.trim(d)}function getParserById(a){var b,c=parsers.length;for(b=0;b<c;b++){if(parsers[b].id.toLowerCase()===a.toString().toLowerCase()){return parsers[b]}}return false}function detectParserForColumn(a,b,c,d){var e,f=parsers.length,g=false,h="",i=true;while(h===""&&i){c++;if(b[c]){g=b[c].cells[d];h=getElementText(a,g,d);if(a.config.debug){log("Checking if value was empty on row "+c+", column:"+d+": "+h)}}else{i=false}}for(e=1;e<f;e++){if(parsers[e].is(h,a,g)){return parsers[e]}}return parsers[0]}function buildParserCache(a,b){var c=a.config,d=$(a.tBodies).filter(":not(."+c.cssInfoBlock+")"),e=$.tablesorter,f,g,h,i,j,k,l,m,n,o="";if(d.length===0){return}f=d[0].rows;if(f[0]){g=[];h=f[0].cells.length;for(i=0;i<h;i++){j=b.filter(':not([colspan])[data-column="'+i+'"]:last');l=c.headers[i];n=getParserById(e.getData(j,l,"sorter"));c.empties[i]=e.getData(j,l,"empty")||c.emptyTo||(c.emptyToBottom?"bottom":"top");c.strings[i]=e.getData(j,l,"string")||c.stringTo||"max";if(!n){n=detectParserForColumn(a,f,-1,i)}if(c.debug){o+="column:"+i+"; parser:"+n.id+"; string:"+c.strings[i]+"; empty: "+c.empties[i]+"\n"}g.push(n)}}if(c.debug){log(o)}return g}function buildRegex(){var a,b="[",c=$.tablesorter,d=c.characterEquivalents;c.characterRegexArray={};for(a in d){if(typeof a==="string"){b+=d[a];c.characterRegexArray[a]=new RegExp("["+d[a]+"]","g")}}c.characterRegex=new RegExp(b+"]")}function buildCache(a){var b=a.tBodies,c=a.config,d,e,f=c.parsers,g,h,i,j,k,l,m;c.cache={};if(c.debug){m=new Date}for(j=0;j<b.length;j++){c.cache[j]={row:[],normalized:[]};if(!$(b[j]).hasClass(c.cssInfoBlock)){d=b[j]&&b[j].rows.length||0;e=b[j].rows[0]&&b[j].rows[0].cells.length||0;for(h=0;h<d;++h){k=$(b[j].rows[h]);l=[];if(k.hasClass(c.cssChildRow)){c.cache[j].row[c.cache[j].row.length-1]=c.cache[j].row[c.cache[j].row.length-1].add(k);continue}c.cache[j].row.push(k);for(i=0;i<e;++i){g=getElementText(a,k[0].cells[i],i);l.push(f[i].format(g,a,k[0].cells[i],i))}l.push(c.cache[j].normalized.length);c.cache[j].normalized.push(l)}}}if(c.debug){benchmark("Building cache for "+d+" rows",m)}}function getWidgetById(a){var b,c,d=widgets.length;for(b=0;b<d;b++){c=widgets[b];if(c&&c.hasOwnProperty("id")&&c.id.toLowerCase()===a.toLowerCase()){return c}}}function applyWidget(a,b){var c=a.config.widgets,d,e,f=c.length;for(d=0;d<f;d++){e=getWidgetById(c[d]);if(e){if(b&&e.hasOwnProperty("init")){e.init(a,widgets,e)}else if(!b&&e.hasOwnProperty("format")){e.format(a)}}}}function appendToTable(a){var b=a.config,c=a.tBodies,d=[],e,f,g,h,i=b.cache,j,k,l,m,n,o,p;if(b.debug){p=new Date}for(m=0;m<c.length;m++){if(!$(c[m]).hasClass(b.cssInfoBlock)){j=document.createDocumentFragment();e=i[m].row;f=i[m].normalized;g=f.length;h=g?f[0].length-1:0;for(k=0;k<g;k++){o=f[k][h];d.push(e[o]);if(!b.appender||!b.removeRows){n=e[o].length;for(l=0;l<n;l++){j.appendChild(e[o][l])}}}a.tBodies[m].appendChild(j)}}if(b.appender){b.appender(a,d)}if(b.debug){benchmark("Rebuilt table",p)}applyWidget(a);$(a).trigger("sortEnd",a)}function computeTableHeaderCellIndexes(a){var b=[],c={},d=$(a).find("thead:eq(0) tr"),e,f,g,h,i,j,k,l,m,n,o,p;for(e=0;e<d.length;e++){j=d[e].cells;for(f=0;f<j.length;f++){i=j[f];k=i.parentNode.rowIndex;l=k+"-"+i.cellIndex;m=i.rowSpan||1;n=i.colSpan||1;if(typeof b[k]==="undefined"){b[k]=[]}for(g=0;g<b[k].length+1;g++){if(typeof b[k][g]==="undefined"){o=g;break}}c[l]=o;$(i).attr({"data-column":o});for(g=k;g<k+m;g++){if(typeof b[g]==="undefined"){b[g]=[]}p=b[g];for(h=o;h<o+n;h++){p[h]="x"}}}}return c}function formatSortingOrder(a){return/^d/i.test(a)||a===1}function buildHeaders(a){var b=$.metadata?true:false,c=computeTableHeaderCellIndexes(a),d,e,f,g,h,i,j=a.config,k=$.tablesorter;j.headerList=[];if(j.debug){h=new Date}i=$(j.selectorHeaders,a).wrapInner("<div class='tablesorter-header-inner' />").each(function(a){e=$(this);d=j.headers[a];this.column=c[this.parentNode.rowIndex+"-"+this.cellIndex];this.order=formatSortingOrder(k.getData(e,d,"sortInitialOrder")||j.sortInitialOrder)?[1,0,2]:[0,1,2];this.count=-1;if(k.getData(e,d,"sorter")==="false"){this.sortDisabled=true}this.lockedOrder=false;g=k.getData(e,d,"lockedOrder")||false;if(typeof g!=="undefined"&&g!==false){this.order=this.lockedOrder=formatSortingOrder(g)?[1,1,1]:[0,0,0]}if(!this.sortDisabled){f=e.addClass(j.cssHeader);if(j.onRenderHeader){j.onRenderHeader.apply(f,[a])}}j.headerList[a]=this;e.parent().addClass(j.cssHeader)});if(j.debug){benchmark("Built headers",h);log(i)}return i}function isValueInArray(a,b){var c,d=b.length;for(c=0;c<d;c++){if(b[c][0]===a){return true}}return false}function setHeadersCss(a,b,c){var d,e=[],f,g,h,i=[a.config.cssDesc,a.config.cssAsc];b.removeClass(i.join(" ")).each(function(){if(!this.sortDisabled){e[this.column]=$(this)}});h=c.length;for(f=0;f<h;f++){if(c[f][1]===2){continue}e[c[f][0]].addClass(i[c[f][1]]);d=b.filter('[data-column="'+c[f][0]+'"]');if(h>1&&d.length){for(g=0;g<d.length;g++){if(!d[g].sortDisabled){$(d[g]).addClass(i[c[f][1]])}}}}}function fixColumnWidth(a){if(a.config.widthFixed){var b=$("<colgroup>");$("tr:first td",a.tBodies[0]).each(function(){b.append($("<col>").css("width",$(this).width()))});$(a).prepend(b)}}function updateHeaderSortCount(a,b){var c,d,e,f=a.config,g=b.length;for(c=0;c<g;c++){d=b[c];e=f.headerList[d[0]];e.count=d[1]%(f.sortReset?3:2)}}function getCachedSortType(a,b){return a?a[b].type:""}function multisort(table,sortList){var dynamicExp,col,mx=0,dir=0,tc=table.config,l=sortList.length,bl=table.tBodies.length,sortTime,i,j,k,c,cache,lc,s,e,order,orgOrderCol;if(tc.debug){sortTime=new Date}for(k=0;k<bl;k++){dynamicExp="var sortWrapper = function(a,b) {";cache=tc.cache[k];lc=cache.normalized.length;for(i=0;i<l;i++){c=sortList[i][0];order=sortList[i][1];s=/n/i.test(getCachedSortType(tc.parsers,c))?"Numeric":"Text";s+=order===0?"":"Desc";e="e"+i;if(/Numeric/.test(s)&&tc.strings[c]){for(j=0;j<lc;j++){col=Math.abs(parseFloat(cache.normalized[j][c]));mx=Math.max(mx,isNaN(col)?0:col)}if(typeof tc.string[tc.strings[c]]==="boolean"){dir=(order===0?1:-1)*(tc.string[tc.strings[c]]?-1:1)}else{dir=tc.strings[c]?tc.string[tc.strings[c]]||0:0}}dynamicExp+="var "+e+" = sort"+s+"(table, a["+c+"],b["+c+"],"+c+","+mx+","+dir+"); ";dynamicExp+="if ("+e+") { return "+e+"; } ";dynamicExp+="else { "}orgOrderCol=cache.normalized&&cache.normalized[0]?cache.normalized[0].length-1:0;dynamicExp+="return a["+orgOrderCol+"]-b["+orgOrderCol+"];";for(i=0;i<l;i++){dynamicExp+="}; "}dynamicExp+="return 0; ";dynamicExp+="}; ";eval(dynamicExp);cache.normalized.sort(sortWrapper)}if(tc.debug){benchmark("Sorting on "+sortList.toString()+" and dir "+order+" time",sortTime)}}function sortText(a,b,c,d){if(b===c){return 0}var e=a.config,f=e.string[e.empties[d]||e.emptyTo],g=$.tablesorter.regex,h,i,j,k,l,m,n,o;if(b===""&&f!==0){return typeof f==="boolean"?f?-1:1:-f||-1}if(c===""&&f!==0){return typeof f==="boolean"?f?1:-1:f||1}if(typeof e.textSorter==="function"){return e.textSorter(b,c,a,d)}h=b.replace(g[0],"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0");j=c.replace(g[0],"\0$1\0").replace(/\0$/,"").replace(/^\0/,"").split("\0");i=parseInt(b.match(g[2]))||h.length!==1&&b.match(g[1])&&Date.parse(b);k=parseInt(c.match(g[2]))||i&&c.match(g[1])&&Date.parse(c)||null;if(k){if(i<k){return-1}if(i>k){return 1}}o=Math.max(h.length,j.length);for(n=0;n<o;n++){l=!(h[n]||"").match(g[3])&&parseFloat(h[n])||h[n]||0;m=!(j[n]||"").match(g[3])&&parseFloat(j[n])||j[n]||0;if(isNaN(l)!==isNaN(m)){return isNaN(l)?1:-1}if(typeof l!==typeof m){l+="";m+=""}if(l<m){return-1}if(l>m){return 1}}return 0}function sortTextDesc(a,b,c,d){if(b===c){return 0}var e=a.config,f=e.string[e.empties[d]||e.emptyTo];if(b===""&&f!==0){return typeof f==="boolean"?f?-1:1:f||1}if(c===""&&f!==0){return typeof f==="boolean"?f?1:-1:-f||-1}if(typeof e.textSorter==="function"){return e.textSorter(c,b,a,d)}return sortText(a,c,b)}function getTextValue(a,b,c){if(b){var d,e=a.length,f=b+c;for(d=0;d<e;d++){f+=a.charCodeAt(d)}return c*f}return 0}function sortNumeric(a,b,c,d,e,f){if(b===c){return 0}var g=a.config,h=g.string[g.empties[d]||g.emptyTo];if(b===""&&h!==0){return typeof h==="boolean"?h?-1:1:-h||-1}if(c===""&&h!==0){return typeof h==="boolean"?h?1:-1:h||1}if(isNaN(b)){b=getTextValue(b,e,f)}if(isNaN(c)){c=getTextValue(c,e,f)}return b-c}function sortNumericDesc(a,b,c,d,e,f){if(b===c){return 0}var g=a.config,h=g.string[g.empties[d]||g.emptyTo];if(b===""&&h!==0){return typeof h==="boolean"?h?-1:1:h||1}if(c===""&&h!==0){return typeof h==="boolean"?h?1:-1:-h||-1}if(isNaN(b)){b=getTextValue(b,e,f)}if(isNaN(c)){c=getTextValue(c,e,f)}return c-b}this.version="2.3.3";var parsers=[],widgets=[];this.defaults={widthFixed:false,cancelSelection:true,dateFormat:"mmddyyyy",sortMultiSortKey:"shiftKey",usNumberFormat:true,delayInit:false,headers:{},ignoreCase:true,sortForce:null,sortList:[],sortAppend:null,sortInitialOrder:"asc",sortLocaleCompare:false,sortReset:false,sortRestart:false,emptyTo:"bottom",stringTo:"max",textExtraction:"simple",textSorter:null,widgetOptions:{zebra:["even","odd"]},initialized:null,onRenderHeader:null,tableClass:"tablesorter",cssAsc:"tablesorter-headerSortUp",cssChildRow:"expand-child",cssDesc:"tablesorter-headerSortDown",cssHeader:"tablesorter-header",cssInfoBlock:"tablesorter-infoOnly",selectorHeaders:"> thead th",selectorRemove:"tr.remove-me",debug:false,headerList:[],empties:{},strings:{},parsers:[],widgets:[]};this.benchmark=benchmark;this.hasInitialized=false;this.construct=function(a){return this.each(function(){if(!this.tHead||this.tBodies.length===0){return}var b,c,d,e,f,g,h,i,j,k,l,m,n=$.metadata;this.config={};g=f=$.extend(true,this.config,$.tablesorter.defaults,a);if(g.debug){$.data(this,"startoveralltimer",new Date)}e=$(this).addClass(g.tableClass);$.data(this,"tablesorter",g);buildRegex();g.string={max:1,min:-1,"max+":1,"max-":-1,zero:0,none:0,"null":0,top:true,bottom:false};b=buildHeaders(this);g.parsers=buildParserCache(this,b);if(!g.delayInit){buildCache(this)}fixColumnWidth(this);b.click(function(a){if(g.delayInit&&!g.cache){buildCache(e[0])}if(!this.sortDisabled){e.trigger("sortStart",e[0]);c=$(this);j=!a[g.sortMultiSortKey];this.count=(this.count+1)%(g.sortReset?3:2);if(g.sortRestart){h=this;b.each(function(){if(this!==h&&(j||!$(this).is("."+g.cssDesc+",."+g.cssAsc))){this.count=-1}})}h=this.column;if(j){g.sortList=[];if(g.sortForce!==null){k=g.sortForce;for(i=0;i<k.length;i++){if(k[i][0]!==h){g.sortList.push(k[i])}}}m=this.order[this.count];if(m<2){g.sortList.push([h,m]);if(this.colSpan>1){for(i=1;i<this.colSpan;i++){g.sortList.push([h+i,m])}}}}else{if(isValueInArray(h,g.sortList)){for(i=0;i<g.sortList.length;i++){l=g.sortList[i];m=g.headerList[l[0]];if(l[0]===h){l[1]=m.order[m.count];if(l[1]===2){g.sortList.splice(i,1);m.count=-1}}}}else{m=this.order[this.count];if(m<2){g.sortList.push([h,m]);if(this.colSpan>1){for(i=1;i<this.colSpan;i++){g.sortList.push([h+i,m])}}}}}if(g.sortAppend!==null){k=g.sortAppend;for(i=0;i<k.length;i++){if(k[i][0]!==h){g.sortList.push(k[i])}}}e.trigger("sortBegin",e[0]);setHeadersCss(e[0],b,g.sortList);appendToTable(e[0],multisort(e[0],g.sortList));return false}}).mousedown(function(){if(g.cancelSelection){this.onselectstart=function(){return false};return false}});e.bind("update",function(a,c){$(g.selectorRemove,this).remove();g.parsers=buildParserCache(this,b);buildCache(this);if(c!==false){$(this).trigger("sorton",[g.sortList])}}).bind("updateCell",function(a,b,c){var d=this,e=[b.parentNode.rowIndex-1,b.cellIndex],f=$(this).find("tbody").index($(b).closest("tbody"));d.config.cache[f].normalized[e[0]][e[1]]=g.parsers[e[1]].format(getElementText(d,b,e[1]),d,b,e[1]);if(c!==false){$(this).trigger("sorton",[g.sortList])}}).bind("addRows",function(a,b,c){var d,e=b.filter("tr").length,f=[],h=b[0].cells.length,j=this,k=$(this).find("tbody").index(b.closest("tbody"));for(d=0;d<e;d++){for(i=0;i<h;i++){f[i]=g.parsers[i].format(getElementText(j,b[d].cells[i],i),j,b[d].cells[i],i)}f.push(g.cache[k].row.length);g.cache[k].row.push([b[d]]);g.cache[k].normalized.push(f);f=[]}if(c!==false){$(this).trigger("sorton",[g.sortList])}}).bind("sorton",function(a,c){$(this).trigger("sortStart",this);g.sortList=c;updateHeaderSortCount(this,g.sortList);setHeadersCss(this,b,g.sortList);appendToTable(this,multisort(this,g.sortList))}).bind("appendCache",function(){appendToTable(this)}).bind("applyWidgetId",function(a,b){getWidgetById(b).format(this)}).bind("applyWidgets",function(){applyWidget(this)}).bind("destroy",function(a,b){$.tablesorter.destroy(this,b)});if(e.data()&&typeof e.data().sortlist!=="undefined"){g.sortList=e.data().sortlist}else if(n&&e.metadata()&&e.metadata().sortlist){g.sortList=e.metadata().sortlist}applyWidget(this,true);if(g.sortList.length>0){e.trigger("sorton",[g.sortList])}else{applyWidget(this)}this.hasInitialized=true;if(g.debug){$.tablesorter.benchmark("Overall initialization time",$.data(this,"startoveralltimer"))}e.trigger("tablesorter-initialized",this);if(typeof g.initialized==="function"){g.initialized(this)}})};this.destroy=function(a,b){var c=$(a),d=a.config;c.find("thead:first tr:not(."+d.cssHeader+")").remove();c.find("thead:first .tablesorter-resizer").remove();c.unbind("update updateCell addRows sorton appendCache applyWidgetId applyWidgets destroy mouseup mouseleave").find(d.selectorHeaders).unbind("click mousedown mousemove mouseup").removeClass(d.cssHeader+" "+d.cssAsc+" "+d.cssDesc);if(b!==false){c.removeClass(d.tableClass)}};this.addParser=function(a){var b,c=parsers.length,d=true;for(b=0;b<c;b++){if(parsers[b].id.toLowerCase()===a.id.toLowerCase()){d=false}}if(d){parsers.push(a)}};this.addWidget=function(a){widgets.push(a)};this.formatFloat=function(a,b){if(typeof a!=="string"||a===""){return a}if(b.config.usNumberFormat!==false){a=a.replace(/,/g,"")}else{a=a.replace(/[\s|\.]/g,"").replace(/,/g,".")}if(/^\s*\([.\d]+\)/.test(a)){a=a.replace(/^\s*\(/,"-").replace(/\)/,"")}var c=parseFloat(a);return isNaN(c)?$.trim(a):c};this.isDigit=function(a){return/^[\-+(]?\d*[)]?$/.test(a.replace(/[,.'\s]/g,""))};this.regex=[/(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,/(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,/^0x[0-9a-f]+$/i,/^0/];this.characterEquivalents={a:"<22><><EFBFBD><EFBFBD><EFBFBD>",A:"<22><><EFBFBD><EFBFBD><EFBFBD>",c:"<22>",C:"<22>",e:"<22><><EFBFBD><EFBFBD>",E:"<22><><EFBFBD><EFBFBD>",i:"<22><>I<EFBFBD><49>",I:"<22><>I<EFBFBD><49>",o:"<22><><EFBFBD><EFBFBD><EFBFBD>",O:"<22><><EFBFBD><EFBFBD><EFBFBD>",S:"<22>",u:"<22><><EFBFBD><EFBFBD>",U:"<22><><EFBFBD><EFBFBD>"};this.replaceAccents=function(a){if(this.characterRegex.test(a)){var b,c=this.characterEquivalents;for(b in c){if(typeof b==="string"){a=a.replace(this.characterRegexArray[b],b)}}}return a};this.getData=function(a,b,c){var d="",e=$(a),f=$.metadata?e.metadata():false,g=" "+(e.length?e.attr("class")||"":"");if(e.length&&e.data()&&(typeof e.data(c)!=="undefined"||typeof e.data(c.toLowerCase())!=="undefined")){d+=e.data(c)||e.data(c.toLowerCase())}else if(f&&typeof f[c]!=="undefined"){d+=f[c]}else if(b&&typeof b[c]!=="undefined"){d+=b[c]}else if(g&&g.match(" "+c+"-")){d=g.match(new RegExp(" "+c+"-(\\w+)"))[1]||""}return $.trim(d)};this.clearTableBody=function(a){$(a.tBodies).filter(":not(."+a.config.cssInfoBlock+")").empty()}}})();var ts=$.tablesorter;$.fn.extend({tablesorter:ts.construct});ts.addParser({id:"text",is:function(a,b,c){return true},format:function(a,b,c,d){var e=b.config;a=$.trim(e.ignoreCase?a.toLocaleLowerCase():a);return e.sortLocaleCompare?ts.replaceAccents(a):a},type:"text"});ts.addParser({id:"currency",is:function(a){return/^\(?[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+/.test(a)},format:function(a,b){return ts.formatFloat(a.replace(/[^\w,. \-()]/g,""),b)},type:"numeric"});ts.addParser({id:"ipAddress",is:function(a){return/^\d{2,3}[\.]\d{2,3}[\.]\d{2,3}[\.]\d{2,3}$/.test(a)},format:function(a,b){var c,d,e=a.split("."),f="",g=e.length;for(c=0;c<g;c++){d=e[c];if(d.length===2){f+="0"+d}else{f+=d}}return ts.formatFloat(f,b)},type:"numeric"});ts.addParser({id:"url",is:function(a){return/^(https?|ftp|file):\/\/$/.test(a)},format:function(a){return $.trim(a.replace(/(https?|ftp|file):\/\//,""))},type:"text"});ts.addParser({id:"isoDate",is:function(a){return/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}$/.test(a)},format:function(a,b){return ts.formatFloat(a!==""?(new Date(a.replace(/-/g,"/"))).getTime()||"":"",b)},type:"numeric"});ts.addParser({id:"percent",is:function(a){return/\d%\)?$/.test(a)},format:function(a,b){return ts.formatFloat(a.replace(/%/g,""),b)},type:"numeric"});ts.addParser({id:"usLongDate",is:function(a){return a.match(/^[A-Za-z]{3,10}\.? [0-9]{1,2}, ([0-9]{4}|'?[0-9]{2}) (([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(AM|PM)))$/)},format:function(a,b){return ts.formatFloat((new Date(a)).getTime()||"",b)},type:"numeric"});ts.addParser({id:"shortDate",is:function(a){return/\d{1,4}[\/\-\,\.\s+]\d{1,4}[\/\-\.\,\s+]\d{1,4}/.test(a)},format:function(a,b,c,d){var e=b.config,f=e.headerList[d],g=f.shortDateFormat;if(typeof g==="undefined"){g=f.shortDateFormat=ts.getData(f,e.headers[d],"dateFormat")||e.dateFormat}a=a.replace(/\s+/g," ").replace(/[\-|\.|\,]/g,"/");if(g==="mmddyyyy"){a=a.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,"$3/$1/$2")}else if(g==="ddmmyyyy"){a=a.replace(/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,"$3/$2/$1")}else if(g==="yyyymmdd"){a=a.replace(/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,"$1/$2/$3")}return ts.formatFloat((new Date(a)).getTime()||"",b)},type:"numeric"});ts.addParser({id:"time",is:function(a){return/^(([0-2]?[0-9]:[0-5][0-9])|([0-1]?[0-9]:[0-5][0-9]\s(am|pm)))$/.test(a)},format:function(a,b){return ts.formatFloat((new Date("2000/01/01 "+a)).getTime()||"",b)},type:"numeric"});ts.addParser({id:"digit",is:function(a){return ts.isDigit(a)},format:function(a,b){return ts.formatFloat(a.replace(/[^\w,. \-()]/g,""),b)},type:"numeric"});ts.addParser({id:"metadata",is:function(a){return false},format:function(a,b,c){var d=b.config,e=!d.parserMetadataName?"sortValue":d.parserMetadataName;return $(c).metadata()[e]},type:"numeric"});ts.addWidget({id:"zebra",format:function(a){var b,c,d,e,f,g,h,i,j,k,l=a.config,m=new RegExp(l.cssChildRow,"i"),n=$(a).children("tbody:not(."+l.cssInfoBlock+")"),o=["even","odd"];o=l.widgetZebra&&l.hasOwnProperty("css")?l.widgetZebra.css:l.widgetOptions&&l.widgetOptions.hasOwnProperty("zebra")?l.widgetOptions.zebra:o;if(l.debug){g=new Date}for(h=0;h<n.length;h++){e=0;b=$(n[h]);j=b.children("tr").length;if(j>1){d=$(document.createDocumentFragment());c=b.children("tr").appendTo(d);for(i=0;i<j;i++){if(c[i].style.display!=="none"){k=c[i].className;if(!m.test(k)){e++}f=e%2===0;c[i].className=k.replace(/\s+/g,"").replace(o[0],"").replace(o[1],"")+" "+o[f?0:1]}}}b.append(c)}if(l.debug){ts.benchmark("Applying Zebra widget",g)}}})}(jQuery);