tablesorter/js/jquery.tablesorter.widgets.min.js
2014-07-17 12:40:11 -05:00

18 lines
32 KiB
JavaScript

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