mirror of
https://github.com/Mottie/tablesorter.git
synced 2024-11-15 23:54:22 +00:00
18 lines
28 KiB
JavaScript
18 lines
28 KiB
JavaScript
/*! tableSorter 2.16+ widgets - updated 4/27/2014 (v2.16.2) */
|
|
;(function(k){
|
|
var d=k.tablesorter=k.tablesorter||{};
|
|
d.themes={bootstrap:{table:"table table-bordered table-striped",caption:"caption",header:"bootstrap-header",footerRow:"",footerCells:"",icons:"",sortNone:"bootstrap-icon-unsorted",sortAsc:"icon-chevron-up glyphicon glyphicon-chevron-up",sortDesc:"icon-chevron-down glyphicon glyphicon-chevron-down",active:"",hover:"",filterRow:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",caption:"ui-widget-content ui-corner-all",header:"ui-widget-header ui-corner-all ui-state-default", footerRow:"",footerCells:"",icons:"ui-icon",sortNone:"ui-icon-carat-2-n-s",sortAsc:"ui-icon-carat-1-n",sortDesc:"ui-icon-carat-1-s",active:"ui-state-active",hover:"ui-state-hover",filterRow:"",even:"ui-widget-content",odd:"ui-state-default"}};k.extend(d.css,{filterRow:"tablesorter-filter-row",filter:"tablesorter-filter",wrapper:"tablesorter-wrapper",resizer:"tablesorter-resizer",grip:"tablesorter-resizer-grip",sticky:"tablesorter-stickyHeader",stickyVis:"tablesorter-sticky-visible"});
|
|
d.storage=function(b, a,e,c){b=k(b)[0];var f,d,h=!1;f={};d=b.config;var l=k(b);b=c&&c.id||l.attr(c&&c.group||"data-table-group")||b.id||k(".tablesorter").index(l);c=c&&c.url||l.attr(c&&c.page||"data-table-page")||d&&d.fixedUrl||window.location.pathname;if("localStorage"in window)try{window.localStorage.setItem("_tmptest","temp"),h=!0,window.localStorage.removeItem("_tmptest")}catch(m){}k.parseJSON&&(h?f=k.parseJSON(localStorage[a]||"{}"):(d=document.cookie.split(/[;\s|=]/),f=k.inArray(a,d)+1,f=0!==f?k.parseJSON(d[f]|| "{}"):{}));if((e||""===e)&&window.JSON&&JSON.hasOwnProperty("stringify"))f[c]||(f[c]={}),f[c][b]=e,h?localStorage[a]=JSON.stringify(f):(e=new Date,e.setTime(e.getTime()+31536E6),document.cookie=a+"="+JSON.stringify(f).replace(/\"/g,'"')+"; expires="+e.toGMTString()+"; path=/");else return f&&f[c]?f[c][b]:""};
|
|
d.addHeaderResizeEvent=function(b,a,e){var c;e=k.extend({},{timer:250},e);var d=b.config,g=d.widgetOptions,h=function(a){g.resize_flag=!0;c=[];d.$headers.each(function(){var a=k(this),b=a.data("savedSizes")|| [0,0],e=this.offsetWidth,d=this.offsetHeight;if(e!==b[0]||d!==b[1])a.data("savedSizes",[e,d]),c.push(this)});c.length&&!1!==a&&d.$table.trigger("resize",[c]);g.resize_flag=!1};h(!1);clearInterval(g.resize_timer);if(a)return g.resize_flag=!1;g.resize_timer=setInterval(function(){g.resize_flag||h()},e.timer)};
|
|
d.addWidget({id:"uitheme",priority:10,format:function(b,a,e){var c,f,g,h=d.themes;c=a.$table;g=a.$headers;var l=a.theme||"jui",m=h[l]||h.jui,h=m.sortNone+" "+m.sortDesc+" "+m.sortAsc;a.debug&& (f=new Date);c.hasClass("tablesorter-"+l)&&a.theme!==l&&b.hasInitialized||(""!==m.even&&(e.zebra[0]+=" "+m.even),""!==m.odd&&(e.zebra[1]+=" "+m.odd),c.find("caption").addClass(m.caption),b=c.removeClass(""===a.theme?"":"tablesorter-"+a.theme).addClass("tablesorter-"+l+" "+m.table).find("tfoot"),b.length&&b.find("tr").addClass(m.footerRow).children("th, td").addClass(m.footerCells),g.addClass(m.header).not(".sorter-false").bind("mouseenter.tsuitheme mouseleave.tsuitheme",function(a){k(this)["mouseenter"=== a.type?"addClass":"removeClass"](m.hover)}),g.find("."+d.css.wrapper).length||g.wrapInner('<div class="'+d.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>'),a.cssIcon&&g.find("."+d.css.icon).addClass(m.icons),c.hasClass("hasFilters")&&g.find("."+d.css.filterRow).addClass(m.filterRow));for(c=0;c<a.columns;c++)b=a.$headers.add(a.$extraHeaders).filter('[data-column="'+c+'"]'),e=d.css.icon?b.find("."+d.css.icon):b,a.$headers.filter('[data-column="'+c+'"]:last')[0].sortDisabled? (b.removeClass(h),e.removeClass(h+" "+m.icons)):(g=b.hasClass(d.css.sortAsc)?m.sortAsc:b.hasClass(d.css.sortDesc)?m.sortDesc:b.hasClass(d.css.header)?m.sortNone:"",b[g===m.sortNone?"removeClass":"addClass"](m.active),e.removeClass(h).addClass(g));a.debug&&d.benchmark("Applying "+l+" theme",f)},remove:function(b,a,e){b=a.$table;a=a.theme||"jui";e=d.themes[a]||d.themes.jui;var c=b.children("thead").children(),f=e.sortNone+" "+e.sortDesc+" "+e.sortAsc;b.removeClass("tablesorter-"+a+" "+e.table).find(d.css.header).removeClass(e.header); c.unbind("mouseenter.tsuitheme mouseleave.tsuitheme").removeClass(e.hover+" "+f+" "+e.active).find("."+d.css.filterRow).removeClass(e.filterRow);c.find("."+d.css.icon).removeClass(e.icons)}});
|
|
d.addWidget({id:"columns",priority:30,options:{columns:["primary","secondary","tertiary"]},format:function(b,a,e){var c,f,g,h,l,m,q,n,p=a.$table,t=a.$tbodies,v=a.sortList,u=v.length,w=e&&e.columns||["primary","secondary","tertiary"],x=w.length-1;q=w.join(" ");a.debug&&(c=new Date);for(g=0;g<t.length;g++)f=d.processTbody(b, t.eq(g),!0),h=f.children("tr"),h.each(function(){l=k(this);if("none"!==this.style.display&&(m=l.children().removeClass(q),v&&v[0]&&(m.eq(v[0][0]).addClass(w[0]),1<u)))for(n=1;n<u;n++)m.eq(v[n][0]).addClass(w[n]||w[x])}),d.processTbody(b,f,!1);b=!1!==e.columns_thead?["thead tr"]:[];!1!==e.columns_tfoot&&b.push("tfoot tr");if(b.length&&(h=p.find(b.join(",")).children().removeClass(q),u))for(n=0;n<u;n++)h.filter('[data-column="'+v[n][0]+'"]').addClass(w[n]||w[x]);a.debug&&d.benchmark("Applying Columns widget", c)},remove:function(b,a,e){var c=a.$tbodies,f=(e.columns||["primary","secondary","tertiary"]).join(" ");a.$headers.removeClass(f);a.$table.children("tfoot").children("tr").children("th, td").removeClass(f);for(a=0;a<c.length;a++)e=d.processTbody(b,c.eq(a),!0),e.children("tr").each(function(){k(this).children().removeClass(f)}),d.processTbody(b,e,!1)}});
|
|
d.addWidget({id:"filter",priority:50,options:{filter_childRows:!1,filter_columnFilters:!0,filter_cssFilter:"",filter_external:"",filter_filteredRow:"filtered", filter_formatter:null,filter_functions:null,filter_hideEmpty:!0,filter_hideFilters:!1,filter_ignoreCase:!0,filter_liveSearch:!0,filter_onlyAvail:"filter-onlyAvail",filter_placeholder:{search:"",select:""},filter_reset:null,filter_saveFilters:!1,filter_searchDelay:300,filter_selectSource:null,filter_startsWith:!1,filter_useParsedData:!1,filter_serversideFiltering:!1,filter_defaultAttrib:"data-value"},format:function(b,a,e){a.$table.hasClass("hasFilters")||d.filter.init(b,a,e)},remove:function(b,a, e){var c,f=a.$tbodies;a.$table.removeClass("hasFilters").unbind("addRows updateCell update updateRows updateComplete appendCache filterReset filterEnd search ".split(" ").join(a.namespace+"filter ")).find("."+d.css.filterRow).remove();for(a=0;a<f.length;a++)c=d.processTbody(b,f.eq(a),!0),c.children().removeClass(e.filter_filteredRow).show(),d.processTbody(b,c,!1);e.filter_reset&&k(document).undelegate(e.filter_reset,"click.tsfilter")}});
|
|
d.filter={regex:{regex:/^\/((?:\\\/|[^\/])+)\/([mig]{0,3})?$/, child:/tablesorter-childRow/,filtered:/filtered/,type:/undefined|number/,exact:/(^[\"|\'|=]+)|([\"|\'|=]+$)/g,nondigit:/[^\w,. \-()]/g,operators:/[<>=]/g},types:{regex:function(b,a,e,c){if(d.filter.regex.regex.test(a)){var f;b=d.filter.regex.regex.exec(a);try{f=RegExp(b[1],b[2]).test(c)}catch(g){f=!1}return f}return null},operators:function(b,a,e,c,f,g,h,l,k){if(/^[<>]=?/.test(a)){var q,n;q=h.config;b=d.formatFloat(a.replace(d.filter.regex.operators,""),h);e=q.parsers[g];l=b;if(k[g]||"numeric"=== e.type)q=e.format(""+a.replace(d.filter.regex.operators,""),h,q.$headers.eq(g),g),b="number"!==typeof b||""===q||isNaN(q)?b:q;q=!k[g]&&"numeric"!==e.type||isNaN(b)||!f?isNaN(c)?d.formatFloat(c.replace(d.filter.regex.nondigit,""),h):d.formatFloat(c,h):f;/>/.test(a)&&(n=/>=/.test(a)?q>=b:q>b);/</.test(a)&&(n=/<=/.test(a)?q<=b:q<b);n||""!==l||(n=!0);return n}return null},exact:function(b,a,e,c,f,g,h,l,m,q){return d.filter.regex.exact.test(a)?(b=a.replace(d.filter.regex.exact,""),q?0<=k.inArray(b,q): b==c):null},notMatch:function(b,a,e,c,d,g,h,l){return/^\!/.test(a)?(a=a.replace("!",""),b=c.search(k.trim(a)),""===a?!0:!(l.filter_startsWith?0===b:0<=b)):null},and:function(b,a,e,c){if(/\s+(AND|&&)\s+/g.test(b)){b=a.split(/(?:\s+(?:and|&&)\s+)/g);a=0<=c.search(k.trim(b[0]));for(e=b.length-1;a&&e;)a=a&&0<=c.search(k.trim(b[e])),e--;return a}return null},range:function(b,a,e,c,f,g,h,l,k){if(/\s+(-|to)\s+/.test(a)){b=h.config;var q=a.split(/(?: - | to )/);e=d.formatFloat(q[0].replace(d.filter.regex.nondigit, ""),h);l=d.formatFloat(q[1].replace(d.filter.regex.nondigit,""),h);if(k[g]||"numeric"===b.parsers[g].type)a=b.parsers[g].format(""+q[0],h,b.$headers.eq(g),g),e=""===a||isNaN(a)?e:a,a=b.parsers[g].format(""+q[1],h,b.$headers.eq(g),g),l=""===a||isNaN(a)?l:a;a=!k[g]&&"numeric"!==b.parsers[g].type||isNaN(e)||isNaN(l)?isNaN(c)?d.formatFloat(c.replace(d.filter.regex.nondigit,""),h):d.formatFloat(c,h):f;e>l&&(c=e,e=l,l=c);return a>=e&&a<=l||""===e||""===l}return null},wild:function(b,a,e,c,d,g,h,l,m,q){return/[\?|\*]/.test(a)|| /\s+OR\s+/i.test(b)?(b=h.config,a=a.replace(/\s+OR\s+/gi,"|"),!b.$headers.filter('[data-column="'+g+'"]:last').hasClass("filter-match")&&/\|/.test(a)&&(a=k.isArray(q)?"("+a+")":"^("+a+")$"),RegExp(a.replace(/\?/g,"\\S{1}").replace(/\*/g,"\\S*")).test(c)):null},fuzzy:function(b,a,e,c){if(/^~/.test(a)){b=0;e=c.length;var d=a.slice(1);for(a=0;a<e;a++)c[a]===d[b]&&(b+=1);return b===d.length?!0:!1}return null}},init:function(b,a,e){var c,f,g,h,l,m;a.debug&&(m=new Date);a.$table.addClass("hasFilters"); d.filter.regex.child=RegExp(a.cssChildRow);d.filter.regex.filtered=RegExp(e.filter_filteredRow);!1!==e.filter_columnFilters&&a.$headers.filter(".filter-false").length!==a.$headers.length&&d.filter.buildRow(b,a,e);a.$table.bind("addRows updateCell update updateRows updateComplete appendCache filterReset filterEnd search ".split(" ").join(a.namespace+"filter "),function(c,f){a.$table.find("."+d.css.filterRow).toggle(!(e.filter_hideEmpty&&k.isEmptyObject(a.cache)));/(search|filter)/.test(c.type)||(c.stopPropagation(), d.filter.buildDefault(b,!0));"filterReset"===c.type?d.filter.searching(b,[]):"filterEnd"===c.type?d.filter.buildDefault(b,!0):(f="search"===c.type?f:"updateComplete"===c.type?a.$table.data("lastSearch"):"",/(update|add)/.test(c.type)&&"updateComplete"!==c.type&&(a.lastCombinedFilter=null),d.filter.searching(b,f,!0));return!1});e.filter_reset&&(e.filter_reset instanceof k?e.filter_reset.click(function(){a.$table.trigger("filterReset")}):k(e.filter_reset).length&&k(document).undelegate(e.filter_reset, "click.tsfilter").delegate(e.filter_reset,"click.tsfilter",function(){a.$table.trigger("filterReset")}));if(e.filter_functions)for(h in e.filter_functions)if(e.filter_functions.hasOwnProperty(h)&&"string"===typeof h)if(g=a.$headers.filter('[data-column="'+h+'"]:last'),c="",!0===e.filter_functions[h]&&!g.hasClass("filter-false"))d.filter.buildSelect(b,h);else if("string"===typeof h&&!g.hasClass("filter-false")){for(f in e.filter_functions[h])"string"===typeof f&&(c+=""===c?'<option value="">'+(g.data("placeholder")|| g.attr("data-placeholder")||e.filter_placeholder.select||"")+"</option>":"",c+='<option value="'+f+'">'+f+"</option>");a.$table.find("thead").find("select."+d.css.filter+'[data-column="'+h+'"]').append(c)}d.filter.buildDefault(b,!0);d.filter.bindSearch(b,a.$table.find("."+d.css.filter),!0);e.filter_external&&d.filter.bindSearch(b,e.filter_external);e.filter_hideFilters&&d.filter.hideFilters(b,a);a.showProcessing&&a.$table.bind("filterStart"+a.namespace+"filter filterEnd"+a.namespace+"filter",function(e, c){g=c?a.$table.find("."+d.css.header).filter("[data-column]").filter(function(){return""!==c[k(this).data("column")]}):"";d.isProcessing(b,"filterStart"===e.type,c?g:"")});a.debug&&d.benchmark("Applying Filter widget",m);a.$table.bind("tablesorter-initialized pagerInitialized",function(){l=d.filter.setDefaults(b,a,e)||[];l.length&&d.setFilters(b,l,!0);a.$table.trigger("filterFomatterUpdate");d.filter.checkFilters(b,l)});e.filter_initialized=!0;a.$table.trigger("filterInit")},setDefaults:function(b, a,e){var c,f=d.getFilters(b)||[];e.filter_saveFilters&&d.storage&&(c=d.storage(b,"tablesorter-filters")||[],(b=k.isArray(c))&&""===c.join("")||!b||(f=c));if(""===f.join(""))for(b=0;b<a.columns;b++)f[b]=a.$headers.filter('[data-column="'+b+'"]:last').attr(e.filter_defaultAttrib)||f[b];a.$table.data("lastSearch",f);return f},buildRow:function(b,a,e){var c,f,g,h=a.columns;f='<tr class="'+d.css.filterRow+'">';for(b=0;b<h;b++)f+="<td></td>";a.$filters=k(f+"</tr>").appendTo(a.$table.children("thead").eq(0)).find("td"); for(b=0;b<h;b++)c=a.$headers.filter('[data-column="'+b+'"]:last'),f=e.filter_functions&&e.filter_functions[b]&&"function"!==typeof e.filter_functions[b]||c.hasClass("filter-select"),g=d.getData?"false"===d.getData(c[0],a.headers[b],"filter"):a.headers[b]&&a.headers[b].hasOwnProperty("filter")&&!1===a.headers[b].filter||c.hasClass("filter-false"),f?f=k("<select>").appendTo(a.$filters.eq(b)):(e.filter_formatter&&k.isFunction(e.filter_formatter[b])?((f=e.filter_formatter[b](a.$filters.eq(b),b))&&0=== f.length&&(f=a.$filters.eq(b).children("input")),f&&(0===f.parent().length||f.parent().length&&f.parent()[0]!==a.$filters[b])&&a.$filters.eq(b).append(f)):f=k('<input type="search">').appendTo(a.$filters.eq(b)),f&&f.attr("placeholder",c.data("placeholder")||c.attr("data-placeholder")||e.filter_placeholder.search||"")),f&&(c=(k.isArray(e.filter_cssFilter)?"undefined"!==typeof e.filter_cssFilter[b]?e.filter_cssFilter[b]||"":"":e.filter_cssFilter)||"",f.addClass(d.css.filter+" "+c).attr("data-column", b),g&&(f.attr("placeholder","").addClass("disabled")[0].disabled=!0))},bindSearch:function(b,a,e){b=k(b)[0];a=k(a);if(a.length){var c=b.config,f=c.widgetOptions,g=f.filter_$externalFilters;!0!==e&&(f.filter_$anyMatch=a.filter('[data-column="all"]'),f.filter_$externalFilters=g&&g.length?f.filter_$externalFilters.add(a):a,d.setFilters(b,c.$table.data("lastSearch")||[],!1===e));a.attr("data-lastSearchTime",(new Date).getTime()).unbind(["keyup","search","change",""].join(c.namespace+"filter ")).bind(["keyup", "search","change",""].join(c.namespace+"filter "),function(a){k(this).attr("data-lastSearchTime",(new Date).getTime());if(27===a.which)this.value="";else if("number"===typeof f.filter_liveSearch&&this.value.length<f.filter_liveSearch&&""!==this.value||"keyup"===a.type&&(32>a.which&&8!==a.which&&!0===f.filter_liveSearch&&13!==a.which||37<=a.which&&40>=a.which||13!==a.which&&!1===f.filter_liveSearch))return;d.filter.searching(b,!0,!0)});c.$table.bind("filterReset",function(){a.val("")})}},checkFilters:function(b, a,e){var c=b.config,f=c.widgetOptions,g=k.isArray(a),h=g?a:d.getFilters(b,!0),l=(h||[]).join("");g&&d.setFilters(b,h,!1,!0!==e);f.filter_hideFilters&&c.$table.find("."+d.css.filterRow).trigger(""===l?"mouseleave":"mouseenter");if(c.lastCombinedFilter!==l||!1===a)if(!1===a&&(c.lastCombinedFilter=null),c.$table.trigger("filterStart",[h]),c.showProcessing)setTimeout(function(){d.filter.findRows(b,h,l);return!1},30);else return d.filter.findRows(b,h,l),!1},hideFilters:function(b,a){var e,c,f;a.$table.find("."+ d.css.filterRow).addClass("hideme").bind("mouseenter mouseleave",function(b){e=k(this);clearTimeout(f);f=setTimeout(function(){/enter|over/.test(b.type)?e.removeClass("hideme"):k(document.activeElement).closest("tr")[0]!==e[0]&&""===a.lastCombinedFilter&&e.addClass("hideme")},200)}).find("input, select").bind("focus blur",function(a){c=k(this).closest("tr");clearTimeout(f);f=setTimeout(function(){if(""===d.getFilters(b).join(""))c["focus"===a.type?"removeClass":"addClass"]("hideme")},200)})},findRows:function(b, a,e){if(b.config.lastCombinedFilter!==e){var c,f,g,h,l,m,q,n,p,t,v,u,w,x,D,y,B,C,z,A,L,E,G,H,I,J,M,r=b.config,s=r.widgetOptions,N=r.columns,K=r.$table.children("tbody"),O=["range","notMatch","operators"],F=r.$headers.map(function(a){return r.parsers&&r.parsers[a]&&r.parsers[a].parsed||(d.getData?"parsed"===d.getData(r.$headers.filter('[data-column="'+a+'"]:last'),r.headers[a],"filter"):k(this).hasClass("filter-parsed"))}).get();r.debug&&(L=new Date);for(m=0;m<K.length;m++)if(!K.eq(m).hasClass(r.cssInfoBlock|| d.css.info)){q=d.processTbody(b,K.eq(m),!0);p=r.columns;g=k(k.map(r.cache[m].normalized,function(a){return a[p].$row.get()}));f=g.length;if(""===e||s.filter_serversideFiltering)g.removeClass(s.filter_filteredRow).not("."+r.cssChildRow).show();else{C=!0;D=r.lastSearch||r.$table.data("lastSearch")||[];k.each(a,function(a,b){C=C&&0===(b||"").indexOf(D[a])&&!/(\s+or\s+|\|)/g.test(b||"")&&!/[=\"]/.test(D[a])&&!(""!==b&&s.filter_functions&&!0===s.filter_functions[a]&&!r.$headers.filter('[data-column="'+ a+'"]:last').hasClass("filter-match"))});l=g.not("."+s.filter_filteredRow).length;C&&0===l&&(C=!1);r.debug&&d.log("Searching through "+(C&&l<f?l:"all")+" rows");if(s.filter_$anyMatch&&s.filter_$anyMatch.length||a[r.columns])E=s.filter_$anyMatch&&s.filter_$anyMatch.val()||a[r.columns]||"",r.sortLocaleCompare&&(E=d.replaceAccents(E)),G=E.toLowerCase();for(l=h=0;l<f;l++)if(t=g[l].className,!(d.filter.regex.child.test(t)||C&&d.filter.regex.filtered.test(t))){A=!0;t=g.eq(l).nextUntil("tr:not(."+r.cssChildRow+ ")");v=t.length&&s.filter_childRows?t.text():"";v=s.filter_ignoreCase?v.toLocaleLowerCase():v;n=g.eq(l).children();E&&(H=n.map(function(a){F[a]?a=r.cache[m].normalized[h][a]:(a=s.filter_ignoreCase?k(this).text().toLowerCase():k(this).text(),r.sortLocaleCompare&&(a=d.replaceAccents(a)));return a}).get(),I=H.join(" "),J=I.toLowerCase(),M=r.cache[m].normalized[h].slice(0,-1).join(" "),z=null,k.each(d.filter.types,function(a,c){if(0>k.inArray(a,O)&&(y=c(E,G,I,J,M,N,b,s,F,H),null!==y))return z=y,!1}), A=null!==z?z:0<=(J+v).indexOf(G));for(p=0;p<N;p++)a[p]&&(c=r.cache[m].normalized[h][p],s.filter_useParsedData||F[p]?u=c:(u=k.trim(n.eq(p).text()),u=r.sortLocaleCompare?d.replaceAccents(u):u),w=!d.filter.regex.type.test(typeof u)&&s.filter_ignoreCase?u.toLocaleLowerCase():u,B=A,a[p]=r.sortLocaleCompare?d.replaceAccents(a[p]):a[p],x=s.filter_ignoreCase?(a[p]||"").toLocaleLowerCase():a[p],s.filter_functions&&s.filter_functions[p]?!0===s.filter_functions[p]?B=r.$headers.filter('[data-column="'+p+'"]:last').hasClass("filter-match")? 0<=w.search(x):a[p]===u:"function"===typeof s.filter_functions[p]?B=s.filter_functions[p](u,c,a[p],p,g.eq(l)):"function"===typeof s.filter_functions[p][a[p]]&&(B=s.filter_functions[p][a[p]](u,c,a[p],p,g.eq(l))):(z=null,k.each(d.filter.types,function(e,d){y=d(a[p],x,u,w,c,p,b,s,F);if(null!==y)return z=y,!1}),null!==z?B=z:(u=(w+v).indexOf(x),B=!s.filter_startsWith&&0<=u||s.filter_startsWith&&0===u)),A=B?A:!1);g.eq(l).toggle(A).toggleClass(s.filter_filteredRow,!A);t.length&&t.toggleClass(s.filter_filteredRow, !A);h++}}d.processTbody(b,q,!1)}r.lastCombinedFilter=e;r.lastSearch=a;r.$table.data("lastSearch",a);s.filter_saveFilters&&d.storage&&d.storage(b,"tablesorter-filters",a);r.debug&&d.benchmark("Completed filter widget search",L);r.$table.trigger("filterEnd");setTimeout(function(){r.$table.trigger("applyWidgets")},0)}},getOptionSource:function(b,a,e){var c=!1,f=b.config.widgetOptions.filter_selectSource;k.isFunction(f)?c=f(b,a,e):"object"===k.type(f)&&f.hasOwnProperty(a)&&(c=f[a](b,a,e));!1===c&&(c= d.filter.getOptions(b,a,e));c=k.grep(c,function(a,b){return k.inArray(a,c)===b});return d.sortNatural?c.sort(function(a,b){return d.sortNatural(a,b)}):c.sort(!0)},getOptions:function(b,a,e){var c,d,g,h,l=b.config,m=l.widgetOptions,q=l.$table.children("tbody"),n=[];for(c=0;c<q.length;c++)if(!q.eq(c).hasClass(l.cssInfoBlock))for(h=l.cache[c],d=l.cache[c].normalized.length,b=0;b<d;b++)g=h.row?h.row[b]:h.normalized[b][l.columns].$row[0],e&&g.className.match(m.filter_filteredRow)||(m.filter_useParsedData? n.push(""+h.normalized[b][a]):(g=g.cells[a])&&n.push(k.trim(g.textContent||g.innerText||k(g).text())));return n},buildSelect:function(b,a,e,c){if(b.config.cache&&!k.isEmptyObject(b.config.cache)){a=parseInt(a,10);var f;f=b.config;var g=f.widgetOptions,h=f.$headers.filter('[data-column="'+a+'"]:last'),h='<option value="">'+(h.data("placeholder")||h.attr("data-placeholder")||g.filter_placeholder.select||"")+"</option>",l=d.filter.getOptionSource(b,a,c),m=f.$table.find("thead").find("select."+d.css.filter+ '[data-column="'+a+'"]').val();for(b=0;b<l.length;b++)c=l[b].replace(/\"/g,"""),h+=""!==l[b]?'<option value="'+c+'"'+(m===c?' selected="selected"':"")+">"+l[b]+"</option>":"";f=(f.$filters?f.$filters:f.$table.children("thead")).find("."+d.css.filter);g.filter_$externalFilters&&(f=f&&f.length?f.add(g.filter_$externalFilters):g.filter_$externalFilters);f.filter('select[data-column="'+a+'"]')[e?"html":"append"](h)}},buildDefault:function(b,a){var e,c,f=b.config,g=f.widgetOptions,h=f.columns;for(e= 0;e<h;e++)c=f.$headers.filter('[data-column="'+e+'"]:last'),(c.hasClass("filter-select")||g.filter_functions&&!0===g.filter_functions[e])&&!c.hasClass("filter-false")&&(g.filter_functions||(g.filter_functions={}),g.filter_functions[e]=!0,d.filter.buildSelect(b,e,a,c.hasClass(g.filter_onlyAvail)))},searching:function(b,a,e){if("undefined"===typeof a||!0===a){var c=b.config.widgetOptions;clearTimeout(c.searchTimer);c.searchTimer=setTimeout(function(){d.filter.checkFilters(b,a,e)},c.filter_liveSearch? c.filter_searchDelay:10)}else d.filter.checkFilters(b,a,e)}};
|
|
d.getFilters=function(b,a,e,c){var f,g=!1,h=b?k(b)[0].config:"",l=h?h.widgetOptions:"";if(!0!==a&&l&&!l.filter_columnFilters)return k(b).data("lastSearch");if(h&&(h.$filters&&(f=h.$filters.find("."+d.css.filter)),l.filter_$externalFilters&&(f=f&&f.length?f.add(l.filter_$externalFilters):l.filter_$externalFilters),f&&f.length))for(g=e||[],b=0;b<h.columns+1;b++)a=f.filter('[data-column="'+(b===h.columns?"all":b)+'"]'),a.length&&(a=a.sort(function(a, b){return k(b).attr("data-lastSearchTime")-k(a).attr("data-lastSearchTime")}),k.isArray(e)?(c?a.slice(1):a).val(e[b]).trigger("change.tsfilter"):(g[b]=a.val()||"",a.slice(1).val(g[b])),b===h.columns&&a.length&&(l.filter_$anyMatch=a));0===g.length&&(g=!1);return g};
|
|
d.setFilters=function(b,a,e,c){var f=b?k(b)[0].config:"";b=d.getFilters(b,!0,a,c);f&&e&&(f.lastCombinedFilter=null,d.filter.searching(f.$table[0],a,c),f.$table.trigger("filterFomatterUpdate"));return!!b};
|
|
d.addWidget({id:"stickyHeaders", priority:60,options:{stickyHeaders:"",stickyHeaders_attachTo:null,stickyHeaders_offset:0,stickyHeaders_filteredToTop:!0,stickyHeaders_cloneId:"-sticky",stickyHeaders_addResizeEvent:!0,stickyHeaders_includeCaption:!0,stickyHeaders_zIndex:2},format:function(b,a,e){if(!(a.$table.hasClass("hasStickyHeaders")||0<=k.inArray("filter",a.widgets)&&!a.$table.hasClass("hasFilters"))){var c=a.$table,f=k(e.stickyHeaders_attachTo),g=c.children("thead:first"),h=f.length?f:k(window),l=g.children("tr").not(".sticky-false").children(), m="."+d.css.headerIn,q=c.find("tfoot"),n=isNaN(e.stickyHeaders_offset)?k(e.stickyHeaders_offset):"",p=f.length?0:n.length?n.height()||0:parseInt(e.stickyHeaders_offset,10)||0,t=e.$sticky=c.clone().addClass("containsStickyHeaders").css({position:f.length?"absolute":"fixed",margin:0,top:p,left:0,visibility:"hidden",zIndex:e.stickyHeaders_zIndex?e.stickyHeaders_zIndex:2}),v=t.children("thead:first").addClass(d.css.sticky+" "+e.stickyHeaders),u,w="",x=0,D="collapse"!==c.css("border-collapse")&&!/(webkit|msie)/i.test(navigator.userAgent), y=function(){p=n.length?n.height()||0:parseInt(e.stickyHeaders_offset,10)||0;x=0;D&&(x=2*parseInt(l.eq(0).css("border-left-width"),10));t.css({left:f.length?(parseInt(f.css("padding-left"),10)||0)+parseInt(a.$table.css("padding-left"),10)+parseInt(a.$table.css("margin-left"),10)+parseInt(c.css("border-left-width"),10):g.offset().left-h.scrollLeft()-x,width:c.width()});u.filter(":visible").each(function(b){b=l.filter(":visible").eq(b);var c=D&&k(this).attr("data-column")===""+parseInt(a.columns/2, 10)?1:0;k(this).css({width:b.width()-x,height:b.height()}).find(m).width(b.find(m).width()-c)})};t.attr("id")&&(t[0].id+=e.stickyHeaders_cloneId);t.find("thead:gt(0), tr.sticky-false").hide();t.find("tbody, tfoot").remove();e.stickyHeaders_includeCaption?t.find("caption").css("margin-left","-1px"):t.find("caption").remove();u=v.children().children();t.css({height:0,width:0,padding:0,margin:0,border:0});u.find("."+d.css.resizer).remove();c.addClass("hasStickyHeaders").bind("pagerComplete.tsSticky", function(){y()});d.bindEvents(b,v.children().children(".tablesorter-header"));c.after(t);h.bind("scroll.tsSticky resize.tsSticky",function(a){if(c.is(":visible")){var b=c.offset(),d=e.stickyHeaders_includeCaption?0:c.find("caption").outerHeight(!0),d=(f.length?f.offset().top:h.scrollTop())+p-d,k=c.height()-(t.height()+(q.height()||0)),b=d>b.top&&d<b.top+k?"visible":"hidden",d={visibility:b};f.length?d.top=f.scrollTop():d.left=g.offset().left-h.scrollLeft()-x;t.removeClass("tablesorter-sticky-visible tablesorter-sticky-hidden").addClass("tablesorter-sticky-"+ b).css(d);if(b!==w||"resize"===a.type)y(),w=b}});e.stickyHeaders_addResizeEvent&&d.addHeaderResizeEvent(b);c.hasClass("hasFilters")&&(c.bind("filterEnd",function(){var b=k(document.activeElement).closest("td"),b=b.parent().children().index(b);t.hasClass(d.css.stickyVis)&&e.stickyHeaders_filteredToTop&&(window.scrollTo(0,c.position().top),0<=b&&a.$filters&&a.$filters.eq(b).find("a, select, input").filter(":visible").focus())}),d.filter.bindSearch(c,u.find("."+d.css.filter)));c.trigger("stickyHeadersInit")}}, remove:function(b,a,e){a.$table.removeClass("hasStickyHeaders").unbind("pagerComplete.tsSticky").find("."+d.css.sticky).remove();e.$sticky&&e.$sticky.length&&e.$sticky.remove();k(".hasStickyHeaders").length||k(window).unbind("scroll.tsSticky resize.tsSticky");d.addHeaderResizeEvent(b,!1)}});
|
|
d.addWidget({id:"resizable",priority:40,options:{resizable:!0,resizable_addLastColumn:!1,resizable_widths:[]},format:function(b,a,e){if(!a.$table.hasClass("hasResizable")){a.$table.addClass("hasResizable");d.resizableReset(b, !0);var c,f,g,h,l={},m=a.$table,q=0,n=null,p=null,t=20>Math.abs(m.parent().width()-m.width()),v=function(){d.storage&&n&&p&&(l={},l[n.index()]=n.width(),l[p.index()]=p.width(),n.width(l[n.index()]),p.width(l[p.index()]),!1!==e.resizable&&d.storage(b,"tablesorter-resizable",a.$headers.map(function(){return k(this).width()}).get()));q=0;n=p=null;k(window).trigger("resize")};if(l=d.storage&&!1!==e.resizable?d.storage(b,"tablesorter-resizable"):{})for(h in l)!isNaN(h)&&h<a.$headers.length&&a.$headers.eq(h).width(l[h]); c=m.children("thead:first").children("tr");c.children().each(function(){var b;b=k(this);h=b.attr("data-column");b="false"===d.getData(b,a.headers[h],"resizable");c.children().filter('[data-column="'+h+'"]')[b?"addClass":"removeClass"]("resizable-false")});c.each(function(){g=k(this).children().not(".resizable-false");k(this).find("."+d.css.wrapper).length||g.wrapInner('<div class="'+d.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>');e.resizable_addLastColumn||(g=g.slice(0, -1));f=f?f.add(g):g});f.each(function(){var a=k(this),b=parseInt(a.css("padding-right"),10)+10;a.find("."+d.css.wrapper).append('<div class="'+d.css.resizer+'" style="cursor:w-resize;position:absolute;z-index:1;right:-'+b+'px;top:0;height:100%;width:20px;"></div>')}).bind("mousemove.tsresize",function(a){if(0!==q&&n){var b=a.pageX-q,c=n.width();n.width(c+b);n.width()!==c&&t&&p.width(p.width()-b);q=a.pageX}}).bind("mouseup.tsresize",function(){v()}).find("."+d.css.resizer+",."+d.css.grip).bind("mousedown", function(b){n=k(b.target).closest("th");var c=a.$headers.filter('[data-column="'+n.attr("data-column")+'"]');1<c.length&&(n=n.add(c));p=b.shiftKey?n.parent().find("th").not(".resizable-false").filter(":last"):n.nextAll(":not(.resizable-false)").eq(0);q=b.pageX});m.find("thead:first").bind("mouseup.tsresize mouseleave.tsresize",function(){v()}).bind("contextmenu.tsresize",function(){d.resizableReset(b);var a=k.isEmptyObject?k.isEmptyObject(l):!0;l={};return a})}},remove:function(b,a){a.$table.removeClass("hasResizable").children("thead").unbind("mouseup.tsresize mouseleave.tsresize contextmenu.tsresize").children("tr").children().unbind("mousemove.tsresize mouseup.tsresize").find("."+ d.css.resizer+",."+d.css.grip).remove();d.resizableReset(b)}});
|
|
d.resizableReset=function(b,a){k(b).each(function(){var e,c=this.config,f=c&&c.widgetOptions;b&&c&&(c.$headers.each(function(a){e=k(this);f.resizable_widths[a]?e.css("width",f.resizable_widths[a]):e.hasClass("resizable-false")||e.css("width","")}),d.storage&&!a&&d.storage(this,"tablesorter-resizable",{}))})};
|
|
d.addWidget({id:"saveSort",priority:20,options:{saveSort:!0},init:function(b,a,d,c){a.format(b,d,c,!0)},format:function(b,a,e,c){var f, g=a.$table;e=!1!==e.saveSort;var h={sortList:a.sortList};a.debug&&(f=new Date);g.hasClass("hasSaveSort")?e&&b.hasInitialized&&d.storage&&(d.storage(b,"tablesorter-savesort",h),a.debug&&d.benchmark("saveSort widget: Saving last sort: "+a.sortList,f)):(g.addClass("hasSaveSort"),h="",d.storage&&(h=(e=d.storage(b,"tablesorter-savesort"))&&e.hasOwnProperty("sortList")&&k.isArray(e.sortList)?e.sortList:"",a.debug&&d.benchmark('saveSort: Last sort loaded: "'+h+'"',f),g.bind("saveSortReset",function(a){a.stopPropagation(); d.storage(b,"tablesorter-savesort","")})),c&&h&&0<h.length?a.sortList=h:b.hasInitialized&&h&&0<h.length&&g.trigger("sorton",[h]))},remove:function(b){d.storage&&d.storage(b,"tablesorter-savesort","")}})
|
|
})(jQuery);
|