5d85006fbf1c8a887b96773e30e60b567e1810fd
[roojs1] / Roo / bootstrap / DropTarget.js
1 /*
2  * - LGPL
3  *
4  * dropable area
5  * 
6  */
7
8 /**
9  * @class Roo.bootstrap.DropTarget
10  * @extends Roo.bootstrap.Element
11  * Bootstrap DropTarget class
12  
13  * @cfg {string} name dropable name
14  * 
15  * @constructor
16  * Create a new Dropable Area
17  * @param {Object} config The config object
18  */
19
20 Roo.bootstrap.DropTarget = function(config){
21     Roo.bootstrap.DropTarget.superclass.constructor.call(this, config);
22     
23     this.addEvents({
24         // raw events
25         /**
26          * @event click
27          * When a element is chick
28          * @param {Roo.bootstrap.Element} this
29          * @param {Roo.EventObject} e
30          */
31         "drop" : true
32     });
33 };
34
35 Roo.extend(Roo.bootstrap.DropTarget, Roo.bootstrap.Element,  {
36     
37     
38     getAutoCreate : function(){
39         
40          
41     },
42     
43     initEvents: function() 
44     {
45         Roo.bootstrap.DropTarget.superclass.initEvents.call(this);
46         this.dropZone = new Roo.dd.DropTarget(this.getEl(), {
47             ddGroup: this.name,
48             listeners : {
49                 drop : this.dragDrop.createDelegate(this),
50                 enter : this.dragEnter.createDelegate(this),
51                 out : this.dragOut.createDelegate(this),
52                 over : this.dragOver.createDelegate(this)
53             }
54             
55         });
56         this.dropZone.DDM.useCache = false // so data gets refreshed when we resize stuff
57     },
58     
59     dragDrop : function(source,e,data)
60     {
61         // user has to decide how to impliment this.
62         Roo.log('drop');
63         Roo.log(this);
64         //this.fireEvent('drop', this, source, e ,data);
65         return false;
66     },
67     
68     dragEnter : function(n, dd, e, data)
69     {
70         // probably want to resize the element to match the dropped element..
71         Roo.log("enter");
72         this.originalSize = this.el.getSize();
73         this.el.setSize( n.el.getSize());
74         this.dropZone.DDM.refreshCache(this.name);
75         Roo.log([n, dd, e, data]);
76     },
77     
78     dragOut : function(value)
79     {
80         // resize back to normal
81         Roo.log("out");
82         this.el.setSize(this.originalSize);
83         this.dropZone.resetConstraints();
84     },
85     
86     dragOver : function()
87     {
88         // ??? do nothing?
89     }
90    
91 });
92
93  
94
95