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