3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
8 * @class Ext.dd.DropTarget
9 * @extends Ext.dd.DDTarget
10 * A simple class that provides the basic implementation needed to make any element a drop target that can have
11 * draggable items dropped onto it. The drop has no effect until an implementation of notifyDrop is provided.
13 * @param {Mixed} el The container element
14 * @param {Object} config
16 Ext.dd.DropTarget = function(el, config){
17 this.el = Ext.get(el);
19 Ext.apply(this, config);
21 if(this.containerScroll){
22 Ext.dd.ScrollManager.register(this.el);
25 Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
30 Ext.extend(Ext.dd.DropTarget, Ext.dd.DDTarget, {
32 * @cfg {String} ddGroup
33 * A named drag drop group to which this object belongs. If a group is specified, then this object will only
34 * interact with other drag drop objects in the same group (defaults to undefined).
37 * @cfg {String} overClass
38 * The CSS class applied to the drop target element while the drag source is over it (defaults to "").
41 * @cfg {String} dropAllowed
42 * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok").
44 dropAllowed : "x-dd-drop-ok",
46 * @cfg {String} dropNotAllowed
47 * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop").
49 dropNotAllowed : "x-dd-drop-nodrop",
55 isNotifyTarget : true,
58 * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source is now over the
59 * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element
60 * and returns the dropAllowed config value. This method should be overridden if drop validation is required.
61 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
62 * @param {Event} e The event
63 * @param {Object} data An object containing arbitrary data supplied by the drag source
64 * @return {String} status The CSS class that communicates the drop status back to the source so that the
65 * underlying {@link Ext.dd.StatusProxy} can be updated
67 notifyEnter : function(dd, e, data){
69 this.el.addClass(this.overClass);
71 return this.dropAllowed;
75 * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the target.
76 * This method will be called on every mouse movement while the drag source is over the drop target.
77 * This default implementation simply returns the dropAllowed config value.
78 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
79 * @param {Event} e The event
80 * @param {Object} data An object containing arbitrary data supplied by the drag source
81 * @return {String} status The CSS class that communicates the drop status back to the source so that the
82 * underlying {@link Ext.dd.StatusProxy} can be updated
84 notifyOver : function(dd, e, data){
85 return this.dropAllowed;
89 * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source has been dragged
90 * out of the target without dropping. This default implementation simply removes the CSS class specified by
91 * overClass (if any) from the drop element.
92 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
93 * @param {Event} e The event
94 * @param {Object} data An object containing arbitrary data supplied by the drag source
96 notifyOut : function(dd, e, data){
98 this.el.removeClass(this.overClass);
103 * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the dragged item has
104 * been dropped on it. This method has no default implementation and returns false, so you must provide an
105 * implementation that does something to process the drop event and returns true so that the drag source's
106 * repair action does not run.
107 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
108 * @param {Event} e The event
109 * @param {Object} data An object containing arbitrary data supplied by the drag source
110 * @return {Boolean} True if the drop was valid, else false
112 notifyDrop : function(dd, e, data){