4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
14 * @class Roo.dd.DropTarget
15 * @extends Roo.dd.DDTarget
16 * A simple class that provides the basic implementation needed to make any element a drop target that can have
17 * draggable items dropped onto it. The drop has no effect until an implementation of notifyDrop is provided.
19 * @param {String/HTMLElement/Element} el The container element
20 * @param {Object} config
22 Roo.dd.DropTarget = function(el, config){
23 this.el = Roo.get(el);
25 Roo.apply(this, config);
27 if(this.containerScroll){
28 Roo.dd.ScrollManager.register(this.el);
34 * @scope Roo.BasicLayoutRegion
40 * Fires when the layout for this region is changed.
41 * @param {Roo.LayoutRegion} this
45 * @event visibilitychange
46 * Fires when this region is shown or hidden
47 * @param {Roo.LayoutRegion} this
48 * @param {Boolean} visibility true or false
50 "visibilitychange" : true,
52 Roo.dd.DropTarget.superclass.constructor.call( this,
54 this.ddGroup || this.group,
59 * @scope Roo.dd.DropTarget
64 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source is now over the
65 * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element
66 * and returns the dropAllowed config value. This method should be overridden if drop validation is required.
68 * IMPORTANT : it should set this.overClass and this.dropAllowed
70 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
71 * @param {Event} e The event
72 * @param {Object} data An object containing arbitrary data supplied by the drag source
78 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source is now over the
79 * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element
80 * and returns the dropAllowed config value. This method should be overridden if drop validation is required.
84 * The function a {@link Roo.dd.DragSource} calls continuously while it is being dragged over the target.
85 * This method will be called on every mouse movement while the drag source is over the drop target.
86 * This default implementation simply returns the dropAllowed config value.
88 * IMPORTANT : it should set this.dropAllowed
90 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
91 * @param {Event} e The event
92 * @param {Object} data An object containing arbitrary data supplied by the drag source
105 Roo.extend(Roo.dd.DropTarget, Roo.dd.DDTarget, {
107 * @cfg {String} overClass
108 * The CSS class applied to the drop target element while the drag source is over it (defaults to "").
111 * @cfg {String} dropAllowed
112 * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok").
114 dropAllowed : "x-dd-drop-ok",
116 * @cfg {String} dropNotAllowed
117 * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop").
119 dropNotAllowed : "x-dd-drop-nodrop",
125 isNotifyTarget : true,
128 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source is now over the
129 * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element
130 * and returns the dropAllowed config value. This method should be overridden if drop validation is required.
131 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
132 * @param {Event} e The event
133 * @param {Object} data An object containing arbitrary data supplied by the drag source
134 * @return {String} status The CSS class that communicates the drop status back to the source so that the
135 * underlying {@link Roo.dd.StatusProxy} can be updated
137 notifyEnter : function(dd, e, data){
139 this.el.addClass(this.overClass);
141 return this.dropAllowed;
145 * The function a {@link Roo.dd.DragSource} calls continuously while it is being dragged over the target.
146 * This method will be called on every mouse movement while the drag source is over the drop target.
147 * This default implementation simply returns the dropAllowed config value.
148 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
149 * @param {Event} e The event
150 * @param {Object} data An object containing arbitrary data supplied by the drag source
151 * @return {String} status The CSS class that communicates the drop status back to the source so that the
152 * underlying {@link Roo.dd.StatusProxy} can be updated
154 notifyOver : function(dd, e, data){
155 return this.dropAllowed;
159 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source has been dragged
160 * out of the target without dropping. This default implementation simply removes the CSS class specified by
161 * overClass (if any) from the drop element.
162 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
163 * @param {Event} e The event
164 * @param {Object} data An object containing arbitrary data supplied by the drag source
166 notifyOut : function(dd, e, data){
168 this.el.removeClass(this.overClass);
173 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the dragged item has
174 * been dropped on it. This method has no default implementation and returns false, so you must provide an
175 * implementation that does something to process the drop event and returns true so that the drag source's
176 * repair action does not run.
177 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
178 * @param {Event} e The event
179 * @param {Object} data An object containing arbitrary data supplied by the drag source
180 * @return {Boolean} True if the drop was valid, else false
182 notifyDrop : function(dd, e, data){