Upgrade to ExtJS 3.0.3 - Released 10/11/2009
[extjs.git] / docs / source / DropTarget.html
1 <html>
2 <head>
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>
6 </head>
7 <body  onload="prettyPrint();">
8     <pre class="prettyprint lang-js">/*!
9  * Ext JS Library 3.0.3
10  * Copyright(c) 2006-2009 Ext JS, LLC
11  * licensing@extjs.com
12  * http://www.extjs.com/license
13  */
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
19  * @constructor\r
20  * @param {Mixed} el The container element\r
21  * @param {Object} config\r
22  */\r
23 Ext.dd.DropTarget = function(el, config){\r
24     this.el = Ext.get(el);\r
25     \r
26     Ext.apply(this, config);\r
27     \r
28     if(this.containerScroll){\r
29         Ext.dd.ScrollManager.register(this.el);\r
30     }\r
31     \r
32     Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group, \r
33           {isTarget: true});\r
34 \r
35 };\r
36 \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
42      */\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
46      */\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
50      */\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
55      */\r
56     dropNotAllowed : "x-dd-drop-nodrop",\r
57 \r
58     // private\r
59     isTarget : true,\r
60 \r
61     // private\r
62     isNotifyTarget : true,\r
63 \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
73      */\r
74     notifyEnter : function(dd, e, data){\r
75         if(this.overClass){\r
76             this.el.addClass(this.overClass);\r
77         }\r
78         return this.dropAllowed;\r
79     },\r
80 \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
90      */\r
91     notifyOver : function(dd, e, data){\r
92         return this.dropAllowed;\r
93     },\r
94 \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
102      */\r
103     notifyOut : function(dd, e, data){\r
104         if(this.overClass){\r
105             this.el.removeClass(this.overClass);\r
106         }\r
107     },\r
108 \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
118      */\r
119     notifyDrop : function(dd, e, data){\r
120         return false;\r
121     }\r
122 });</pre>
123 </body>
124 </html>