root / trunk / web / dojo / dojox / mdnd / PureSource.js
History | View | Annotate | Download (2.48 KB)
1 | 9 | andrej.cim | /*
|
---|---|---|---|
2 | Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
||
3 | Available via Academic Free License >= 2.1 OR the modified BSD license.
|
||
4 | see: http://dojotoolkit.org/license for details
|
||
5 | */
|
||
6 | |||
7 | |||
8 | if(!dojo._hasResource["dojox.mdnd.PureSource"]){ |
||
9 | dojo._hasResource["dojox.mdnd.PureSource"]=true; |
||
10 | dojo.provide("dojox.mdnd.PureSource");
|
||
11 | dojo.require("dojo.dnd.Selector");
|
||
12 | dojo.require("dojo.dnd.Manager");
|
||
13 | dojo.declare("dojox.mdnd.PureSource",dojo.dnd.Selector,{horizontal:false,copyOnly:true,skipForm:false,withHandles:false,isSource:true,targetState:"Disabled",generateText:true,constructor:function(_1,_2){ |
||
14 | dojo.mixin(this,dojo.mixin({},_2));
|
||
15 | var _3=this.accept; |
||
16 | this.isDragging=false; |
||
17 | this.mouseDown=false; |
||
18 | this.sourceState=""; |
||
19 | dojo.addClass(this.node,"dojoDndSource"); |
||
20 | if(this.horizontal){ |
||
21 | dojo.addClass(this.node,"dojoDndHorizontal"); |
||
22 | } |
||
23 | this.topics=[dojo.subscribe("/dnd/cancel",this,"onDndCancel"),dojo.subscribe("/dnd/drop",this,"onDndCancel")]; |
||
24 | },onDndCancel:function(){ |
||
25 | this.isDragging=false; |
||
26 | this.mouseDown=false; |
||
27 | delete this.mouseButton; |
||
28 | },copyState:function(_4){ |
||
29 | return this.copyOnly||_4; |
||
30 | },destroy:function(){ |
||
31 | dojox.mdnd.PureSource.superclass.destroy.call(this);
|
||
32 | dojo.forEach(this.topics,dojo.unsubscribe);
|
||
33 | this.targetAnchor=null; |
||
34 | },markupFactory:function(_5,_6){ |
||
35 | _5._skipStartup=true;
|
||
36 | return new dojox.mdnd.PureSource(_6,_5); |
||
37 | },onMouseMove:function(e){ |
||
38 | if(this.isDragging){ |
||
39 | return;
|
||
40 | } |
||
41 | dojox.mdnd.PureSource.superclass.onMouseMove.call(this,e);
|
||
42 | var m=dojo.dnd.manager();
|
||
43 | if(this.mouseDown&&!this.isDragging&&this.isSource){ |
||
44 | var _7=this.getSelectedNodes(); |
||
45 | if(_7.length){
|
||
46 | m.startDrag(this,_7,this.copyState(dojo.isCopyKey(e))); |
||
47 | this.isDragging=true; |
||
48 | } |
||
49 | } |
||
50 | },onMouseDown:function(e){ |
||
51 | if(this._legalMouseDown(e)&&(!this.skipForm||!dojo.dnd.isFormElement(e))){ |
||
52 | this.mouseDown=true; |
||
53 | this.mouseButton=e.button;
|
||
54 | dojox.mdnd.PureSource.superclass.onMouseDown.call(this,e);
|
||
55 | } |
||
56 | },onMouseUp:function(e){ |
||
57 | if(this.mouseDown){ |
||
58 | this.mouseDown=false; |
||
59 | dojox.mdnd.PureSource.superclass.onMouseUp.call(this,e);
|
||
60 | } |
||
61 | },onOverEvent:function(){ |
||
62 | dojox.mdnd.PureSource.superclass.onOverEvent.call(this);
|
||
63 | dojo.dnd.manager().overSource(this);
|
||
64 | },onOutEvent:function(){ |
||
65 | dojox.mdnd.PureSource.superclass.onOutEvent.call(this);
|
||
66 | dojo.dnd.manager().outSource(this);
|
||
67 | },_markDndStatus:function(_8){ |
||
68 | this._changeState("Source",_8?"Copied":"Moved"); |
||
69 | },_legalMouseDown:function(e){ |
||
70 | if(!this.withHandles){ |
||
71 | return true; |
||
72 | } |
||
73 | for(var _9=e.target;_9&&!dojo.hasClass(_9,"dojoDndItem");_9=_9.parentNode){ |
||
74 | if(dojo.hasClass(_9,"dojoDndHandle")){ |
||
75 | return true; |
||
76 | } |
||
77 | } |
||
78 | return false; |
||
79 | }}); |
||
80 | } |