1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-tree.ViewDDPlugin'>/**
2 </span> * @class Ext.tree.ViewDDPlugin
3 * @extends Ext.AbstractPlugin
4 * <p>This plugin provides drag and/or drop functionality for a TreeView.</p>
5 * <p>It creates a specialized instance of {@link Ext.dd.DragZone DragZone} which knows how to drag out of a {@link Ext.tree.View TreeView}
6 * and loads the data object which is passed to a cooperating {@link Ext.dd.DragZone DragZone}'s methods with the following properties:<ul>
7 * <li>copy : Boolean
8 * <div class="sub-desc">The value of the TreeView's <code>copy</code> property, or <code>true</code> if the TreeView was configured
9 * with <code>allowCopy: true</code> <u>and</u> the control key was pressed when the drag operation was begun.</div></li>
10 * <li>view : TreeView
11 * <div class="sub-desc">The source TreeView from which the drag originated.</div></li>
12 * <li>ddel : HtmlElement
13 * <div class="sub-desc">The drag proxy element which moves with the mouse</div></li>
14 * <li>item : HtmlElement
15 * <div class="sub-desc">The TreeView node upon which the mousedown event was registered.</div></li>
16 * <li>records : Array
17 * <div class="sub-desc">An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source TreeView.</div></li>
18 * </ul></p>
19 * <p>It also creates a specialized instance of {@link Ext.dd.DropZone} which cooperates with other DropZones which are members of the same
20 * ddGroup which processes such data objects.</p>
21 * <p>Adding this plugin to a view means that two new events may be fired from the client TreeView, <code>{@link #event-beforedrop beforedrop}</code> and
22 * <code>{@link #event-drop drop}</code></p>
24 Ext.define('Ext.tree.plugin.TreeViewDragDrop', {
25 extend: 'Ext.AbstractPlugin',
26 alias: 'plugin.treeviewdragdrop',
29 'Ext.tree.ViewDragZone',
30 'Ext.tree.ViewDropZone'
33 <span id='Ext-tree.ViewDDPlugin-event-beforedrop'> /**
34 </span> * @event beforedrop
35 * <p><b>This event is fired through the TreeView. Add listeners to the TreeView object</b></p>
36 * <p>Fired when a drop gesture has been triggered by a mouseup event in a valid drop position in the TreeView.
37 * @param {HtmlElement} node The TreeView node <b>if any</b> over which the mouse was positioned.</p>
38 * <p>Returning <code>false</code> to this event signals that the drop gesture was invalid, and if the drag proxy
39 * will animate back to the point from which the drag began.</p>
40 * <p>Returning <code>0</code> To this event signals that the data transfer operation should not take place, but
41 * that the gesture was valid, and that the repair operation should not take place.</p>
42 * <p>Any other return value continues with the data transfer operation.</p>
43 * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone DragZone}'s
44 * {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:<ul>
45 * <li>copy : Boolean
46 * <div class="sub-desc">The value of the TreeView's <code>copy</code> property, or <code>true</code> if the TreeView was configured
47 * with <code>allowCopy: true</code> and the control key was pressed when the drag operation was begun</div></li>
48 * <li>view : TreeView
49 * <div class="sub-desc">The source TreeView from which the drag originated.</div></li>
50 * <li>ddel : HtmlElement
51 * <div class="sub-desc">The drag proxy element which moves with the mouse</div></li>
52 * <li>item : HtmlElement
53 * <div class="sub-desc">The TreeView node upon which the mousedown event was registered.</div></li>
54 * <li>records : Array
55 * <div class="sub-desc">An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source TreeView.</div></li>
57 * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.
58 * @param {String} dropPosition <code>"before"</code>, <code>"after"</code> or <code>"append"</code> depending on whether the mouse is above or below the midline of the node,
59 * or the node is a branch node which accepts new child nodes.
60 * @param {Function} dropFunction <p>A function to call to complete the data transfer operation and either move or copy Model instances from the source
61 * View's Store to the destination View's Store.</p>
62 * <p>This is useful when you want to perform some kind of asynchronous processing before confirming
63 * the drop, such as an {@link Ext.window.MessageBox#confirm confirm} call, or an Ajax request.</p>
64 * <p>Return <code>0</code> from this event handler, and call the <code>dropFunction</code> at any time to perform the data transfer.</p>
67 <span id='Ext-tree.ViewDDPlugin-event-drop'> /**
69 * <b>This event is fired through the TreeView. Add listeners to the TreeView object</b>
70 * Fired when a drop operation has been completed and the data has been moved or copied.
71 * @param {HtmlElement} node The TreeView node <b>if any</b> over which the mouse was positioned.
72 * @param {Object} data The data object gathered at mousedown time by the cooperating {@link Ext.dd.DragZone DragZone}'s
73 * {@link Ext.dd.DragZone#getDragData getDragData} method it contains the following properties:<ul>
74 * <li>copy : Boolean
75 * <div class="sub-desc">The value of the TreeView's <code>copy</code> property, or <code>true</code> if the TreeView was configured
76 * with <code>allowCopy: true</code> and the control key was pressed when the drag operation was begun</div></li>
77 * <li>view : TreeView
78 * <div class="sub-desc">The source TreeView from which the drag originated.</div></li>
79 * <li>ddel : HtmlElement
80 * <div class="sub-desc">The drag proxy element which moves with the mouse</div></li>
81 * <li>item : HtmlElement
82 * <div class="sub-desc">The TreeView node upon which the mousedown event was registered.</div></li>
83 * <li>records : Array
84 * <div class="sub-desc">An Array of {@link Ext.data.Model Model}s representing the selected data being dragged from the source TreeView.</div></li>
86 * @param {Ext.data.Model} overModel The Model over which the drop gesture took place.
87 * @param {String} dropPosition <code>"before"</code>, <code>"after"</code> or <code>"append"</code> depending on whether the mouse is above or below the midline of the node,
88 * or the node is a branch node which accepts new child nodes.
91 dragText : '{0} selected node{1}',
93 <span id='Ext-tree.ViewDDPlugin-cfg-allowParentInsert'> /**
94 </span> * @cfg {Boolean} allowParentInsert
95 * Allow inserting a dragged node between an expanded parent node and its first child that will become a
96 * sibling of the parent when dropped (defaults to false)
98 allowParentInserts: false,
100 <span id='Ext-tree.ViewDDPlugin-cfg-allowContainerDrop'> /**
101 </span> * @cfg {String} allowContainerDrop
102 * True if drops on the tree container (outside of a specific tree node) are allowed (defaults to false)
104 allowContainerDrops: false,
106 <span id='Ext-tree.ViewDDPlugin-cfg-appendOnly'> /**
107 </span> * @cfg {String} appendOnly
108 * True if the tree should only allow append drops (use for trees which are sorted, defaults to false)
112 <span id='Ext-tree.ViewDDPlugin-cfg-ddGroup'> /**
113 </span> * @cfg {String} ddGroup
114 * A named drag drop group to which this object belongs. If a group is specified, then both the DragZones and DropZone
115 * used by this plugin will only interact with other drag drop objects in the same group (defaults to 'TreeDD').
117 ddGroup : "TreeDD",
119 <span id='Ext-tree.ViewDDPlugin-cfg-dragGroup'> /**
120 </span> * @cfg {String} dragGroup
121 * <p>The ddGroup to which the DragZone will belong.</p>
122 * <p>This defines which other DropZones the DragZone will interact with. Drag/DropZones only interact with other Drag/DropZones
123 * which are members of the same ddGroup.</p>
126 <span id='Ext-tree.ViewDDPlugin-cfg-dropGroup'> /**
127 </span> * @cfg {String} dropGroup
128 * <p>The ddGroup to which the DropZone will belong.</p>
129 * <p>This defines which other DragZones the DropZone will interact with. Drag/DropZones only interact with other Drag/DropZones
130 * which are members of the same ddGroup.</p>
133 <span id='Ext-tree.ViewDDPlugin-cfg-expandDelay'> /**
134 </span> * @cfg {String} expandDelay
135 * The delay in milliseconds to wait before expanding a target tree node while dragging a droppable node
136 * over the target (defaults to 1000)
140 <span id='Ext-tree.ViewDDPlugin-cfg-enableDrop'> /**
141 </span> * @cfg {Boolean} enableDrop
142 * <p>Defaults to <code>true</code></p>
143 * <p>Set to <code>false</code> to disallow the View from accepting drop gestures</p>
147 <span id='Ext-tree.ViewDDPlugin-cfg-enableDrag'> /**
148 </span> * @cfg {Boolean} enableDrag
149 * <p>Defaults to <code>true</code></p>
150 * <p>Set to <code>false</code> to disallow dragging items from the View </p>
154 <span id='Ext-tree.ViewDDPlugin-cfg-nodeHighlightColor'> /**
155 </span> * @cfg {String} nodeHighlightColor The color to use when visually highlighting the dragged
156 * or dropped node (defaults to 'c3daf9' - light blue). The color must be a 6 digit hex value, without
157 * a preceding '#'. See also {@link #nodeHighlightOnDrop} and {@link #nodeHighlightOnRepair}.
159 nodeHighlightColor: 'c3daf9',
161 <span id='Ext-tree.ViewDDPlugin-cfg-nodeHighlightOnDrop'> /**
162 </span> * @cfg {Boolean} nodeHighlightOnDrop Whether or not to highlight any nodes after they are
163 * successfully dropped on their target. Defaults to the value of `Ext.enableFx`.
164 * See also {@link #nodeHighlightColor} and {@link #nodeHighlightOnRepair}.
167 nodeHighlightOnDrop: Ext.enableFx,
169 <span id='Ext-tree.ViewDDPlugin-cfg-nodeHighlightOnRepair'> /**
170 </span> * @cfg {Boolean} nodeHighlightOnRepair Whether or not to highlight any nodes after they are
171 * repaired from an unsuccessful drag/drop. Defaults to the value of `Ext.enableFx`.
172 * See also {@link #nodeHighlightColor} and {@link #nodeHighlightOnDrop}.
175 nodeHighlightOnRepair: Ext.enableFx,
177 init : function(view) {
178 view.on('render', this.onViewRender, this, {single: true});
181 <span id='Ext-tree.ViewDDPlugin-method-destroy'> /**
183 * AbstractComponent calls destroy on all its plugins at destroy time.
185 destroy: function() {
186 Ext.destroy(this.dragZone, this.dropZone);
189 onViewRender : function(view) {
193 me.dragZone = Ext.create('Ext.tree.ViewDragZone', {
195 ddGroup: me.dragGroup || me.ddGroup,
196 dragText: me.dragText,
197 repairHighlightColor: me.nodeHighlightColor,
198 repairHighlight: me.nodeHighlightOnRepair
203 me.dropZone = Ext.create('Ext.tree.ViewDropZone', {
205 ddGroup: me.dropGroup || me.ddGroup,
206 allowContainerDrops: me.allowContainerDrops,
207 appendOnly: me.appendOnly,
208 allowParentInserts: me.allowParentInserts,
209 expandDelay: me.expandDelay,
210 dropHighlightColor: me.nodeHighlightColor,
211 dropHighlight: me.nodeHighlightOnDrop
215 });</pre></pre></body></html>