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

2 lines
37 KiB
JavaScript
Raw Normal View History

2015-10-04 14:26:07 +00:00
!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){return function(a){"use strict";a.extend({tablesorter:new function(){function b(b,c,d,e){for(var f,g,h=q.parsers.length,i=!1,j="",k=!0;""===j&&k;)d++,c[d]?(i=c[d].cells[e],j=q.getElementText(b,i,e),g=a(i),b.debug&&console.log("Checking if value was empty on row "+d+", column: "+e+': "'+j+'"')):k=!1;for(;--h>=0;)if(f=q.parsers[h],f&&"text"!==f.id&&f.is&&f.is(j,b.table,i,g))return f;return q.getParserById("text")}function c(a,c){var d,e,f,g,h,i,j,k,l,m,n,o,p=a.table,r=0,s={};if(a.$tbodies=a.$table.children("tbody:not(."+a.cssInfoBlock+")"),n="undefined"==typeof c?a.$tbodies:c,o=n.length,0===o)return a.debug?console.warn("Warning: *Empty table!* Not building a parser cache"):"";for(a.debug&&(m=new Date,console[console.group?"group":"log"]("Detecting parsers for each column")),e={extractors:[],parsers:[]};o>r;){if(d=n[r].rows,d.length)for(f=a.columns,g=0;f>g;g++)h=a.$headerIndexed[g],i=q.getColumnData(p,a.headers,g),l=q.getParserById(q.getData(h,i,"extractor")),k=q.getParserById(q.getData(h,i,"sorter")),j="false"===q.getData(h,i,"parser"),a.empties[g]=(q.getData(h,i,"empty")||a.emptyTo||(a.emptyToBottom?"bottom":"top")).toLowerCase(),a.strings[g]=(q.getData(h,i,"string")||a.stringTo||"max").toLowerCase(),j&&(k=q.getParserById("no-parser")),l||(l=!1),k||(k=b(a,d,-1,g)),a.debug&&(s["("+g+") "+h.text()]={parser:k.id,extractor:l?l.id:"none",string:a.strings[g],empty:a.empties[g]}),e.parsers[g]=k,e.extractors[g]=l;r+=e.parsers.length?o:1}a.debug&&(q.isEmptyObject(s)?console.warn(" No parsers detected!"):console[console.table?"table":"log"](s),console.log("Completed detecting parsers"+q.benchmark(m)),console.groupEnd&&console.groupEnd()),a.parsers=e.parsers,a.extractors=e.extractors}function d(b,c,d){var e,f,g,h,i,j,k,l,m,n,o,p,r,s,t=b.config,u=t.parsers;if(t.$tbodies=t.$table.children("tbody:not(."+t.cssInfoBlock+")"),k="undefined"==typeof d?t.$tbodies:d,t.cache={},t.totalRows=0,!u)return t.debug?console.warn("Warning: *Empty table!* Not building a cache"):"";for(t.debug&&(n=new Date),t.showProcessing&&q.isProcessing(b,!0),j=0;j<k.length;j++){for(s=[],e=t.cache[j]={normalized:[]},o=k[j]&&k[j].rows.length||0,h=0;o>h;++h)if(p={child:[],raw:[]},l=a(k[j].rows[h]),m=[],l.hasClass(t.cssChildRow)&&0!==h)for(f=e.normalized.length-1,r=e.normalized[f][t.columns],r.$row=r.$row.add(l),l.prev().hasClass(t.cssChildRow)||l.prev().addClass(q.css.cssHasChild),g=l.children("th, td"),f=r.child.length,r.child[f]=[],i=0;i<t.columns;i++)r.child[f][i]=q.getParsedText(t,g[i],i);else{for(p.$row=l,p.order=h,i=0;i<t.columns;++i)"undefined"!=typeof u[i]?(f=q.getElementText(t,l[0].cells[i],i),p.raw.push(f),g=q.getParsedText(t,l[0].cells[i],i,f),m.push(g),"numeric"===(u[i].type||"").toLowerCase()&&(s[i]=Math.max(Math.abs(g)||0,s[i]||0))):t.debug&&console.warn("No parser found for cell:",l[0].cells[i],"does it have a header?");m[t.columns]=p,e.normalized.push(m)}e.colMax=s,t.totalRows+=e.normalized.length}t.showProcessing&&q.isProcessing(b),t.debug&&console.log("Building cache for "+o+" rows"+q.benchmark(n)),a.isFunction(c)&&c(b)}function e(a){return/^d/i.test(a)||1===a}function f(b){var c,d,f,g,i,j,k,l;for(b.headerList=[],b.headerContent=[],b.debug&&(k=new Date),b.columns=q.computeColumnIndex(b.$table.children("thead, tfoot").children("tr")),g=b.cssIcon?'<i class="'+(b.cssIcon===q.css.icon?q.css.icon:b.cssIcon+" "+q.css.icon)+'"></i>':"",b.$headers=a(a.map(b.$table.find(b.selectorHeaders),function(h,k){return d=a(h),d.parent().hasClass(b.cssIgnoreRow)?void 0:(c=q.getColumnData(b.table,b.headers,k,!0),b.headerContent[k]=d.html(),""===b.headerTemplate||d.find("."+q.css.headerIn).length||(i=b.headerTemplate.replace(q.regex.templateContent,d.html()).replace(q.regex.templateIcon,d.find("."+q.css.icon).length?"":g),b.onRenderTemplate&&(f=b.onRenderTemplate.apply(d,[k,i]),f&&"string"==typeof f&&(i=f)),d.html('<div class="'+q.css.headerIn+'">'+i+"</div>")),b.onRenderHeader&&b.onRe
"undefined"!=typeof h.data(d)||"undefined"!=typeof h.data(d.toLowerCase())?g+=h.data(d)||h.data(d.toLowerCase()):e&&"undefined"!=typeof e[d]?g+=e[d]:c&&"undefined"!=typeof c[d]?g+=c[d]:" "!==f&&f.match(" "+d+"-")&&(g=f.match(new RegExp("\\s"+d+"-([\\w-]+)"))[1]||""),a.trim(g)):""},q.regex.comma=/,/g,q.regex.digitNonUS=/[\s|\.]/g,q.regex.digitNegativeTest=/^\s*\([.\d]+\)/,q.regex.digitNegativeReplace=/^\s*\(([.\d]+)\)/,q.formatFloat=function(b,c){if("string"!=typeof b||""===b)return b;var d,e=c&&c.config?c.config.usNumberFormat!==!1:"undefined"!=typeof c?c:!0;return b=e?b.replace(q.regex.comma,""):b.replace(q.regex.digitNonUS,"").replace(q.regex.comma,"."),q.regex.digitNegativeTest.test(b)&&(b=b.replace(q.regex.digitNegativeReplace,"-$1")),d=parseFloat(b),isNaN(d)?a.trim(b):d},q.regex.digitTest=/^[\-+(]?\d+[)]?$/,q.regex.digitReplace=/[,.'"\s]/g,q.isDigit=function(a){return isNaN(a)?q.regex.digitTest.test(a.toString().replace(q.regex.digitReplace,"")):""!==a}}});var b=a.tablesorter;a.fn.extend({tablesorter:b.construct}),window.console&&window.console.log||(b.logs=[],console={},console.log=console.warn=console.error=console.table=function(){b.logs.push([Date.now(),arguments])}),b.log=function(){console.log(arguments)},b.benchmark=function(a){return" ("+((new Date).getTime()-a.getTime())+"ms)"},b.addParser({id:"no-parser",is:function(){return!1},format:function(){return""},type:"text"}),b.addParser({id:"text",is:function(){return!0},format:function(c,d){var e=d.config;return c&&(c=a.trim(e.ignoreCase?c.toLocaleLowerCase():c),c=e.sortLocaleCompare?b.replaceAccents(c):c),c},type:"text"}),b.regex.nondigit=/[^\w,. \-()]/g,b.addParser({id:"digit",is:function(a){return b.isDigit(a)},format:function(c,d){var e=b.formatFloat((c||"").replace(b.regex.nondigit,""),d);return c&&"number"==typeof e?e:c?a.trim(c&&d.config.ignoreCase?c.toLocaleLowerCase():c):c},type:"numeric"}),b.regex.currencyReplace=/[+\-,. ]/g,b.regex.currencyTest=/^\(?\d+[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]|[\u00a3$\u20ac\u00a4\u00a5\u00a2?.]\d+\)?$/,b.addParser({id:"currency",is:function(a){return a=(a||"").replace(b.regex.currencyReplace,""),b.regex.currencyTest.test(a)},format:function(c,d){var e=b.formatFloat((c||"").replace(b.regex.nondigit,""),d);return c&&"number"==typeof e?e:c?a.trim(c&&d.config.ignoreCase?c.toLocaleLowerCase():c):c},type:"numeric"}),b.regex.urlProtocolTest=/^(https?|ftp|file):\/\//,b.regex.urlProtocolReplace=/(https?|ftp|file):\/\//,b.addParser({id:"url",is:function(a){return b.regex.urlProtocolTest.test(a)},format:function(c){return c?a.trim(c.replace(b.regex.urlProtocolReplace,"")):c},parsed:!0,type:"text"}),b.regex.dash=/-/g,b.regex.isoDate=/^\d{4}[\/\-]\d{1,2}[\/\-]\d{1,2}/,b.addParser({id:"isoDate",is:function(a){return b.regex.isoDate.test(a)},format:function(a,c){var d=a?new Date(a.replace(b.regex.dash,"/")):a;return d instanceof Date&&isFinite(d)?d.getTime():a},type:"numeric"}),b.regex.percent=/%/g,b.regex.percentTest=/(\d\s*?%|%\s*?\d)/,b.addParser({id:"percent",is:function(a){return b.regex.percentTest.test(a)&&a.length<15},format:function(a,c){return a?b.formatFloat(a.replace(b.regex.percent,""),c):a},type:"numeric"}),b.addParser({id:"image",is:function(a,b,c,d){return d.find("img").length>0},format:function(b,c,d){return a(d).find("img").attr(c.config.imgAttr||"alt")||b},parsed:!0,type:"text"}),b.regex.dateReplace=/(\S)([AP]M)$/i,b.regex.usLongDateTest1=/^[A-Z]{3,10}\.?\s+\d{1,2},?\s+(\d{4})(\s+\d{1,2}:\d{2}(:\d{2})?(\s+[AP]M)?)?$/i,b.regex.usLongDateTest2=/^\d{1,2}\s+[A-Z]{3,10}\s+\d{4}/i,b.addParser({id:"usLongDate",is:function(a){return b.regex.usLongDateTest1.test(a)||b.regex.usLongDateTest2.test(a)},format:function(a,c){var d=a?new Date(a.replace(b.regex.dateReplace,"$1 $2")):a;return d instanceof Date&&isFinite(d)?d.getTime():a},type:"numeric"}),b.regex.shortDateTest=/(^\d{1,2}[\/\s]\d{1,2}[\/\s]\d{4})|(^\d{4}[\/\s]\d{1,2}[\/\s]\d{1,2})/,b.regex.shortDateReplace=/[\-.,]/g,b.regex.shortDateXXY=/(\d{1,2})[\/\s](\d{1,2})[\/\s](\d{4})/,b.regex.shortDateYMD=/(\d{4})[\/\s](\d{1,2})[\/\s](\d{1,2})/,b.addParser({id:"shortDate",is:fun