tablesorter/js/jquery.tablesorter.min.js

6 lines
24 KiB
JavaScript
Raw Normal View History

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