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