control-freak-ide/Code/client/build/davinci/dojo/dnd/Manager.js
plastic-hub-dev-node-saturn 538369cff7 latest
2021-05-12 18:35:18 +02:00

8 lines
3.0 KiB
JavaScript

//>>built
define("dojo/dnd/Manager","../_base/array ../_base/declare ../_base/lang ../_base/window ../dom-class ../Evented ../has ../keys ../on ../topic ../touch ./common ./autoscroll ./Avatar xide/mixins/EventedMixin xide/lodash xide/types/Types".split(" "),function(z,t,h,c,k,u,l,m,g,e,p,d,q,v,w,x,y){function r(a){a.preventDefault();a.stopPropagation()}var f=y.EVENTS,n=t("dojo.dnd.Manager",[u,w],{avatar:null,source:null,target:null,copy:null,constructor:function(){this.source=this.avatar=null;this.nodes=[];
this.copy=!0;this.target=null;this.canDropFlag=!1;this.events=[]},OFFSET_X:l("touch")?0:16,OFFSET_Y:l("touch")?-64:16,overSource:function(a){this.avatar&&(this.target=a&&"Disabled"!=a.targetState?a:null,this.canDropFlag=!!this.target,this.avatar.update());e.publish(f.ON_DND_SOURCE_OVER,a)},outSource:function(a){this.avatar?this.target==a&&(this.target=null,this.canDropFlag=!1,this.avatar.update(),e.publish(f.ON_DND_SOURCE_OVER,null)):e.publish(f.ON_DND_SOURCE_OVER,null)},startDrag:function(a,b,d){q.autoScrollStart(c.doc);
this.source=a;this.nodes=b;this.copy=!!d;this.avatar=this.makeAvatar();c.body().appendChild(this.avatar.node);e.publish("/dnd/start",a,b,this.copy);this.events=[g(c.doc,p.move,h.hitch(this,"onMouseMove")),g(c.doc,p.release,h.hitch(this,"onMouseUp")),g(c.doc,"keydown",h.hitch(this,"onKeyDown")),g(c.doc,"keyup",h.hitch(this,"onKeyUp")),g(c.doc,"dragstart",r),g(c.body(),"selectstart",r)];a="dojoDnd"+(d?"Copy":"Move");k.add(c.body(),a)},canDrop:function(a){a=!(!this.target||!a);this.canDropFlag!=a&&(this.canDropFlag=
a,this.avatar.update())},stopDrag:function(){k.remove(c.body(),["dojoDndCopy","dojoDndMove"]);x.invoke(this.events,"remove");this.events=[];this.avatar.destroy();this.source=this.target=this.avatar=null;this.nodes=[]},makeAvatar:function(){return new v(this)},updateAvatar:function(){this.avatar.update()},onMouseMove:function(a){var b=this.avatar;b&&(q.autoScrollNodes(a),b=b.node.style,b.left=a.pageX+this.OFFSET_X+"px",b.top=a.pageY+this.OFFSET_Y+"px",b=!!this.source.copyState(d.getCopyKeyState(a)),
this.copy!=b&&this._setCopyStatus(b));l("touch")&&a.preventDefault()},onMouseUp:function(a){if(this.avatar){if(this.target&&this.canDropFlag){var b=!!this.source.copyState(d.getCopyKeyState(a));e.publish(f.ON_DND_DROP_BEFORE,this.source,this.nodes,b,this.target,a);e.publish(f.ON_DND_DROP,this.source,this.nodes,b,this.target,a)}else e.publish(f.ON_DND_CANCEL);this.stopDrag()}},onKeyDown:function(a){if(this.avatar)switch(a.keyCode){case m.CTRL:a=!!this.source.copyState(!0);this.copy!=a&&this._setCopyStatus(a);
break;case m.ESCAPE:e.publish(f.ON_DND_CANCEL),this.stopDrag()}},onKeyUp:function(a){this.avatar&&a.keyCode==m.CTRL&&(a=!!this.source.copyState(!1),this.copy!=a&&this._setCopyStatus(a))},_setCopyStatus:function(a){this.copy=a;this.source._markDndStatus(this.copy);this.updateAvatar();k.replace(c.body(),"dojoDnd"+(this.copy?"Copy":"Move"),"dojoDnd"+(this.copy?"Move":"Copy"))}});d._manager=null;n.manager=d.manager=function(){d._manager||(d._manager=new n);return d._manager};return n});
//# sourceMappingURL=Manager.js.map