/*! Widget: resizable - updated 6/26/2015 (v2.22.2) */ /*jshint browser:true, jquery:true, unused:false */ !function(a,b){"use strict";var c=a.tablesorter||{};a.extend(c.css,{resizableContainer:"tablesorter-resizable-container",resizableHandle:"tablesorter-resizable-handle",resizableNoSelect:"tablesorter-disableSelection",resizableStorage:"tablesorter-resizable"}), // Add extra scroller css a(function(){var b="";a(b).appendTo("body")}),c.resizable={init:function(b,d){if(!b.$table.hasClass("hasResizable")){b.$table.addClass("hasResizable");var e,f,g,h,i,j=b.$table,k=j.parent(),l=parseInt(j.css("margin-top"),10), // internal variables m=d.resizable_vars={useStorage:c.storage&&d.resizable!==!1,$wrap:k,mouseXPosition:0,$target:null,$next:null,overflow:"auto"===k.css("overflow")||"scroll"===k.css("overflow")||"auto"===k.css("overflow-x")||"scroll"===k.css("overflow-x"),storedSizes:[]}; // add container for( // set default widths c.resizableReset(b.table,!0), // now get measurements! m.tableWidth=j.width(), // attempt to autodetect m.fullWidth=Math.abs(k.width()-m.tableWidth)<20,/* // Hacky method to determine if table width is set to 'auto' // http://stackoverflow.com/a/20892048/145346 if ( !vars.fullWidth ) { tmp = $table.width(); $header = $table.wrap('').parent(); // temp variable storedSizes = parseInt( $table.css( 'margin-left' ), 10 ) || 0; $table.css( 'margin-left', storedSizes + 50 ); vars.tableWidth = $header.width() > tmp ? 'auto' : tmp; $table.css( 'margin-left', storedSizes ? storedSizes : '' ); $header = null; $table.unwrap(''); } */ m.useStorage&&m.overflow&&( // save table width c.storage(b.table,"tablesorter-table-original-css-width",m.tableWidth),i=c.storage(b.table,"tablesorter-table-resized-width")||"auto",c.resizable.setWidth(j,i,!0)),d.resizable_vars.storedSizes=h=(m.useStorage?c.storage(b.table,c.css.resizableStorage):[])||[],c.resizable.setWidths(b,d,h),c.resizable.updateStoredSizes(b,d),d.$resizable_container=a('
').css({top:l}).insertBefore(j),g=0;g').appendTo(d.$resizable_container).attr({"data-column":g,unselectable:"on"}).data("header",f).bind("selectstart",!1);j.one("tablesorter-initialized",function(){c.resizable.setHandlePosition(b,d),c.resizable.bindings(this.config,this.config.widgetOptions)})}},updateStoredSizes:function(a,b){var c,d,e=a.columns,f=b.resizable_vars;for(f.storedSizes=[],c=0;e>c;c++)d=a.$headerIndexed[c],f.storedSizes[c]=d.is(":visible")?d.width():0},setWidth:function(a,b,c){ // overflow tables need min & max width set as well a.css({width:b,"min-width":c?b:"","max-width":c?b:""})},setWidths:function(b,d,e){var f,g,h=d.resizable_vars,i=a(b.namespace+"_extra_headers"),j=b.$table.children("colgroup").children("col"); // process only if table ID or url match if(e=e||h.storedSizes||[],e.length){for(f=0;ff||f===h&&d.resizable_addLastColumn)&&c.css({display:"inline-block",height:g,left:j.position().left-e+j.outerWidth()-i}):c.hide())})}, // prevent text selection while dragging resize bar toggleTextSelection:function(b,d){var e=b.namespace+"tsresize";b.widgetOptions.resizable_vars.disabled=d,a("body").toggleClass(c.css.resizableNoSelect,d),d?a("body").attr("unselectable","on").bind("selectstart"+e,!1):a("body").removeAttr("unselectable").unbind("selectstart"+e)},bindings:function(d,e){var f=d.namespace+"tsresize";e.$resizable_container.children().bind("mousedown",function(b){ // save header cell and mouse position var f,g=e.resizable_vars,h=a(d.namespace+"_extra_headers"),i=a(b.target).data("header");f=parseInt(i.attr("data-column"),10),g.$target=i=i.add(h.filter('[data-column="'+f+'"]')),g.target=f,g.$next=b.shiftKey||e.resizable_targetLast?i.parent().children().not(".resizable-false").filter(":last"):i.nextAll(":not(.resizable-false)").eq(0),f=parseInt(g.$next.attr("data-column"),10),g.$next=g.$next.add(h.filter('[data-column="'+f+'"]')),g.next=f,g.mouseXPosition=b.pageX,c.resizable.updateStoredSizes(d,e),c.resizable.toggleTextSelection(d,!0)}),a(document).bind("mousemove"+f,function(a){var b=e.resizable_vars; // ignore mousemove if no mousedown b.disabled&&0!==b.mouseXPosition&&b.$target&&(e.resizable_throttle?(clearTimeout(b.timer),b.timer=setTimeout(function(){c.resizable.mouseMove(d,e,a)},isNaN(e.resizable_throttle)?5:e.resizable_throttle)):c.resizable.mouseMove(d,e,a))}).bind("mouseup"+f,function(){e.resizable_vars.disabled&&(c.resizable.toggleTextSelection(d,!1),c.resizable.stopResize(d,e),c.resizable.setHandlePosition(d,e))}), // resizeEnd event triggered by scroller widget a(b).bind("resize"+f+" resizeEnd"+f,function(){c.resizable.setHandlePosition(d,e)}), // right click to reset columns to default widths d.$table.bind("columnUpdate"+f,function(){c.resizable.setHandlePosition(d,e)}).find("thead:first").add(a(d.namespace+"_extra_table").find("thead:first")).bind("contextmenu"+f,function(){ // $.isEmptyObject() needs jQuery 1.4+; allow right click if already reset var a=0===e.resizable_vars.storedSizes.length;return c.resizableReset(d.table),c.resizable.setHandlePosition(d,e),e.resizable_vars.storedSizes=[],a})},mouseMove:function(b,d,e){if(0!==d.resizable_vars.mouseXPosition&&d.resizable_vars.$target){ // resize columns var f,g=0,h=d.resizable_vars,i=h.$next,j=h.storedSizes[h.target],k=e.pageX-h.mouseXPosition;if(h.overflow){if(j+k>0){ // update the entire table width for(h.storedSizes[h.target]+=k,c.resizable.setWidth(h.$target,h.storedSizes[h.target],!0),f=0;f