tablesorter/js/jquery.tablesorter.min.js

6 lines
23 KiB
JavaScript
Raw Normal View History

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