1 | /* |
---|
2 | * Ext JS Library 2.2.1 |
---|
3 | * Copyright(c) 2006-2009, Ext JS, LLC. |
---|
4 | * licensing@extjs.com |
---|
5 | * |
---|
6 | * http://extjs.com/license |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * @class Ext.tree.TreeDragZone |
---|
11 | * @extends Ext.dd.DragZone |
---|
12 | * @constructor |
---|
13 | * @param {String/HTMLElement/Element} tree The {@link Ext.tree.TreePanel} for which to enable dragging |
---|
14 | * @param {Object} config |
---|
15 | */ |
---|
16 | if(Ext.dd.DragZone){ |
---|
17 | Ext.tree.TreeDragZone = function(tree, config){ |
---|
18 | Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.getTreeEl(), config); |
---|
19 | /** |
---|
20 | * The TreePanel for this drag zone |
---|
21 | * @type Ext.tree.TreePanel |
---|
22 | * @property |
---|
23 | */ |
---|
24 | this.tree = tree; |
---|
25 | }; |
---|
26 | |
---|
27 | Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, { |
---|
28 | /** |
---|
29 | * @cfg {String} ddGroup |
---|
30 | * A named drag drop group to which this object belongs. If a group is specified, then this object will only |
---|
31 | * interact with other drag drop objects in the same group (defaults to 'TreeDD'). |
---|
32 | */ |
---|
33 | ddGroup : "TreeDD", |
---|
34 | |
---|
35 | // private |
---|
36 | onBeforeDrag : function(data, e){ |
---|
37 | var n = data.node; |
---|
38 | return n && n.draggable && !n.disabled; |
---|
39 | }, |
---|
40 | |
---|
41 | // private |
---|
42 | onInitDrag : function(e){ |
---|
43 | var data = this.dragData; |
---|
44 | this.tree.getSelectionModel().select(data.node); |
---|
45 | this.tree.eventModel.disable(); |
---|
46 | this.proxy.update(""); |
---|
47 | data.node.ui.appendDDGhost(this.proxy.ghost.dom); |
---|
48 | this.tree.fireEvent("startdrag", this.tree, data.node, e); |
---|
49 | }, |
---|
50 | |
---|
51 | // private |
---|
52 | getRepairXY : function(e, data){ |
---|
53 | return data.node.ui.getDDRepairXY(); |
---|
54 | }, |
---|
55 | |
---|
56 | // private |
---|
57 | onEndDrag : function(data, e){ |
---|
58 | this.tree.eventModel.enable.defer(100, this.tree.eventModel); |
---|
59 | this.tree.fireEvent("enddrag", this.tree, data.node, e); |
---|
60 | }, |
---|
61 | |
---|
62 | // private |
---|
63 | onValidDrop : function(dd, e, id){ |
---|
64 | this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e); |
---|
65 | this.hideProxy(); |
---|
66 | }, |
---|
67 | |
---|
68 | // private |
---|
69 | beforeInvalidDrop : function(e, id){ |
---|
70 | // this scrolls the original position back into view |
---|
71 | var sm = this.tree.getSelectionModel(); |
---|
72 | sm.clearSelections(); |
---|
73 | sm.select(this.dragData.node); |
---|
74 | }, |
---|
75 | |
---|
76 | // private |
---|
77 | afterRepair : function(){ |
---|
78 | if (Ext.enableFx && this.tree.hlDrop) { |
---|
79 | Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9"); |
---|
80 | } |
---|
81 | this.dragging = false; |
---|
82 | } |
---|
83 | }); |
---|
84 | } |
---|