3 <title>The source code</title>
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 <body onload="prettyPrint();">
8 <pre class="prettyprint lang-js">/*!
10 * Copyright(c) 2006-2009 Ext JS, LLC
12 * http://www.extjs.com/license
14 <div id="cls-Ext.dd.DropTarget"></div>/**
\r
15 * @class Ext.dd.DropTarget
\r
16 * @extends Ext.dd.DDTarget
\r
17 * A simple class that provides the basic implementation needed to make any element a drop target that can have
\r
18 * draggable items dropped onto it. The drop has no effect until an implementation of notifyDrop is provided.
\r
20 * @param {Mixed} el The container element
\r
21 * @param {Object} config
\r
23 Ext.dd.DropTarget = function(el, config){
\r
24 this.el = Ext.get(el);
\r
26 Ext.apply(this, config);
\r
28 if(this.containerScroll){
\r
29 Ext.dd.ScrollManager.register(this.el);
\r
32 Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
\r
37 Ext.extend(Ext.dd.DropTarget, Ext.dd.DDTarget, {
\r
38 <div id="cfg-Ext.dd.DropTarget-ddGroup"></div>/**
\r
39 * @cfg {String} ddGroup
\r
40 * A named drag drop group to which this object belongs. If a group is specified, then this object will only
\r
41 * interact with other drag drop objects in the same group (defaults to undefined).
\r
43 <div id="cfg-Ext.dd.DropTarget-overClass"></div>/**
\r
44 * @cfg {String} overClass
\r
45 * The CSS class applied to the drop target element while the drag source is over it (defaults to "").
\r
47 <div id="cfg-Ext.dd.DropTarget-dropAllowed"></div>/**
\r
48 * @cfg {String} dropAllowed
\r
49 * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok").
\r
51 dropAllowed : "x-dd-drop-ok",
\r
52 <div id="cfg-Ext.dd.DropTarget-dropNotAllowed"></div>/**
\r
53 * @cfg {String} dropNotAllowed
\r
54 * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop").
\r
56 dropNotAllowed : "x-dd-drop-nodrop",
\r
62 isNotifyTarget : true,
\r
64 <div id="method-Ext.dd.DropTarget-notifyEnter"></div>/**
\r
65 * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source is now over the
\r
66 * target. This default implementation adds the CSS class specified by overClass (if any) to the drop element
\r
67 * and returns the dropAllowed config value. This method should be overridden if drop validation is required.
\r
68 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
\r
69 * @param {Event} e The event
\r
70 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
71 * @return {String} status The CSS class that communicates the drop status back to the source so that the
\r
72 * underlying {@link Ext.dd.StatusProxy} can be updated
\r
74 notifyEnter : function(dd, e, data){
\r
76 this.el.addClass(this.overClass);
\r
78 return this.dropAllowed;
\r
81 <div id="method-Ext.dd.DropTarget-notifyOver"></div>/**
\r
82 * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the target.
\r
83 * This method will be called on every mouse movement while the drag source is over the drop target.
\r
84 * This default implementation simply returns the dropAllowed config value.
\r
85 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
\r
86 * @param {Event} e The event
\r
87 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
88 * @return {String} status The CSS class that communicates the drop status back to the source so that the
\r
89 * underlying {@link Ext.dd.StatusProxy} can be updated
\r
91 notifyOver : function(dd, e, data){
\r
92 return this.dropAllowed;
\r
95 <div id="method-Ext.dd.DropTarget-notifyOut"></div>/**
\r
96 * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source has been dragged
\r
97 * out of the target without dropping. This default implementation simply removes the CSS class specified by
\r
98 * overClass (if any) from the drop element.
\r
99 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
\r
100 * @param {Event} e The event
\r
101 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
103 notifyOut : function(dd, e, data){
\r
104 if(this.overClass){
\r
105 this.el.removeClass(this.overClass);
\r
109 <div id="method-Ext.dd.DropTarget-notifyDrop"></div>/**
\r
110 * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the dragged item has
\r
111 * been dropped on it. This method has no default implementation and returns false, so you must provide an
\r
112 * implementation that does something to process the drop event and returns true so that the drag source's
\r
113 * repair action does not run.
\r
114 * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
\r
115 * @param {Event} e The event
\r
116 * @param {Object} data An object containing arbitrary data supplied by the drag source
\r
117 * @return {Boolean} True if the drop was valid, else false
\r
119 notifyDrop : function(dd, e, data){
\r