summaryrefslogtreecommitdiff
path: root/frontend/beta/js/YUI-extensions/dd/DropZone.js
blob: ce446fb6b68a83f003865e66de7d6ea5654e43e9 (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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// kill drag drop dependency
if(YAHOO.util.DragDrop){
YAHOO.ext.dd.DropZone = function(el, config){
    YAHOO.ext.dd.DropZone.superclass.constructor.call(this, el, config);
};

YAHOO.extendX(YAHOO.ext.dd.DropZone, YAHOO.ext.dd.DropTarget, {
    getTargetFromEvent : function(e){
        return YAHOO.ext.dd.Registry.getTargetFromEvent(e);
    },
    
    onNodeEnter : function(n, dd, e, data){
        
    },
    
    onNodeOver : function(n, dd, e, data){
        return this.dropAllowed;
    },
    
    onNodeOut : function(n, dd, e, data){
        
    },
    
    onNodeDrop : function(n, dd, e, data){
        return false;
    },
    
    onContainerOver : function(n, dd, e, data){
        return this.dropNotAllowed;
    },
    
    onContainerDrop : function(n, dd, e, data){
        return false;
    },
    
    notifyEnter : function(dd, e, data){
        return this.dropNotAllowed;
    },
    
    notifyOver : function(dd, e, data){
        var n = this.getTargetFromEvent(e);
        if(!n){ // not over valid drop target
            if(this.lastOverNode){
                this.onNodeOut(this.lastOverNode, dd, e, data);
                this.lastOverNode = null;
            }
            return this.onContainerOver(dd, e, data);
        }
        if(this.lastOverNode != n){
            if(this.lastOverNode){
                this.onNodeOut(this.lastOverNode, dd, e, data);
            }
            this.onNodeEnter(n, dd, e, data);
            this.lastOverNode = n;
        }
        return this.onNodeOver(n, dd, e, data);
    },
    
    notifyOut : function(dd, e, data){
        if(this.lastOverNode){
            this.onNodeOut(this.lastOverNode, dd, e, data);
            this.lastOverNode = null;
        }
    },
    
    notifyDrop : function(dd, e, data){
        if(this.lastOverNode){
            this.onNodeOut(this.lastOverNode, dd, e, data);
            this.lastOverNode = null;
        }
        var n = this.getTargetFromEvent(e);
        return n ?
            this.onNodeDrop(n, dd, e, data) :
            this.onContainerDrop(n, dd, e, data);
    },
    
    triggerCacheRefresh : function(){
        YAHOO.util.DDM.refreshCache(this.groups);
    }  
});
}