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