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