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