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