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

4 lines
83 KiB
JavaScript
Raw Normal View History

2015-09-23 15:20:58 +00:00
/*! tablesorter (FORK) - updated 09-23-2015 (v2.23.4)*/
!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
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:function(a){return a=(a||"").replace(b.regex.spaces," ").replace(b.regex.shortDateReplace,"/"),b.regex.shortDateTest.test(a)},format:function(a,c,d,e){if(a){var f,g,h=c.config,i=h.$headerIndexed[e],j=i.length&&i[0].dateFormat||b.getData(i,b.getColumnData(c,h.headers,e),
if(j=j.not("."+F.cssChildRow),g=j.length,(G.filter_$anyMatch&&G.filter_$anyMatch.length||"undefined"!=typeof e[F.columns])&&(H.anyMatchFlag=!0,H.anyMatchFilter=""+(e[F.columns]||G.filter_$anyMatch&&b.getLatestSearch(G.filter_$anyMatch).val()||""),G.filter_columnAnyMatch)){for(y=H.anyMatchFilter.split(E.andSplit),z=!1,v=0;v<y.length;v++)A=y[v].split(":"),A.length>1&&(B=parseInt(A[0],10)-1,B>=0&&B<F.columns&&(e[B]=A[1],y.splice(v,1),v--,z=!0));z&&(H.anyMatchFilter=y.join(" && "))}if(x=G.filter_searchFiltered,r=F.lastSearch||F.$table.data("lastSearch")||[],x)for(v=0;o+1>v;v++)u=e[v]||"",x||(v=o),x=x&&r.length&&0===u.indexOf(r[v]||"")&&!E.alreadyFiltered.test(u)&&!E.exactTest.test(u)&&!(E.isNeg1.test(u)||E.isNeg2.test(u))&&!(""!==u&&F.$filters&&F.$filters.eq(v).find("select").length&&!F.$headerIndexed[v].hasClass("filter-match"));for(w=j.not("."+G.filter_filteredRow).length,x&&0===w&&(x=!1),F.debug&&console.log("Filter: Searching through "+(x&&g>w?w:"all")+" rows"),H.anyMatchFlag&&(F.sortLocaleCompare&&(H.anyMatchFilter=c.replaceAccents(H.anyMatchFilter)),G.filter_defaultFilter&&E.iQuery.test(I.defaultAnyFilter)&&(H.anyMatchFilter=b.defaultFilter(H.anyMatchFilter,I.defaultAnyFilter),x=!1),H.iAnyMatchFilter=G.filter_ignoreCase&&F.ignoreCase?H.anyMatchFilter.toLowerCase():H.anyMatchFilter),l=0;g>l;l++)if(C=j[l].className,p=l&&E.child.test(C),!(p||x&&E.filtered.test(C))){if(H.$row=j.eq(l),H.cacheArray=h[l],i=H.cacheArray[F.columns],H.rawArray=i.raw,H.childRowText="",!G.filter_childByColumn){for(C="",q=i.child,v=0;v<q.length;v++)C+=" "+q[v].join("")||"";H.childRowText=G.filter_childRows?G.filter_ignoreCase?C.toLowerCase():C:""}if(s=!1,u=b.processRow(F,H,I),q=i.$row.filter(":gt( 0 )"),G.filter_childRows&&q.length){if(G.filter_childWithSibs||q.addClass(G.filter_filteredRow),G.filter_childByColumn)for(v=0;v<q.length;v++)H.$row=q.eq(v),H.cacheArray=i.child[v],H.rawArray=H.cacheArray,u=b.processRow(F,H,I),s=s||u,!G.filter_childWithSibs&&u&&q.eq(v).removeClass(G.filter_filteredRow)}else s=u;k=i.$row,G.filter_childWithSibs||(k=k.eq(0)),k.toggleClass(G.filter_filteredRow,!s)[0].display=s?"":"none"}}F.filteredRows+=j.not("."+G.filter_filteredRow).length,F.totalRows+=j.length,c.processTbody(d,n,!1)}F.lastCombinedFilter=f,F.lastSearch=D,F.$table.data("lastSearch",D),G.filter_saveFilters&&c.storage&&c.storage(d,"tablesorter-filters",D),F.debug&&console.log("Completed filter widget search"+c.benchmark(t)),G.filter_initialized&&F.$table.trigger("filterEnd",F),setTimeout(function(){F.$table.trigger("applyWidgets")},0)}},getOptionSource:function(d,e,f){d=a(d)[0];var g=d.config,h=g.widgetOptions,i=!1,j=h.filter_selectSource,k=g.$table.data("lastSearch")||[],l="function"==typeof j?!0:c.getColumnData(d,j,e);if(f&&""!==k[e]&&(f=!1),l===!0)i=j(d,e,f);else{if(l instanceof a||"string"===a.type(l)&&l.indexOf("</option>")>=0)return l;a.isArray(l)?i=l:"object"===a.type(j)&&l&&(i=l(d,e,f))}return i===!1&&(i=b.getOptions(d,e,f)),b.processOptions(d,e,i)},processOptions:function(b,d,e){if(!a.isArray(e))return!1;b=a(b)[0];var f,g,h,i,j=b.config,k="undefined"!=typeof d&&null!==d&&d>=0&&d<j.columns,l=[];if(e=a.grep(e,function(b,c){return a.inArray(b,e)===c}),k&&j.$headerIndexed[d].hasClass("filter-select-nosort"))return e;for(i=e.length,h=0;i>h;h++)g=e[h],l.push({t:g,p:k&&j.parsers&&j.parsers.length&&j.parsers[d].format(g,b,[],d)||g});for(f=j.textSorter||"",l.sort(function(a,e){var g=a.p.toString(),h=e.p.toString();return k&&"function"==typeof f?f(g,h,!0,d,b):k&&"object"==typeof f&&f.hasOwnProperty(d)?f[d](g,h,!0,d,b):c.sortNatural?c.sortNatural(g,h):!0}),e=[],i=l.length,h=0;i>h;h++)e.push(l[h].t);return e},getOptions:function(b,c,d){b=a(b)[0];var e,f,g,h,i,j=b.config,k=j.widgetOptions,l=[];for(f=0;f<j.$tbodies.length;f++)for(i=j.cache[f],g=j.cache[f].normalized.length,e=0;g>e;e++)h=i.row?i.row[e]:i.normalized[e][j.columns].$row[0],d&&h.className.match(k.filter_filteredRow)||(k.filter_useParsedData||j.parsers[c].parsed||j.$headerIndexed[c].hasClass("filter-parsed")?l.push(""+i.normalized[e][c]):l.push(i.normalized[e][j.columns].raw[c]));return l},buildSelect:f