1
2
3
4
5
6
7
8
| //>>built
| define(["dojo","dijit","dojox","./TablePlugins"],function(b,v,B,A){var q=b.declare("dojox.editor.plugins.ResizeTableColumn",A,{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(m){function r(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 q(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 y(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(a,b){if(!b)return 0;if("medium"==b)return 1;if(b.slice&&"px"==b.slice(-2))return parseFloat(b);with(a){a=style.left;var c=runtimeStyle.left;runtimeStyle.left=currentStyle.left;try{style.left=b,b=style.pixelLeft}catch(p){b=
| 0}style.left=a;runtimeStyle.left=c}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=m;this.editor.customUndo=!0;this.onEditorLoaded();m.onLoadDeferred.addCallback(b.hitch(this,function(){this.connect(this.editor.editNode,"onmousemove",function(a){var e=b.position(m.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;var g=q(f),l,k,n=b.position(t(f).parentNode),f=n.x,n=n.w;g&&(l=b.position(g),k=l.x,l=l.w);(this.isLtr&&(h.headerColumn&&g&&f<d&&d<e+a||!g&&e<d&&d<f+n||g&&e<d&&d<k+l)||!this.isLtr&&(h.headerColumn&&g&&f>d&&d>e||!g&&e+a>d&&d>f||g&&e+a>d&&d>k))&&b.style(h,{left:c+d+"px"})}else if(k=a.target,k.tagName&&"td"==k.tagName.toLowerCase()){l=b.position(k);a=l.x;g=l.w;c=c+l.x-2;if(this.isLtr){if(h.headerColumn=!0,!r(k,"first")||d>a+g/2)c+=g,h.headerColumn=!1}else h.headerColumn=!1,
| r(k,"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+l.y+"px",left:c+"px",height:l.h+"px"});this.activeCell=k}else b.style(h,{display:"none",top:"-10000px"})});this.connect(h,"onmousedown",function(a){var e=b.position(m.iframe,!0),c=b.position(t(this.activeCell));this.isDragging=!0;b.style(m.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=q(e),g,l,k=b.position(m.iframe).x,n=t(e),v=b.position(n),p=n.getAttribute("cellspacing");a=a.clientX;var z=y(e),w,x;if(!p||0>(p=parseInt(p,10)))p=2;c&&(g=b.position(c),l=g.x,g=g.w,w=y(c));this.isLtr?h.headerColumn?f=k+f+d-a:(f=a-k-f,c&&(x=k+l+g-a-p)):h.headerColumn?f=a-k-f:(f=k+f+d-a,c&&(x=a-k-l-p));this.isDragging=!1;u(z,f);c&&(h.headerColumn||u(w,x));(h.headerColumn&&r(e,"first")||
| r(e,"last"))&&b.marginBox(n,{w:v.w+f-d});u(z,b.position(e).w);c&&u(w,b.position(c).w);b.style(m.editNode,{cursor:"auto"});b.style(h,{display:"none",top:"-10000px"});this.activeCell=null})}))}});b.subscribe(v._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);"resizeTableColumn"==m&&(b.plugin=new q({commandName:m}))}});return q});
|
|