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