Upgrade to ExtJS 3.2.1 - Released 04/27/2010
[extjs.git] / docs / source / TreeDragZone.html
1 <html>
2 <head>
3   <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />    
4   <title>The source code</title>
5     <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
6     <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
7 </head>
8 <body  onload="prettyPrint();">
9     <pre class="prettyprint lang-js">/*!
10  * Ext JS Library 3.2.1
11  * Copyright(c) 2006-2010 Ext JS, Inc.
12  * licensing@extjs.com
13  * http://www.extjs.com/license
14  */
15 <div id="cls-Ext.tree.TreeDragZone"></div>/**
16  * @class Ext.tree.TreeDragZone
17  * @extends Ext.dd.DragZone
18  * @constructor
19  * @param {String/HTMLElement/Element} tree The {@link Ext.tree.TreePanel} for which to enable dragging
20  * @param {Object} config
21  */
22 if(Ext.dd.DragZone){
23 Ext.tree.TreeDragZone = function(tree, config){
24     Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.innerCt, config);
25     <div id="prop-Ext.tree.TreeDragZone-tree"></div>/**
26     * The TreePanel for this drag zone
27     * @type Ext.tree.TreePanel
28     * @property
29     */
30     this.tree = tree;
31 };
32
33 Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
34     <div id="cfg-Ext.tree.TreeDragZone-ddGroup"></div>/**
35      * @cfg {String} ddGroup
36      * A named drag drop group to which this object belongs.  If a group is specified, then this object will only
37      * interact with other drag drop objects in the same group (defaults to 'TreeDD').
38      */
39     ddGroup : "TreeDD",
40
41     // private
42     onBeforeDrag : function(data, e){
43         var n = data.node;
44         return n && n.draggable && !n.disabled;
45     },
46
47     // private
48     onInitDrag : function(e){
49         var data = this.dragData;
50         this.tree.getSelectionModel().select(data.node);
51         this.tree.eventModel.disable();
52         this.proxy.update("");
53         data.node.ui.appendDDGhost(this.proxy.ghost.dom);
54         this.tree.fireEvent("startdrag", this.tree, data.node, e);
55     },
56
57     // private
58     getRepairXY : function(e, data){
59         return data.node.ui.getDDRepairXY();
60     },
61
62     // private
63     onEndDrag : function(data, e){
64         this.tree.eventModel.enable.defer(100, this.tree.eventModel);
65         this.tree.fireEvent("enddrag", this.tree, data.node, e);
66     },
67
68     // private
69     onValidDrop : function(dd, e, id){
70         this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
71         this.hideProxy();
72     },
73
74     // private
75     beforeInvalidDrop : function(e, id){
76         // this scrolls the original position back into view
77         var sm = this.tree.getSelectionModel();
78         sm.clearSelections();
79         sm.select(this.dragData.node);
80     },
81     
82     // private
83     afterRepair : function(){
84         if (Ext.enableFx && this.tree.hlDrop) {
85             Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
86         }
87         this.dragging = false;
88     }
89 });
90 }</pre>    
91 </body>
92 </html>