tablesorter/js/jquery.tablesorter.min.js

6 lines
23 KiB
JavaScript
Raw Normal View History

2012-03-18 14:02:49 +00:00
/*!
2013-03-27 23:21:09 +00:00
* TableSorter 2.8.0 min - Client-side table sorting with ease!
2011-06-22 23:19:27 +00:00
* Copyright (c) 2007 Christian Bach
*/
2013-03-27 23:21:09 +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 w(c,b){d(c+" ("+((new Date).getTime()-b.getTime())+"ms)")}function r(c,b,a){if(!b)return"";var e=c.config,d=e.textExtraction,j="",j="simple"===d?e.supportsTextContent?b.textContent:g(b).text():"function"===typeof d?d(b,c,a):"object"===typeof d&&d.hasOwnProperty(a)?d[a](b,c,a):e.supportsTextContent?b.textContent:g(b).text();return g.trim(j)} function l(c){var b=c.config,a=b.$tbodies=b.$table.children("tbody:not(."+b.cssInfoBlock+")"),e,t,j,h,k,p,m="";if(0===a.length)return b.debug?d("*Empty table!* Not building a parser cache"):"";a=a[0].rows;if(a[0]){e=[];t=a[0].cells.length;for(j=0;j<t;j++){h=b.$headers.filter(":not([colspan])");h=h.add(b.$headers.filter('[colspan="1"]')).filter('[data-column="'+j+'"]:last');k=b.headers[j];p=f.getParserById(f.getData(h,k,"sorter"));b.empties[j]=f.getData(h,k,"empty")||b.emptyTo||(b.emptyToBottom?"bottom": "top");b.strings[j]=f.getData(h,k,"string")||b.stringTo||"max";if(!p)a:{h=c;k=a;p=-1;for(var g=j,n=void 0,w=f.parsers.length,F=!1,C="",n=!0;""===C&&n;)p++,k[p]?(F=k[p].cells[g],C=r(h,F,g),h.config.debug&&d("Checking if value was empty on row "+p+", column: "+g+': "'+C+'"')):n=!1;for(;0<=--w;)if((n=f.parsers[w])&&"text"!==n.id&&n.is&&n.is(C,h,F)){p=n;break a}p=f.getParserById("text")}b.debug&&(m+="column:"+j+"; parser:"+p.id+"; string:"+b.strings[j]+"; empty: "+b.empties[j]+"\n");e.push(p)}}b.debug&& d(m);b.parsers=e}function s(c){var b=c.tBodies,a=c.config,e,t,j=a.parsers,h,k,p,m,q,n,G,l=[];a.cache={};if(!j)return a.debug?d("*Empty table!* Not building a cache"):"";a.debug&&(G=new Date);a.showProcessing&&f.isProcessing(c,!0);for(m=0;m<b.length;m++)if(a.cache[m]={row:[],normalized:[]},!g(b[m]).hasClass(a.cssInfoBlock)){e=b[m]&&b[m].rows.length||0;t=b[m].rows[0]&&b[m].rows[0].cells.length||0;for(k=0;k<e;++k)if(q=g(b[m].rows[k]),n=[],q.hasClass(a.cssChildRow))a.cache[m].row[a.cache[m].row.length- 1]=a.cache[m].row[a.cache[m].row.length-1].add(q);else{a.cache[m].row.push(q);for(p=0;p<t;++p)if(h=r(c,q[0].cells[p],p),h=j[p].format(h,c,q[0].cells[p],p),n.push(h),"numeric"===(j[p].type||"").toLowerCase())l[p]=Math.max(Math.abs(h),l[p]||0);n.push(a.cache[m].normalized.length);a.cache[m].normalized.push(n)}a.cache[m].colMax=l}a.showProcessing&&f.isProcessing(c);a.debug&&w("Building cache for "+e+" rows",G)}function v(c,b){var a=c.config,e=c.tBodies,d=[],j=a.cache,h,k,p,m,q,n,l,r,C,s,v;if(j[0]){a.debug&& (v=new Date);for(r=0;r<e.length;r++)if(h=g(e[r]),h.length&&!h.hasClass(a.cssInfoBlock)){q=f.processTbody(c,h,!0);h=j[r].row;k=j[r].normalized;m=(p=k.length)?k[0].length-1:0;for(n=0;n<p;n++)if(s=k[n][m],d.push(h[s]),!a.appender||!a.removeRows){C=h[s].length;for(l=0;l<C;l++)q.append(h[s][l])}f.processTbody(c,q,!1)}a.appender&&a.appender(c,d);a.debug&&w("Rebuilt table",v);b||f.applyWidget(c);g(c).trigger("sortEnd",c)}}function z(c){var b=[],a={},e=0,t=g(c).find("thead:eq(0), tfoot").children("tr"),j, h,k,p,m,q,n,l,r,s;for(j=0;j<t.length;j++){m=t[j].cells;for(h=0;h<m.length;h++){p=m[h];q=p.parentNode.rowIndex;n=q+"-"+p.cellIndex;l=p.rowSpan||1;r=p.colSpan||1;"undefined"===typeof b[q]&&(b[q]=[]);for(k=0;k<b[q].length+1;k++)if("undefined"===typeof b[q][k]){s=k;break}a[n]=s;e=Math.max(s,e);g(p).attr({"data-column":s});for(k=q;k<q+l;k++){"undefined"===typeof b[k]&&(b[k]=[]);n=b[k];for(p=s;p<s+r;p++)n[p]="x"}}}c.config.columns=e;var v,u,z,B,A,y,D,x=c.config;x.headerList=[];x.headerContent=[];x.debug&& (D=new Date);B=x.cssIcon?'<i class="'+x.cssIcon+'"></i>':"";x.$headers=g(c).find(x.selectorHeaders).each(function(c){u=g(this);v=x.headers[c];x.headerContent[c]=this.innerHTML;A=x.headerTemplate.replace(/\{content\}/g,this.innerHTML).replace(/\{icon\}/g,B);x.onRenderTemplate&&(z=x.onRenderTemplate.apply(u,[c,A]))&&"string"===typeof z&&(A=z);this.innerHTML='<div class="tablesorter-header-inner">'+A+"</div>";x.onRenderHeader&&x.onRenderHeader.apply(u,[c]);this.column=a[this.parentNode.rowIndex+"-"+ this.cellIndex];var b=f.getData(u,v,"sortInitialOrder"