tablesorter/js/jquery.tablesorter.min.js

6 lines
28 KiB
JavaScript
Raw Normal View History

2012-03-18 14:02:49 +00:00
/*!
2014-05-01 02:50:31 +00:00
* TableSorter 2.16.3 min - Client-side table sorting with ease!
2011-06-22 23:19:27 +00:00
* Copyright (c) 2007 Christian Bach
*/
2014-05-01 02:50:31 +00:00
!function(g){g.extend({tablesorter:new function(){function d(){var b=arguments[0],a=1<arguments.length?Array.prototype.slice.call(arguments):b;if("undefined"!==typeof console&&"undefined"!==typeof console.log)console[/error/i.test(b)?"error":/warn/i.test(b)?"warn":"log"](a);else alert(a)}function u(b,a){d(b+" ("+((new Date).getTime()-a.getTime())+"ms)")}function n(b){for(var a in b)return!1;return!0}function p(b,a,c){if(!a)return"";var h=b.config,e=h.textExtraction||"",f="",f="basic"===e?g(a).attr(h.textAttribute)|| a.textContent||a.innerText||g(a).text()||"":"function"===typeof e?e(a,b,c):"object"===typeof e&&e.hasOwnProperty(c)?e[c](a,b,c):a.textContent||a.innerText||g(a).text()||"";return g.trim(f)}function s(b){var a=b.config,c=a.$tbodies=a.$table.children("tbody:not(."+a.cssInfoBlock+")"),h,e,t,k,l,m,g,n,w=0,q="",r=c.length;if(0===r)return a.debug?d("Warning: *Empty table!* Not building a parser cache"):"";a.debug&&(n=new Date,d("Detecting parsers for each column"));for(e=[];w<r;){h=c[w].rows;if(h[w])for(t= h[w].cells.length,k=0;k<t;k++){l=a.$headers.filter(":not([colspan])");l=l.add(a.$headers.filter('[colspan="1"]')).filter('[data-column="'+k+'"]:last');m=a.$headers.index(l);m=a.headers[m];g=f.getParserById(f.getData(l,m,"sorter"));a.empties[k]=f.getData(l,m,"empty")||a.emptyTo||(a.emptyToBottom?"bottom":"top");a.strings[k]=f.getData(l,m,"string")||a.stringTo||"max";if(!g)a:{l=b;m=h;g=-1;for(var s=k,A=void 0,x=f.parsers.length,y=!1,F="",A=!0;""===F&&A;)g++,m[g]?(y=m[g].cells[s],F=p(l,y,s),l.config.debug&& d("Checking if value was empty on row "+g+", column: "+s+': "'+F+'"')):A=!1;for(;0<=--x;)if((A=f.parsers[x])&&"text"!==A.id&&A.is&&A.is(F,l,y)){g=A;break a}g=f.getParserById("text")}a.debug&&(q+="column:"+k+"; parser:"+g.id+"; string:"+a.strings[k]+"; empty: "+a.empties[k]+"\n");e.push(g)}w+=e.length?r:1}a.debug&&(d(q?q:"No parsers detected"),u("Completed detecting parsers",n));a.parsers=e}function x(b){var a,c,h,e,t,k,l,m,z,n,w,q=b.config,r=q.$table.children("tbody"),s=q.parsers;q.cache={};if(!s)return q.debug? d("Warning: *Empty table!* Not building a cache"):"";q.debug&&(m=new Date);q.showProcessing&&f.isProcessing(b,!0);for(t=0;t<r.length;t++)if(w=[],a=q.cache[t]={normalized:[]},!r.eq(t).hasClass(q.cssInfoBlock)){z=r[t]&&r[t].rows.length||0;for(h=0;h<z;++h)if(n={child:[]},k=g(r[t].rows[h]),l=[],k.hasClass(q.cssChildRow)&&0!==h)c=a.normalized.length-1,a.normalized[c][q.columns].$row=a.normalized[c][q.columns].$row.add(k),k.prev().hasClass(q.cssChildRow)||k.prev().addClass(f.css.cssHasChild),n.child[c]= g.trim(k[0].textContent||k[0].innerText||k.text()||"");else{n.$row=k;n.order=h;for(e=0;e<q.columns;++e)"undefined"===typeof s[e]?q.debug&&d("No parser found for cell:",k[0].cells[e],"does it have a header?"):(c=p(b,k[0].cells[e],e),c=s[e].format(c,b,k[0].cells[e],e),l.push(c),"numeric"===(s[e].type||"").toLowerCase()&&(w[e]=Math.max(Math.abs(c)||0,w[e]||0)));l[q.columns]=n;a.normalized.push(l)}a.colMax=w}q.showProcessing&&f.isProcessing(b);q.debug&&u("Building cache for "+z+" rows",m)}function y(b, a){var c=b.config,h=c.widgetOptions,e=b.tBodies,t=[],k=c.cache,d,m,z,p,w,q;if(n(k))return c.appender?c.appender(b,t):b.isUpdating?c.$table.trigger("updateComplete",b):"";c.debug&&(q=new Date);for(w=0;w<e.length;w++)if(d=g(e[w]),d.length&&!d.hasClass(c.cssInfoBlock)){z=f.processTbody(b,d,!0);d=k[w].normalized;m=d.length;for(p=0;p<m;p++)t.push(d[p][c.columns].$row),c.appender&&(!c.pager||c.pager.removeRows&&h.pager_removeRows||c.pager.ajax)||z.append(d[p][c.columns].$row);f.processTbody(b,z,!1)}c.appender&& c.appender(b,t);c.debug&&u("Rebuilt table",q);a||c.appender||f.applyWidget(b);b.isUpdating&&c.$table.trigger("updateComplete",b)}function C(b){return/^d/i.test(b)||1===b}function D(b){var a,c,h,e,t,k,l,m=b.config;m.headerList=[];m.headerContent=[];m.debug&&(l=new Date);m.columns=f.computeColumnIndex(m.$table.children("thead, tfoot").children("tr"));e=m.cssIcon?'<i class="'+(m.cssIcon===f.css.icon?f.css.icon:m.cssIcon+" "+f.css.icon)+'"></i>':"";m.$headers=g(b).find(m.selectorHeaders).each(function(b){c= g(this);a=m.