tablesorter/js/jquery.tablesorter.min.js

6 lines
21 KiB
JavaScript
Raw Normal View History

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