summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/tree/TreeDragZone.js
blob: 9b77b3ce492869c1cce1bf02607a342351360990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
YAHOO.ext.tree.TreeDragZone = function(tree, config){
    YAHOO.ext.tree.TreeDragZone.superclass.constructor.call(this, tree.getEl(), config);
    this.tree = tree;
};

YAHOO.extendX(YAHOO.ext.tree.TreeDragZone, YAHOO.ext.dd.DragZone, {
    ddGroup : 'TreeDD',
    
    onBeforeDrag : function(data, e){
        var n = data.node;
        return n && n.draggable && !n.disabled;
    },
    
    onInitDrag : function(e){
        var data = this.dragData;
        this.tree.getSelectionModel().select(data.node);
        this.proxy.update('');
        data.node.ui.appendDDGhost(this.proxy.ghost.dom);
        this.tree.fireEvent('startdrag', this.tree, data.node, e);
    },
    
    getRepairXY : function(e, data){
        return data.node.ui.getDDRepairXY();
    },
    
    onEndDrag : function(data, e){
        this.tree.fireEvent('enddrag', this.tree, data.node, e); 
    },
    
    onValidDrop : function(dd, e, id){
        this.tree.fireEvent('dragdrop', this.tree, this.dragData.node, dd, e);
        this.hideProxy();
    },
    
    beforeInvalidDrop : function(e, id){
        if(YAHOO.util.Anim){
            // this scrolls the original position back into view
            var sm = this.tree.getSelectionModel();
            sm.clearSelections();
            sm.select(this.dragData.node);
        }
    }
});