tablesorter/js/jquery.tablesorter.widgets.min.js
2013-10-10 23:18:33 -05:00

17 lines
23 KiB
JavaScript

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