tablesorter/js/jquery.tablesorter.min.js

5 lines
24 KiB
JavaScript
Raw Normal View History

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