tablesorter/js/jquery.tablesorter.min.js

6 lines
24 KiB
JavaScript
Raw Normal View History

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