3 * Copyright(c) 2006-2010 Sencha Inc.
5 * http://www.sencha.com/license
8 * @class Ext.tree.TreeDragZone
9 * @extends Ext.dd.DragZone
11 * @param {String/HTMLElement/Element} tree The {@link Ext.tree.TreePanel} for which to enable dragging
12 * @param {Object} config
15 Ext.tree.TreeDragZone = function(tree, config){
16 Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.innerCt, config);
18 * The TreePanel for this drag zone
19 * @type Ext.tree.TreePanel
25 Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
27 * @cfg {String} ddGroup
28 * A named drag drop group to which this object belongs. If a group is specified, then this object will only
29 * interact with other drag drop objects in the same group (defaults to 'TreeDD').
34 onBeforeDrag : function(data, e){
36 return n && n.draggable && !n.disabled;
40 onInitDrag : function(e){
41 var data = this.dragData;
42 this.tree.getSelectionModel().select(data.node);
43 this.tree.eventModel.disable();
44 this.proxy.update("");
45 data.node.ui.appendDDGhost(this.proxy.ghost.dom);
46 this.tree.fireEvent("startdrag", this.tree, data.node, e);
50 getRepairXY : function(e, data){
51 return data.node.ui.getDDRepairXY();
55 onEndDrag : function(data, e){
56 this.tree.eventModel.enable.defer(100, this.tree.eventModel);
57 this.tree.fireEvent("enddrag", this.tree, data.node, e);
61 onValidDrop : function(dd, e, id){
62 this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
67 beforeInvalidDrop : function(e, id){
68 // this scrolls the original position back into view
69 var sm = this.tree.getSelectionModel();
71 sm.select(this.dragData.node);
75 afterRepair : function(){
76 if (Ext.enableFx && this.tree.hlDrop) {
77 Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
79 this.dragging = false;