tablesorter/js/jquery.tablesorter.min.js

6 lines
29 KiB
JavaScript
Raw Normal View History

2012-03-18 14:02:49 +00:00
/*!
2014-05-22 12:51:24 +00:00
* TableSorter 2.17.0 min - Client-side table sorting with ease!
2011-06-22 23:19:27 +00:00
* Copyright (c) 2007 Christian Bach
*/
2014-05-22 12:51:24 +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 v(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,e=b.config,s=e.textExtraction||"",k="",k="basic"===s?g(a).attr(e.textAttribute)|| a.textContent||a.innerText||g(a).text()||"":"function"===typeof s?s(a,b,c):"function"===typeof(h=f.getColumnData(b,s,c))?h(a,b,c):a.textContent||a.innerText||g(a).text()||"";return g.trim(k)}function u(b){var a=b.config,c=a.$tbodies=a.$table.children("tbody:not(."+a.cssInfoBlock+")"),h,e,s,k,l,g,r,n,x=0,q="",t=c.length;if(0===t)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=[];x<t;){h=c[x].rows;if(h[x])for(s= a.columns,k=0;k<s;k++){l=a.$headers.filter('[data-column="'+k+'"]:last');g=f.getColumnData(b,a.headers,k);r=f.getParserById(f.getData(l,g,"sorter"));a.empties[k]=f.getData(l,g,"empty")||a.emptyTo||(a.emptyToBottom?"bottom":"top");a.strings[k]=f.getData(l,g,"string")||a.stringTo||"max";if(!r)a:{l=b;g=h;r=-1;for(var u=k,A=void 0,y=f.parsers.length,z=!1,F="",A=!0;""===F&&A;)r++,g[r]?(z=g[r].cells[u],F=p(l,z,u),l.config.debug&&d("Checking if value was empty on row "+r+", column: "+u+': "'+F+'"')):A=!1; for(;0<=--y;)if((A=f.parsers[y])&&"text"!==A.id&&A.is&&A.is(F,l,z)){r=A;break a}r=f.getParserById("text")}a.debug&&(q+="column:"+k+"; parser:"+r.id+"; string:"+a.strings[k]+"; empty: "+a.empties[k]+"\n");e.push(r)}x+=e.length?t:1}a.debug&&(d(q?q:"No parsers detected"),v("Completed detecting parsers",n));a.parsers=e}function y(b){var a,c,h,e,s,k,l,m,r,n,x,q=b.config,t=q.$table.children("tbody"),u=q.parsers;q.cache={};if(!u)return q.debug?d("Warning: *Empty table!* Not building a cache"):"";q.debug&& (m=new Date);q.showProcessing&&f.isProcessing(b,!0);for(s=0;s<t.length;s++)if(x=[],a=q.cache[s]={normalized:[]},!t.eq(s).hasClass(q.cssInfoBlock)){r=t[s]&&t[s].rows.length||0;for(h=0;h<r;++h)if(n={child:[]},k=g(t[s].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 u[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=u[e].format(c,b,k[0].cells[e],e),l.push(c),"numeric"===(u[e].type||"").toLowerCase()&&(x[e]=Math.max(Math.abs(c)||0,x[e]||0)));l[q.columns]=n;a.normalized.push(l)}a.colMax=x}q.showProcessing&&f.isProcessing(b);q.debug&&v("Building cache for "+r+" rows",m)}function z(b,a){var c=b.config,h=c.widgetOptions,e=b.tBodies,s=[],k=c.cache,d, m,r,p,x,q;if(n(k))return c.appender?c.appender(b,s):b.isUpdating?c.$table.trigger("updateComplete",b):"";c.debug&&(q=new Date);for(x=0;x<e.length;x++)if(d=g(e[x]),d.length&&!d.hasClass(c.cssInfoBlock)){r=f.processTbody(b,d,!0);d=k[x].normalized;m=d.length;for(p=0;p<m;p++)s.push(d[p][c.columns].$row),c.appender&&(!c.pager||c.pager.removeRows&&h.pager_removeRows||c.pager.ajax)||r.append(d[p][c.columns].$row);f.processTbody(b,r,!1)}c.appender&&c.appender(b,s);c.debug&&v("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,s,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.each(function(d){c=g(this);a=f.getColumnData(b,m.headers,d,!0);m.headerContent[d]=g(this).html();s=m.headerTemplate.replace(/\{content\}/g,