[76] | 1 | /*! |
---|
| 2 | * Ext JS Library 3.4.0 |
---|
| 3 | * Copyright(c) 2006-2011 Sencha Inc. |
---|
| 4 | * licensing@sencha.com |
---|
| 5 | * http://www.sencha.com/license |
---|
| 6 | */ |
---|
| 7 | /** |
---|
| 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. |
---|
| 12 | * @constructor |
---|
| 13 | * @param {Mixed} el The container element |
---|
| 14 | * @param {Object} config |
---|
| 15 | */ |
---|
| 16 | Ext.dd.DropTarget = Ext.extend(Ext.dd.DDTarget, { |
---|
| 17 | |
---|
| 18 | constructor : function(el, config){ |
---|
| 19 | this.el = Ext.get(el); |
---|
| 20 | |
---|
| 21 | Ext.apply(this, config); |
---|
| 22 | |
---|
| 23 | if(this.containerScroll){ |
---|
| 24 | Ext.dd.ScrollManager.register(this.el); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group, |
---|
| 28 | {isTarget: true}); |
---|
| 29 | }, |
---|
| 30 | |
---|
| 31 | /** |
---|
| 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). |
---|
| 35 | */ |
---|
| 36 | /** |
---|
| 37 | * @cfg {String} overClass |
---|
| 38 | * The CSS class applied to the drop target element while the drag source is over it (defaults to ""). |
---|
| 39 | */ |
---|
| 40 | /** |
---|
| 41 | * @cfg {String} dropAllowed |
---|
| 42 | * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok"). |
---|
| 43 | */ |
---|
| 44 | dropAllowed : "x-dd-drop-ok", |
---|
| 45 | /** |
---|
| 46 | * @cfg {String} dropNotAllowed |
---|
| 47 | * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop"). |
---|
| 48 | */ |
---|
| 49 | dropNotAllowed : "x-dd-drop-nodrop", |
---|
| 50 | |
---|
| 51 | // private |
---|
| 52 | isTarget : true, |
---|
| 53 | |
---|
| 54 | // private |
---|
| 55 | isNotifyTarget : true, |
---|
| 56 | |
---|
| 57 | /** |
---|
| 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 |
---|
| 66 | */ |
---|
| 67 | notifyEnter : function(dd, e, data){ |
---|
| 68 | if(this.overClass){ |
---|
| 69 | this.el.addClass(this.overClass); |
---|
| 70 | } |
---|
| 71 | return this.dropAllowed; |
---|
| 72 | }, |
---|
| 73 | |
---|
| 74 | /** |
---|
| 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 |
---|
| 83 | */ |
---|
| 84 | notifyOver : function(dd, e, data){ |
---|
| 85 | return this.dropAllowed; |
---|
| 86 | }, |
---|
| 87 | |
---|
| 88 | /** |
---|
| 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 |
---|
| 95 | */ |
---|
| 96 | notifyOut : function(dd, e, data){ |
---|
| 97 | if(this.overClass){ |
---|
| 98 | this.el.removeClass(this.overClass); |
---|
| 99 | } |
---|
| 100 | }, |
---|
| 101 | |
---|
| 102 | /** |
---|
| 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 |
---|
| 111 | */ |
---|
| 112 | notifyDrop : function(dd, e, data){ |
---|
| 113 | return false; |
---|
| 114 | }, |
---|
| 115 | |
---|
| 116 | destroy : function(){ |
---|
| 117 | Ext.dd.DropTarget.superclass.destroy.call(this); |
---|
| 118 | if(this.containerScroll){ |
---|
| 119 | Ext.dd.ScrollManager.unregister(this.el); |
---|
| 120 | } |
---|
| 121 | } |
---|
| 122 | }); |
---|