initial import
[roojs1] / Roo / tree / TreeDragZone.js
1 /*
2  * Based on:
3  * Ext JS Library 1.1.1
4  * Copyright(c) 2006-2007, Ext JS, LLC.
5  *
6  * Originally Released Under LGPL - original licence link has changed is not relivant.
7  *
8  * Fork - LGPL
9  * <script type="text/javascript">
10  */
11  
12
13 if(Roo.dd.DragZone){
14 Roo.tree.TreeDragZone = function(tree, config){
15     Roo.tree.TreeDragZone.superclass.constructor.call(this, tree.getTreeEl(), config);
16     this.tree = tree;
17 };
18
19 Roo.extend(Roo.tree.TreeDragZone, Roo.dd.DragZone, {
20     ddGroup : "TreeDD",
21     
22     onBeforeDrag : function(data, e){
23         var n = data.node;
24         return n && n.draggable && !n.disabled;
25     },
26     
27     onInitDrag : function(e){
28         var data = this.dragData;
29         this.tree.getSelectionModel().select(data.node);
30         this.proxy.update("");
31         data.node.ui.appendDDGhost(this.proxy.ghost.dom);
32         this.tree.fireEvent("startdrag", this.tree, data.node, e);
33     },
34     
35     getRepairXY : function(e, data){
36         return data.node.ui.getDDRepairXY();
37     },
38     
39     onEndDrag : function(data, e){
40         this.tree.fireEvent("enddrag", this.tree, data.node, e);
41     },
42     
43     onValidDrop : function(dd, e, id){
44         this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
45         this.hideProxy();
46     },
47     
48     beforeInvalidDrop : function(e, id){
49         // this scrolls the original position back into view
50         var sm = this.tree.getSelectionModel();
51         sm.clearSelections();
52         sm.select(this.dragData.node);
53     }
54 });
55 }