//>>built
define("dojox/editor/plugins/ResizeTableColumn",["dojo","dijit","dojox","./TablePlugins"],function(b,B,D,C){var A=b.declare("dojox.editor.plugins.ResizeTableColumn",C,{constructor:function(){this.isLtr=this.dir?"ltr"==this.dir:b._isBodyLtr();this.ruleDiv=b.create("div",{style:"top: -10000px; z-index: 10001"},b.body(),"last")},setEditor:function(l){function p(a,e){var c=b.query("\x3e td",a.parentNode);switch(e){case "first":return c[0]==a;case "last":return c[c.length-1]==a;default:return!1}}function w(a){for(a=
a.nextSibling;a&&(!a.tagName||"td"!=a.tagName.toLowerCase());)a=a.nextSibling;return a}function t(a){for(;(a=a.parentNode)&&"table"!=a.tagName.toLowerCase(););return a}function x(a){for(var e=b.query("td",t(a)),c=e.length,d=0;d<c;d++)if(b.position(e[d]).x==b.position(a).x)return e[d];return null}function u(a,e){function c(m,f){if(!f)return 0;if("medium"==f)return 1;if(f.slice&&"px"==f.slice(-2))return parseFloat(f);with(m){var v=style.left,q=runtimeStyle.left;runtimeStyle.left=currentStyle.left;try{style.left=
f,f=style.pixelLeft}catch(r){f=0}style.left=v;runtimeStyle.left=q}return f}if(b.isIE){var d=a.currentStyle,h=c(a,d.borderLeftWidth),g=c(a,d.borderRightWidth),n=c(a,d.paddingLeft);d=c(a,d.paddingRight);a.style.width=e-h-g-n-d}else b.marginBox(a,{w:e})}var k=this.ruleDiv;this.editor=l;this.editor.customUndo=!0;this.onEditorLoaded();l.onLoadDeferred.addCallback(b.hitch(this,function(){this.connect(this.editor.editNode,"onmousemove",function(a){var e=b.position(l.iframe,!0),c=e.x,d=a.clientX;if(this.isDragging){var h=
this.activeCell;a=b.position(h);e=a.x;a=a.w;var g=w(h),n=b.position(t(h).parentNode);h=n.x;n=n.w;if(g){var m=b.position(g);var f=m.x;m=m.w}(this.isLtr&&(k.headerColumn&&g&&h<d&&d<e+a||!g&&e<d&&d<h+n||g&&e<d&&d<f+m)||!this.isLtr&&(k.headerColumn&&g&&h>d&&d>e||!g&&e+a>d&&d>h||g&&e+a>d&&d>f))&&b.style(k,{left:c+d+"px"})}else if(f=a.target,f.tagName&&"td"==f.tagName.toLowerCase()){m=b.position(f);a=m.x;g=m.w;c=c+m.x-2;if(this.isLtr){if(k.headerColumn=!0,!p(f,"first")||d>a+g/2)c+=g,k.headerColumn=!1}else k.headerColumn=
!1,p(f,"first")&&d>a+g/2&&(c+=g,k.headerColumn=!0);b.style(k,{position:"absolute",cursor:"col-resize",display:"block",width:"4px",backgroundColor:"transparent",top:e.y+m.y+"px",left:c+"px",height:m.h+"px"});this.activeCell=f}else b.style(k,{display:"none",top:"-10000px"})});this.connect(k,"onmousedown",function(a){var e=b.position(l.iframe,!0),c=b.position(t(this.activeCell));this.isDragging=!0;b.style(l.editNode,{cursor:"col-resize"});b.style(k,{width:"1px",left:a.clientX+"px",top:e.y+c.y+"px",height:c.h+
"px",backgroundColor:"#777"})});this.connect(k,"onmouseup",function(a){var e=this.activeCell,c=b.position(e),d=c.w,h=c.x;c=w(e);var g=b.position(l.iframe).x,n=t(e),m=b.position(n),f=n.getAttribute("cellspacing");a=a.clientX;var v=x(e),q;if(!f||0>(f=parseInt(f,10)))f=2;if(c){var r=b.position(c);var y=r.x;r=r.w;var z=x(c)}this.isLtr?k.headerColumn?h=g+h+d-a:(h=a-g-h,c&&(q=g+y+r-a-f)):k.headerColumn?h=a-g-h:(h=g+h+d-a,c&&(q=a-g-y-f));this.isDragging=!1;u(v,h);c&&(k.headerColumn||u(z,q));(k.headerColumn&&
p(e,"first")||p(e,"last"))&&b.marginBox(n,{w:m.w+h-d});u(v,b.position(e).w);c&&u(z,b.position(c).w);b.style(l.editNode,{cursor:"auto"});b.style(k,{display:"none",top:"-10000px"});this.activeCell=null})}))}});b.subscribe(B._scopeName+".Editor.getPlugin",null,function(l){if(!l.plugin&&l.args&&l.args.command){var p=l.args.command.charAt(0).toLowerCase()+l.args.command.substring(1,l.args.command.length);"resizeTableColumn"==p&&(l.plugin=new A({commandName:p}))}});return A});