Upgrade to ExtJS 4.0.1 - Released 05/18/2011
[extjs.git] / docs / source / DropTarget.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5   <title>The source code</title>
6   <link href="../prettify/prettify.css" type="text/css" rel="stylesheet" />
7   <script type="text/javascript" src="../prettify/prettify.js"></script>
8   <style type="text/css">
9     .highlight { display: block; background-color: #ddd; }
10   </style>
11   <script type="text/javascript">
12     function highlight() {
13       document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
14     }
15   </script>
16 </head>
17 <body onload="prettyPrint(); highlight();">
18   <pre class="prettyprint lang-js"><span id='Ext-dd-DropTarget-method-constructor'><span id='Ext-dd-DropTarget'>/**
19 </span></span> * @class Ext.dd.DropTarget
20  * @extends Ext.dd.DDTarget
21  * A simple class that provides the basic implementation needed to make any element a drop target that can have
22  * draggable items dropped onto it.  The drop has no effect until an implementation of notifyDrop is provided.
23  * @constructor
24  * @param {Mixed} el The container element
25  * @param {Object} config
26  */
27 Ext.define('Ext.dd.DropTarget', {
28     extend: 'Ext.dd.DDTarget',
29     requires: ['Ext.dd.ScrollManager'],
30
31     constructor : function(el, config){
32         this.el = Ext.get(el);
33
34         Ext.apply(this, config);
35
36         if(this.containerScroll){
37             Ext.dd.ScrollManager.register(this.el);
38         }
39
40         this.callParent([this.el.dom, this.ddGroup || this.group,
41               {isTarget: true}]);
42     },
43
44 <span id='Ext-dd-DropTarget-cfg-ddGroup'>    /**
45 </span>     * @cfg {String} ddGroup
46      * A named drag drop group to which this object belongs.  If a group is specified, then this object will only
47      * interact with other drag drop objects in the same group (defaults to undefined).
48      */
49 <span id='Ext-dd-DropTarget-cfg-overClass'>    /**
50 </span>     * @cfg {String} overClass
51      * The CSS class applied to the drop target element while the drag source is over it (defaults to &quot;&quot;).
52      */
53 <span id='Ext-dd-DropTarget-cfg-dropAllowed'>    /**
54 </span>     * @cfg {String} dropAllowed
55      * The CSS class returned to the drag source when drop is allowed (defaults to &quot;x-dd-drop-ok&quot;).
56      */
57     dropAllowed : Ext.baseCSSPrefix + 'dd-drop-ok',
58 <span id='Ext-dd-DropTarget-cfg-dropNotAllowed'>    /**
59 </span>     * @cfg {String} dropNotAllowed
60      * The CSS class returned to the drag source when drop is not allowed (defaults to &quot;x-dd-drop-nodrop&quot;).
61      */
62     dropNotAllowed : Ext.baseCSSPrefix + 'dd-drop-nodrop',
63
64     // private
65     isTarget : true,
66
67     // private
68     isNotifyTarget : true,
69
70 <span id='Ext-dd-DropTarget-method-notifyEnter'>    /**
71 </span>     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source is now over the
72      * target.  This default implementation adds the CSS class specified by overClass (if any) to the drop element
73      * and returns the dropAllowed config value.  This method should be overridden if drop validation is required.
74      * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
75      * @param {Event} e The event
76      * @param {Object} data An object containing arbitrary data supplied by the drag source
77      * @return {String} status The CSS class that communicates the drop status back to the source so that the
78      * underlying {@link Ext.dd.StatusProxy} can be updated
79      */
80     notifyEnter : function(dd, e, data){
81         if(this.overClass){
82             this.el.addCls(this.overClass);
83         }
84         return this.dropAllowed;
85     },
86
87 <span id='Ext-dd-DropTarget-method-notifyOver'>    /**
88 </span>     * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the target.
89      * This method will be called on every mouse movement while the drag source is over the drop target.
90      * This default implementation simply returns the dropAllowed config value.
91      * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
92      * @param {Event} e The event
93      * @param {Object} data An object containing arbitrary data supplied by the drag source
94      * @return {String} status The CSS class that communicates the drop status back to the source so that the
95      * underlying {@link Ext.dd.StatusProxy} can be updated
96      */
97     notifyOver : function(dd, e, data){
98         return this.dropAllowed;
99     },
100
101 <span id='Ext-dd-DropTarget-method-notifyOut'>    /**
102 </span>     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source has been dragged
103      * out of the target without dropping.  This default implementation simply removes the CSS class specified by
104      * overClass (if any) from the drop element.
105      * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
106      * @param {Event} e The event
107      * @param {Object} data An object containing arbitrary data supplied by the drag source
108      */
109     notifyOut : function(dd, e, data){
110         if(this.overClass){
111             this.el.removeCls(this.overClass);
112         }
113     },
114
115 <span id='Ext-dd-DropTarget-method-notifyDrop'>    /**
116 </span>     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the dragged item has
117      * been dropped on it.  This method has no default implementation and returns false, so you must provide an
118      * implementation that does something to process the drop event and returns true so that the drag source's
119      * repair action does not run.
120      * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
121      * @param {Event} e The event
122      * @param {Object} data An object containing arbitrary data supplied by the drag source
123      * @return {Boolean} False if the drop was invalid.
124      */
125     notifyDrop : function(dd, e, data){
126         return false;
127     },
128
129     destroy : function(){
130         this.callParent();
131         if(this.containerScroll){
132             Ext.dd.ScrollManager.unregister(this.el);
133         }
134     }
135 });
136 </pre>
137 </body>
138 </html>