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 var listeners = false; ;
26 if (config & config.listeners) {
27 listeners= config.listeners;
28 delete config.listeners;
30 Roo.apply(this, config);
32 if(this.containerScroll){
33 Roo.dd.ScrollManager.register(this.el);
37 * @scope Roo.dd.DropTarget
42 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source is now over the
43 * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element
44 * and returns the dropAllowed config value. This method should be overridden if drop validation is required.
46 * IMPORTANT : it should set this.overClass and this.dropAllowed
48 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
49 * @param {Event} e The event
50 * @param {Object} data An object containing arbitrary data supplied by the drag source
56 * The function a {@link Roo.dd.DragSource} calls continuously while it is being dragged over the target.
57 * This method will be called on every mouse movement while the drag source is over the drop target.
58 * This default implementation simply returns the dropAllowed config value.
60 * IMPORTANT : it should set this.dropAllowed
62 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
63 * @param {Event} e The event
64 * @param {Object} data An object containing arbitrary data supplied by the drag source
70 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the source has been dragged
71 * out of the target without dropping. This default implementation simply removes the CSS class specified by
72 * overClass (if any) from the drop element.
73 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
74 * @param {Event} e The event
75 * @param {Object} data An object containing arbitrary data supplied by the drag source
81 * The function a {@link Roo.dd.DragSource} calls once to notify this drop target that the dragged item has
82 * been dropped on it. This method has no default implementation and returns false, so you must provide an
83 * implementation that does something to process the drop event and returns true so that the drag source's
84 * repair action does not run.
86 * IMPORTANT : it should set this.success
88 * @param {Roo.dd.DragSource} source The drag source that was dragged over this drop target
89 * @param {Event} e The event
90 * @param {Object} data An object containing arbitrary data supplied by the drag source
96 Roo.dd.DropTarget.superclass.constructor.call( this,
98 this.ddGroup || this.group,
101 listeners : listeners || {}
109 Roo.extend(Roo.dd.DropTarget, Roo.dd.DDTarget, {
111 * @cfg {String} overClass
112 * The CSS class applied to the drop target element while the drag source is over it (defaults to "").
115 * @cfg {String} ddGroup
116 * The drag drop group to handle drop events for
120 * @cfg {String} dropAllowed
121 * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok").
123 dropAllowed : "x-dd-drop-ok",
125 * @cfg {String} dropNotAllowed
126 * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop").
128 dropNotAllowed : "x-dd-drop-nodrop",
130 * @cfg {boolean} success
131 * set this after drop listener..
135 * @cfg {boolean} valid
136 * if the drop point is valid for over/enter..
143 isNotifyTarget : true,
148 notifyEnter : function(dd, e, data){
150 this.fireEvent('enter', this, dd, e, data);
152 this.el.addClass(this.overClass);
154 return this.valid ? this.dropAllowed : this.dropNotAllowed;
160 notifyOver : function(dd, e, data){
162 this.fireEvent('over', this, dd, e, data);
163 return this.valid ? this.dropAllowed : this.dropNotAllowed;
169 notifyOut : function(dd, e, data){
170 this.fireEvent('out', this, dd, e, data);
172 this.el.removeClass(this.overClass);
179 notifyDrop : function(dd, e, data){
180 this.success = false;
181 this.fireEvent('drop', this, dd, e, data);