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.getSize())
64 var clientH = Roo.lib.Dom.getViewWidth();
67 var clientW = Roo.lib.Dom.getViewHeight();
69 // The amt scrolled down
70 var st = this.DDM.getScrollTop();
72 // The amt scrolled right
73 var sl = this.DDM.getScrollLeft();
75 // Location of the bottom of the element
78 // Location of the right of the element
81 // The distance from the cursor to the bottom of the visible area,
82 // adjusted so that we don't scroll if the cursor is beyond the
83 // element drag constraints
84 var toBot = (clientH + st - y - this.deltaY);
86 // The distance from the cursor to the right of the visible area
87 var toRight = (clientW + sl - x - this.deltaX);
90 // How close to the edge the cursor must be before we scroll
91 // var thresh = (document.all) ? 100 : 40;
94 // How many pixels to scroll per autoscroll op. This helps to reduce
95 // clunky scrolling. IE is more sensitive about this ... it needs this
96 // value to be higher.
97 var scrAmt = (document.all) ? 80 : 30;
99 // Scroll down if we are near the bottom of the visible page and the
100 // obj extends below the crease
101 if ( bot > clientH && toBot < thresh ) {
102 this.el.scrollTo(sl, st + scrAmt);
105 // Scroll up if the window is scrolled down and the top of the object
106 // goes above the top border
107 if ( y < st && st > 0 && y - st < thresh ) {
108 this.el.scrollTo(sl, st - scrAmt);
111 // Scroll right if the obj is beyond the right border and the cursor is
113 if ( right > clientW && toRight < thresh ) {
114 this.el.scrollTo(sl + scrAmt, st);
117 // Scroll left if the window has been scrolled to the right and the obj
118 // extends past the left border
119 if ( x < sl && sl > 0 && x - sl < thresh ) {
120 this.el.scrollTo(sl - scrAmt, st);