4 * Copyright(c) 2006-2007, Ext JS, LLC.
6 * Originally Released Under LGPL - original licence link has changed is not relivant.
9 * <script type="text/javascript">
14 Roo.tree.TreeDragZone = function(tree, config){
15 Roo.tree.TreeDragZone.superclass.constructor.call(this, tree.getTreeEl(), config);
19 Roo.extend(Roo.tree.TreeDragZone, Roo.dd.DragZone, {
22 onBeforeDrag : function(data, e){
24 return n && n.draggable && !n.disabled;
28 onInitDrag : function(e){
29 var data = this.dragData;
30 this.tree.getSelectionModel().select(data.node);
31 this.proxy.update("");
32 data.node.ui.appendDDGhost(this.proxy.ghost.dom);
33 this.tree.fireEvent("startdrag", this.tree, data.node, e);
36 getRepairXY : function(e, data){
37 return data.node.ui.getDDRepairXY();
40 onEndDrag : function(data, e){
41 this.tree.fireEvent("enddrag", this.tree, data.node, e);
46 onValidDrop : function(dd, e, id){
47 this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
51 beforeInvalidDrop : function(e, id){
52 // this scrolls the original position back into view
53 var sm = this.tree.getSelectionModel();
55 sm.select(this.dragData.node);
57 autoScroll: function(x, y, h, w) {
58 Roo.log("drop zone - autoscroll called");
60 Roo.log( [ x, y, h , w, this.scroll ] );
61 Roo.log(this.el.getBox());
65 var clientH = Roo.lib.Dom.getViewWidth();
68 var clientW = Roo.lib.Dom.getViewHeight();
70 // The amt scrolled down
71 var st = this.DDM.getScrollTop();
73 // The amt scrolled right
74 var sl = this.DDM.getScrollLeft();
76 // Location of the bottom of the element
79 // Location of the right of the element
82 // The distance from the cursor to the bottom of the visible area,
83 // adjusted so that we don't scroll if the cursor is beyond the
84 // element drag constraints
85 var toBot = (clientH + st - y - this.deltaY);
87 // The distance from the cursor to the right of the visible area
88 var toRight = (clientW + sl - x - this.deltaX);
91 // How close to the edge the cursor must be before we scroll
92 // var thresh = (document.all) ? 100 : 40;
95 // How many pixels to scroll per autoscroll op. This helps to reduce
96 // clunky scrolling. IE is more sensitive about this ... it needs this
97 // value to be higher.
98 var scrAmt = (document.all) ? 80 : 30;
100 // Scroll down if we are near the bottom of the visible page and the
101 // obj extends below the crease
102 if ( bot > clientH && toBot < thresh ) {
103 this.el.scrollTo(sl, st + scrAmt);
106 // Scroll up if the window is scrolled down and the top of the object
107 // goes above the top border
108 if ( y < st && st > 0 && y - st < thresh ) {
109 this.el.scrollTo(sl, st - scrAmt);
112 // Scroll right if the obj is beyond the right border and the cursor is
114 if ( right > clientW && toRight < thresh ) {
115 this.el.scrollTo(sl + scrAmt, st);
118 // Scroll left if the window has been scrolled to the right and the obj
119 // extends past the left border
120 if ( x < sl && sl > 0 && x - sl < thresh ) {
121 this.el.scrollTo(sl - scrAmt, st);