tablesorter/js/jquery.tablesorter.min.js

6 lines
28 KiB
JavaScript
Raw Normal View History

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