2 * Ext JS Library 2.2.1
\r
3 * Copyright(c) 2006-2009, Ext JS, LLC.
\r
4 * licensing@extjs.com
\r
6 * http://extjs.com/license
\r
10 * @class Ext.dd.DropZone
\r
11 * @extends Ext.dd.DropTarget
\r
12 * This class provides a container DD instance that proxies for multiple child node targets.<br />
\r
13 * By default, this class requires that child nodes accepting drop are registered with {@link Ext.dd.Registry}.
\r
15 * @param {Mixed} el The container element
\r
16 * @param {Object} config
\r
18 Ext.dd.DropZone = function(el, config){
\r
19 Ext.dd.DropZone.superclass.constructor.call(this, el, config);
\r
22 Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
\r
24 * Returns a custom data object associated with the DOM node that is the target of the event. By default
\r
25 * this looks up the event target in the {@link Ext.dd.Registry}, although you can override this method to
\r
26 * provide your own custom lookup.
\r
27 * @param {Event} e The event
\r
28 * @return {Object} data The custom data
\r
30 getTargetFromEvent : function(e){
\r
31 return Ext.dd.Registry.getTargetFromEvent(e);
\r
35 * Called internally when the DropZone determines that a {@link Ext.dd.DragSource} has entered a drop node
\r
36 * that it has registered. This method has no default implementation and should be overridden to provide
\r
37 * node-specific processing if necessary.
\r
38 * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
\r
39 * {@link #getTargetFromEvent} for this node)
\r
40 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
41 * @param {Event} e The event
\r
42 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
44 onNodeEnter : function(n, dd, e, data){
\r
49 * Called internally while the DropZone determines that a {@link Ext.dd.DragSource} is over a drop node
\r
50 * that it has registered. The default implementation returns this.dropNotAllowed, so it should be
\r
51 * overridden to provide the proper feedback.
\r
52 * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
\r
53 * {@link #getTargetFromEvent} for this node)
\r
54 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
55 * @param {Event} e The event
\r
56 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
57 * @return {String} status The CSS class that communicates the drop status back to the source so that the
\r
58 * underlying {@link Ext.dd.StatusProxy} can be updated
\r
60 onNodeOver : function(n, dd, e, data){
\r
61 return this.dropAllowed;
\r
65 * Called internally when the DropZone determines that a {@link Ext.dd.DragSource} has been dragged out of
\r
66 * the drop node without dropping. This method has no default implementation and should be overridden to provide
\r
67 * node-specific processing if necessary.
\r
68 * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
\r
69 * {@link #getTargetFromEvent} for this node)
\r
70 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
71 * @param {Event} e The event
\r
72 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
74 onNodeOut : function(n, dd, e, data){
\r
79 * Called internally when the DropZone determines that a {@link Ext.dd.DragSource} has been dropped onto
\r
80 * the drop node. The default implementation returns false, so it should be overridden to provide the
\r
81 * appropriate processing of the drop event and return true so that the drag source's repair action does not run.
\r
82 * @param {Object} nodeData The custom data associated with the drop node (this is the same value returned from
\r
83 * {@link #getTargetFromEvent} for this node)
\r
84 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
85 * @param {Event} e The event
\r
86 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
87 * @return {Boolean} True if the drop was valid, else false
\r
89 onNodeDrop : function(n, dd, e, data){
\r
94 * Called internally while the DropZone determines that a {@link Ext.dd.DragSource} is being dragged over it,
\r
95 * but not over any of its registered drop nodes. The default implementation returns this.dropNotAllowed, so
\r
96 * it should be overridden to provide the proper feedback if necessary.
\r
97 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
98 * @param {Event} e The event
\r
99 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
100 * @return {String} status The CSS class that communicates the drop status back to the source so that the
\r
101 * underlying {@link Ext.dd.StatusProxy} can be updated
\r
103 onContainerOver : function(dd, e, data){
\r
104 return this.dropNotAllowed;
\r
108 * Called internally when the DropZone determines that a {@link Ext.dd.DragSource} has been dropped on it,
\r
109 * but not on any of its registered drop nodes. The default implementation returns false, so it should be
\r
110 * overridden to provide the appropriate processing of the drop event if you need the drop zone itself to
\r
111 * be able to accept drops. It should return true when valid so that the drag source's repair action does not run.
\r
112 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
113 * @param {Event} e The event
\r
114 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
115 * @return {Boolean} True if the drop was valid, else false
\r
117 onContainerDrop : function(dd, e, data){
\r
122 * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the source is now over
\r
123 * the zone. The default implementation returns this.dropNotAllowed and expects that only registered drop
\r
124 * nodes can process drag drop operations, so if you need the drop zone itself to be able to process drops
\r
125 * you should override this method and provide a custom implementation.
\r
126 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
127 * @param {Event} e The event
\r
128 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
129 * @return {String} status The CSS class that communicates the drop status back to the source so that the
\r
130 * underlying {@link Ext.dd.StatusProxy} can be updated
\r
132 notifyEnter : function(dd, e, data){
\r
133 return this.dropNotAllowed;
\r
137 * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the drop zone.
\r
138 * This method will be called on every mouse movement while the drag source is over the drop zone.
\r
139 * It will call {@link #onNodeOver} while the drag source is over a registered node, and will also automatically
\r
140 * delegate to the appropriate node-specific methods as necessary when the drag source enters and exits
\r
141 * registered nodes ({@link #onNodeEnter}, {@link #onNodeOut}). If the drag source is not currently over a
\r
142 * registered node, it will call {@link #onContainerOver}.
\r
143 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
144 * @param {Event} e The event
\r
145 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
146 * @return {String} status The CSS class that communicates the drop status back to the source so that the
\r
147 * underlying {@link Ext.dd.StatusProxy} can be updated
\r
149 notifyOver : function(dd, e, data){
\r
150 var n = this.getTargetFromEvent(e);
\r
151 if(!n){ // not over valid drop target
\r
152 if(this.lastOverNode){
\r
153 this.onNodeOut(this.lastOverNode, dd, e, data);
\r
154 this.lastOverNode = null;
\r
156 return this.onContainerOver(dd, e, data);
\r
158 if(this.lastOverNode != n){
\r
159 if(this.lastOverNode){
\r
160 this.onNodeOut(this.lastOverNode, dd, e, data);
\r
162 this.onNodeEnter(n, dd, e, data);
\r
163 this.lastOverNode = n;
\r
165 return this.onNodeOver(n, dd, e, data);
\r
169 * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the source has been dragged
\r
170 * out of the zone without dropping. If the drag source is currently over a registered node, the notification
\r
171 * will be delegated to {@link #onNodeOut} for node-specific handling, otherwise it will be ignored.
\r
172 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
\r
173 * @param {Event} e The event
\r
174 * @param {Object} data An object containing arbitrary data supplied by the drag zone
\r
176 notifyOut : function(dd, e, data){
\r
177 if(this.lastOverNode){
\r
178 this.onNodeOut(this.lastOverNode, dd, e, data);
\r
179 this.lastOverNode = null;
\r
184 * The function a {@link Ext.dd.DragSource} calls once to notify this drop zone that the dragged item has
\r
185 * been dropped on it. The drag zone will look up the target node based on the event passed in, and if there
\r
186 * is a node registered for that event, it will delegate to {@link #onNodeDrop} for node-specific handling,
\r
187 * otherwise it will call {@link #onContainerDrop}.
\r
188 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop zone
\r
189 * @param {Event} e The event
\r
190 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
191 * @return {Boolean} True if the drop was valid, else false
\r
193 notifyDrop : function(dd, e, data){
\r
194 if(this.lastOverNode){
\r
195 this.onNodeOut(this.lastOverNode, dd, e, data);
\r
196 this.lastOverNode = null;
\r
198 var n = this.getTargetFromEvent(e);
\r
200 this.onNodeDrop(n, dd, e, data) :
\r
201 this.onContainerDrop(dd, e, data);
\r
205 triggerCacheRefresh : function(){
\r
206 Ext.dd.DDM.refreshCache(this.groups);
\r