Subversion Repositories eFlore/Applications.cel

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
27 jpm 1
/*
2
 * Ext JS Library 2.0.2
3
 * Copyright(c) 2006-2008, Ext JS, LLC.
4
 * licensing@extjs.com
5
 *
6
 * http://extjs.com/license
7
 */
8
 
9
/**
10
 * @class Ext.dd.DropTarget
11
 * @extends Ext.dd.DDTarget
12
 * A simple class that provides the basic implementation needed to make any element a drop target that can have
13
 * draggable items dropped onto it.  The drop has no effect until an implementation of notifyDrop is provided.
14
 * @constructor
15
 * @param {Mixed} el The container element
16
 * @param {Object} config
17
 */
18
Ext.dd.DropTarget = 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
Ext.extend(Ext.dd.DropTarget, Ext.dd.DDTarget, {
33
    /**
34
     * @cfg {String} ddGroup
35
     * A named drag drop group to which this object belongs.  If a group is specified, then this object will only
36
     * interact with other drag drop objects in the same group (defaults to undefined).
37
     */
38
    /**
39
     * @cfg {String} overClass
40
     * The CSS class applied to the drop target element while the drag source is over it (defaults to "").
41
     */
42
    /**
43
     * @cfg {String} dropAllowed
44
     * The CSS class returned to the drag source when drop is allowed (defaults to "x-dd-drop-ok").
45
     */
46
    dropAllowed : "x-dd-drop-ok",
47
    /**
48
     * @cfg {String} dropNotAllowed
49
     * The CSS class returned to the drag source when drop is not allowed (defaults to "x-dd-drop-nodrop").
50
     */
51
    dropNotAllowed : "x-dd-drop-nodrop",
52
 
53
    // private
54
    isTarget : true,
55
 
56
    // private
57
    isNotifyTarget : true,
58
 
59
    /**
60
     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source is now over the
61
     * target.  This default implementation adds the CSS class specified by overClass (if any) to the drop element
62
     * and returns the dropAllowed config value.  This method should be overridden if drop validation is required.
63
     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
64
     * @param {Event} e The event
65
     * @param {Object} data An object containing arbitrary data supplied by the drag source
66
     * @return {String} status The CSS class that communicates the drop status back to the source so that the
67
     * underlying {@link Ext.dd.StatusProxy} can be updated
68
     */
69
    notifyEnter : function(dd, e, data){
70
        if(this.overClass){
71
            this.el.addClass(this.overClass);
72
        }
73
        return this.dropAllowed;
74
    },
75
 
76
    /**
77
     * The function a {@link Ext.dd.DragSource} calls continuously while it is being dragged over the target.
78
     * This method will be called on every mouse movement while the drag source is over the drop target.
79
     * This default implementation simply returns the dropAllowed config value.
80
     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
81
     * @param {Event} e The event
82
     * @param {Object} data An object containing arbitrary data supplied by the drag source
83
     * @return {String} status The CSS class that communicates the drop status back to the source so that the
84
     * underlying {@link Ext.dd.StatusProxy} can be updated
85
     */
86
    notifyOver : function(dd, e, data){
87
        return this.dropAllowed;
88
    },
89
 
90
    /**
91
     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the source has been dragged
92
     * out of the target without dropping.  This default implementation simply removes the CSS class specified by
93
     * overClass (if any) from the drop element.
94
     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
95
     * @param {Event} e The event
96
     * @param {Object} data An object containing arbitrary data supplied by the drag source
97
     */
98
    notifyOut : function(dd, e, data){
99
        if(this.overClass){
100
            this.el.removeClass(this.overClass);
101
        }
102
    },
103
 
104
    /**
105
     * The function a {@link Ext.dd.DragSource} calls once to notify this drop target that the dragged item has
106
     * been dropped on it.  This method has no default implementation and returns false, so you must provide an
107
     * implementation that does something to process the drop event and returns true so that the drag source's
108
     * repair action does not run.
109
     * @param {Ext.dd.DragSource} source The drag source that was dragged over this drop target
110
     * @param {Event} e The event
111
     * @param {Object} data An object containing arbitrary data supplied by the drag source
112
     * @return {Boolean} True if the drop was valid, else false
113
     */
114
    notifyDrop : function(dd, e, data){
115
        return false;
116
    }
117
});