tablesorter/dist/js/jquery.tablesorter.min.js

3 lines
32 KiB
JavaScript
Raw Normal View History

/*! TableSorter (FORK) v2.19.1 */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&"object"==typeof module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){"use strict";a.extend({tablesorter:new function(){function b(){var a=arguments[0],b=arguments.length>1?Array.prototype.slice.call(arguments):a;"undefined"!=typeof console&&"undefined"!=typeof console.log?console[/error/i.test(a)?"error":/warn/i.test(a)?"warn":"log"](b):alert(b)}function c(a,c){b(a+" ("+((new Date).getTime()-c.getTime())+"ms)")}function d(a){for(var b in a)return!1;return!0}function e(b,c,d){if(!c)return"";var e,f=a(c),g=b.config,h=g.textExtraction||"";return a.trim("string"==typeof h?("basic"===h?f.attr(g.textAttribute)||c.textContent:c.textContent)||f.text()||"":"function"==typeof h?h(c,b,d):"function"==typeof(e=v.getColumnData(b,h,d))?e(c,b,d):c.textContent||f.text()||"")}function f(c,d,f,g){for(var h,i,j=v.parsers.length,k=!1,l="",m=!0;""===l&&m;)f++,d[f]?(k=d[f].cells[g],l=e(c,k,g),i=a(k),c.config.debug&&b("Checking if value was empty on row "+f+", column: "+g+': "'+l+'"')):m=!1;for(;--j>=0;)if(h=v.parsers[j],h&&"text"!==h.id&&h.is&&h.is(l,c,k,i))return h;return v.getParserById("text")}function g(a){var d,e,g,h,i,j,k,l,m,n,o=a.config,p=o.$tbodies=o.$table.children("tbody:not(."+o.cssInfoBlock+")"),q=0,r="",s=p.length;if(0===s)return o.debug?b("Warning: *Empty table!* Not building a parser cache"):"";for(o.debug&&(n=new Date,b("Detecting parsers for each column")),e={extractors:[],parsers:[]};s>q;){if(d=p[q].rows,d.length)for(g=o.columns,h=0;g>h;h++)i=o.$headers.filter('[data-column="'+h+'"]:last'),j=v.getColumnData(a,o.headers,h),m=v.getParserById(v.getData(i,j,"extractor")),l=v.getParserById(v.getData(i,j,"sorter")),k="false"===v.getData(i,j,"parser"),o.empties[h]=(v.getData(i,j,"empty")||o.emptyTo||(o.emptyToBottom?"bottom":"top")).toLowerCase(),o.strings[h]=(v.getData(i,j,"string")||o.stringTo||"max").toLowerCase(),k&&(l=v.getParserById("no-parser")),m||(m=!1),l||(l=f(a,d,-1,h)),o.debug&&(r+="column:"+h+"; extractor:"+m.id+"; parser:"+l.id+"; string:"+o.strings[h]+"; empty: "+o.empties[h]+"\n"),e.parsers[h]=l,e.extractors[h]=m;q+=e.parsers.length?s:1}o.debug&&(b(r?r:"No parsers detected"),c("Completed detecting parsers",n)),o.parsers=e.parsers,o.extractors=e.extractors}function h(d){var f,g,h,i,j,k,l,m,n,o,p,q,r,s,t=d.config,u=t.$table.children("tbody"),w=t.extractors,x=t.parsers;if(t.cache={},t.totalRows=0,!x)return t.debug?b("Warning: *Empty table!* Not building a cache"):"";for(t.debug&&(p=new Date),t.showProcessing&&v.isProcessing(d,!0),l=0;l<u.length;l++)if(s=[],f=t.cache[l]={normalized:[]},!u.eq(l).hasClass(t.cssInfoBlock)){for(q=u[l]&&u[l].rows.length||0,j=0;q>j;++j)if(r={child:[],raw:[]},m=a(u[l].rows[j]),n=[new Array(t.columns)],o=[],m.hasClass(t.cssChildRow)&&0!==j)g=f.normalized.length-1,f.normalized[g][t.columns].$row=f.normalized[g][t.columns].$row.add(m),m.prev().hasClass(t.cssChildRow)||m.prev().addClass(v.css.cssHasChild),r.child[g]=a.trim(m[0].textContent||m.text()||"");else{for(r.$row=m,r.order=j,k=0;k<t.columns;++k)"undefined"!=typeof x[k]?(g=e(d,m[0].cells[k],k),r.raw.push(g),h="undefined"==typeof w[k].id?g:w[k].format(g,d,m[0].cells[k],k),i="no-parser"===x[k].id?"":x[k].format(h,d,m[0].cells[k],k),o.push(t.ignoreCase&&"string"==typeof i?i.toLowerCase():i),"numeric"===(x[k].type||"").toLowerCase()&&(s[k]=Math.max(Math.abs(i)||0,s[k]||0))):t.debug&&b("No parser found for cell:",m[0].cells[k],"does it have a header?");o[t.columns]=r,f.normalized.push(o)}f.colMax=s,t.totalRows+=f.normalized.length}t.showProcessing&&v.isProcessing(d),t.debug&&c("Building cache for "+q+" rows",p)}function i(b,e){var f,g,h,i,j,k,l,m=b.config,n=m.widgetOptions,o=b.tBodies,p=[],q=m.cache;if(d(q))return m.appender?m.appender(b,p):b.isUpdating?m.$table.trigger("updateComplete",b):"";for(m.debug&&(l=new Date),k=0;k<o.length;k++)if(h=a(o[k]),h.length&&!h.hasClass(m.cssInfoBlock)){for(i=v.processTbody(b,h,!0),f=q[k].normalized,g=f.length,j=0;g>j;j++)p.push(f[j][m.columns].$row),m.appender&&(!m.pager||m.pager.removeRows&&n
return a(d).metadata()[f]},type:"numeric"}),b.addWidget({id:"zebra",priority:90,format:function(b,c,d){var e,f,g,h,i,j,k,l=new RegExp(c.cssChildRow,"i"),m=c.$tbodies;for(c.debug&&(j=new Date),k=0;k<m.length;k++)h=0,e=m.eq(k),f=e.children("tr:visible").not(c.selectorRemove),f.each(function(){g=a(this),l.test(this.className)||h++,i=h%2===0,g.removeClass(d.zebra[i?1:0]).addClass(d.zebra[i?0:1])})},remove:function(a,c,d,e){if(!e){var f,g,h=c.$tbodies,i=(d.zebra||["even","odd"]).join(" ");for(f=0;f<h.length;f++)g=b.processTbody(a,h.eq(f),!0),g.children().removeClass(i),b.processTbody(a,g,!1)}}}),b});