tablesorter/js/jquery.tablesorter.min.js

6 lines
21 KiB
JavaScript
Raw Normal View History

2012-03-18 14:02:49 +00:00
/*!
2012-11-27 23:39:53 +00:00
* TableSorter 2.5.2 min - Client-side table sorting with ease!
2011-06-22 23:19:27 +00:00
* Copyright (c) 2007 Christian Bach
*/
2012-11-27 23:39:53 +00:00
!function(f){f.extend({tablesorter:new function(){function d(c){"undefined"!==typeof console&&"undefined"!==typeof console.log?console.log(c):alert(c)}function u(c,b){d(c+" ("+((new Date).getTime()-b.getTime())+"ms)")}function n(c,b,a){if(!b)return"";var g=c.config,h=g.textExtraction,e="",e="simple"===h?g.supportsTextContent?b.textContent:f(b).text():"function"===typeof h?h(b,c,a):"object"===typeof h&&h.hasOwnProperty(a)?h[a](b,c,a):g.supportsTextContent?b.textContent:f(b).text();return f.trim(e)} function i(c){var b=c.config,a=f(c.tBodies).filter(":not(."+b.cssInfoBlock+")"),g,h,s,j,l,k,m="";if(0!==a.length){a=a[0].rows;if(a[0]){g=[];h=a[0].cells.length;for(s=0;s<h;s++){j=b.$headers.filter(":not([colspan])");j=j.add(b.$headers.filter('[colspan="1"]')).filter('[data-column="'+s+'"]:last');l=b.headers[s];k=e.getParserById(e.getData(j,l,"sorter"));b.empties[s]=e.getData(j,l,"empty")||b.emptyTo||(b.emptyToBottom?"bottom":"top");b.strings[s]=e.getData(j,l,"string")||b.stringTo||"max";if(!k)a:{j= c;l=a;k=-1;for(var u=s,q=void 0,r=e.parsers.length,x=!1,p="",q=!0;""===p&&q;)k++,l[k]?(x=l[k].cells[u],p=n(j,x,u),j.config.debug&&d("Checking if value was empty on row "+k+", column: "+u+": "+p)):q=!1;for(q=1;q<r;q++)if(e.parsers[q].is(p,j,x)){k=e.parsers[q];break a}k=e.parsers[0]}b.debug&&(m+="column:"+s+"; parser:"+k.id+"; string:"+b.strings[s]+"; empty: "+b.empties[s]+"\n");g.push(k)}}b.debug&&d(m);return g}}function p(c){var b=c.tBodies,a=c.config,g,h,d=a.parsers,j,l,k,m,i,q,p,x=[];a.cache={}; a.debug&&(p=new Date);a.showProcessing&&e.isProcessing(c,!0);for(m=0;m<b.length;m++)if(a.cache[m]={row:[],normalized:[]},!f(b[m]).hasClass(a.cssInfoBlock)){g=b[m]&&b[m].rows.length||0;h=b[m].rows[0]&&b[m].rows[0].cells.length||0;for(l=0;l<g;++l)if(i=f(b[m].rows[l]),q=[],i.hasClass(a.cssChildRow))a.cache[m].row[a.cache[m].row.length-1]=a.cache[m].row[a.cache[m].row.length-1].add(i);else{a.cache[m].row.push(i);for(k=0;k<h;++k)if(j=n(c,i[0].cells[k],k),j=d[k].format(j,c,i[0].cells[k],k),q.push(j),"numeric"=== (d[k].type||"").toLowerCase())x[k]=Math.max(Math.abs(j),x[k]||0);q.push(a.cache[m].normalized.length);a.cache[m].normalized.push(q)}a.cache[m].colMax=x}a.showProcessing&&e.isProcessing(c);a.debug&&u("Building cache for "+g+" rows",p)}function r(c,b){var a=c.config,g=c.tBodies,h=[],d=a.cache,j,l,k,m,i,q,n,p,r,t,v;a.debug&&(v=new Date);for(p=0;p<g.length;p++)if(j=f(g[p]),!j.hasClass(a.cssInfoBlock)){i=e.processTbody(c,j,!0);j=d[p].row;l=d[p].normalized;m=(k=l.length)?l[0].length-1:0;for(q=0;q<k;q++)if(t= l[q][m],h.push(j[t]),!a.appender||!a.removeRows){r=j[t].length;for(n=0;n<r;n++)i.append(j[t][n])}e.processTbody(c,i,!1)}a.appender&&a.appender(c,h);a.debug&&u("Rebuilt table",v);b||e.applyWidget(c);f(c).trigger("sortEnd",c)}function B(c){var b,a,g,h=c.config,e=h.sortList,d=[h.cssAsc,h.cssDesc],l=f(c).find("tfoot tr").children().removeClass(d.join(" "));h.$headers.removeClass(d.join(" "));g=e.length;for(b=0;b<g;b++)if(2!==e[b][1]&&(c=h.$headers.not(".sorter-false").filter('[data-column="'+e[b][0]+ '"]'+(1===g?":last":"")),c.length))for(a=0;a<c.length;a++)c[a].sortDisabled||(c.eq(a).addClass(d[e[b][1]]),l.length&&l.filter('[data-column="'+e[b][0]+'"]').eq(a).addClass(d[e[b][1]]))}function D(c){var b=0,a=c.config,g=a.sortList,h=g.length,e=c.tBodies.length,d,l,k,m,i,q,n,p,r;a.debug&&(d=new Date);for(k=0;k<e;k++)i=a.cache[k].colMax,r=(q=a.cache[k].normalized)&&q[0]?q[0].length-1:0,q.sort(function(e,d){for(l=0;l<h;l++){m=g[l][0];p=g[l][1];n=/n/i.test(a.parsers&&a.parsers[m]?a.parsers[m].type||"": "")?"Numeric":"Text";n+=0===p?"":"Desc";/Numeric/.test(n)&&a.strings[m]&&(b="boolean"===typeof a.string[a.strings[m]]?(0===p?1:-1)*(a.string[a.strings[m]]?-1:1):a.strings[m]?a.string[a.strings[m]]||0:0);var j=f.tablesorter["sort"+n](c,e[m],d[m],m,i[m],b);if(j)return j}return e[r]-d[r]});a.debug&&u("Sorting on "+g.toString()+" and dir "+p+" time",d)}function C(c,b){c.trigger("updateComplete");"function"===typeof b&&b(c[0])}function E(c,b,a){!1!==b?c.trigger("sorton",[c[0].config.sortList,function(){C(c, a)}]):C(c,a)}var e=this;e.version="2.5.2";e.parsers