~t7-vla7-lz/psiphon/psiphon

« back to all changes in this revision

Viewing changes to trunk/testing/selenium_scripts/selenium/tests/html/dojo-0.4.0-mini/src/dnd/DragAndDrop.js

  • Committer: Eugene Fryntov
  • Date: 2016-11-15 22:13:59 UTC
  • mfrom: (373.1.1 psiphon)
  • Revision ID: e.fryntov@psiphon.ca-20161115221359-f6s56ue1a54n4ijj
merged lp:~t7-vla7-lz/psiphon/psiphon @ 374

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
        Copyright (c) 2004-2006, The Dojo Foundation
3
 
        All Rights Reserved.
4
 
 
5
 
        Licensed under the Academic Free License version 2.1 or above OR the
6
 
        modified BSD license. For more information on Dojo licensing, see:
7
 
 
8
 
                http://dojotoolkit.org/community/licensing.shtml
9
 
*/
10
 
 
11
 
dojo.require("dojo.lang.common");
12
 
dojo.require("dojo.lang.declare");
13
 
dojo.provide("dojo.dnd.DragAndDrop");
14
 
 
15
 
dojo.declare("dojo.dnd.DragSource", null, {
16
 
        type: "",
17
 
 
18
 
        onDragEnd: function(){
19
 
        },
20
 
 
21
 
        onDragStart: function(){
22
 
        },
23
 
 
24
 
        /*
25
 
         * This function gets called when the DOM element was 
26
 
         * selected for dragging by the HtmlDragAndDropManager.
27
 
         */
28
 
        onSelected: function(){
29
 
        },
30
 
 
31
 
        unregister: function(){
32
 
                dojo.dnd.dragManager.unregisterDragSource(this);
33
 
        },
34
 
 
35
 
        reregister: function(){
36
 
                dojo.dnd.dragManager.registerDragSource(this);
37
 
        }
38
 
}, function(){
39
 
 
40
 
        //dojo.profile.start("DragSource");
41
 
 
42
 
        var dm = dojo.dnd.dragManager;
43
 
        if(dm["registerDragSource"]){ // side-effect prevention
44
 
                dm.registerDragSource(this);
45
 
        }
46
 
 
47
 
        //dojo.profile.end("DragSource");
48
 
 
49
 
});
50
 
 
51
 
dojo.declare("dojo.dnd.DragObject", null, {
52
 
        type: "",
53
 
 
54
 
        onDragStart: function(){
55
 
                // gets called directly after being created by the DragSource
56
 
                // default action is to clone self as icon
57
 
        },
58
 
 
59
 
        onDragMove: function(){
60
 
                // this changes the UI for the drag icon
61
 
                //      "it moves itself"
62
 
        },
63
 
 
64
 
        onDragOver: function(){
65
 
        },
66
 
 
67
 
        onDragOut: function(){
68
 
        },
69
 
 
70
 
        onDragEnd: function(){
71
 
        },
72
 
 
73
 
        // normal aliases
74
 
        onDragLeave: this.onDragOut,
75
 
        onDragEnter: this.onDragOver,
76
 
 
77
 
        // non-camel aliases
78
 
        ondragout: this.onDragOut,
79
 
        ondragover: this.onDragOver
80
 
}, function(){
81
 
        var dm = dojo.dnd.dragManager;
82
 
        if(dm["registerDragObject"]){ // side-effect prevention
83
 
                dm.registerDragObject(this);
84
 
        }
85
 
});
86
 
 
87
 
dojo.declare("dojo.dnd.DropTarget", null, {
88
 
 
89
 
        acceptsType: function(type){
90
 
                if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
91
 
                        if(!dojo.lang.inArray(this.acceptedTypes, type)) { return false; }
92
 
                }
93
 
                return true;
94
 
        },
95
 
 
96
 
        accepts: function(dragObjects){
97
 
                if(!dojo.lang.inArray(this.acceptedTypes, "*")){ // wildcard
98
 
                        for (var i = 0; i < dragObjects.length; i++) {
99
 
                                if (!dojo.lang.inArray(this.acceptedTypes,
100
 
                                        dragObjects[i].type)) { return false; }
101
 
                        }
102
 
                }
103
 
                return true;
104
 
        },
105
 
 
106
 
        unregister: function(){
107
 
                dojo.dnd.dragManager.unregisterDropTarget(this);
108
 
        },
109
 
 
110
 
        onDragOver: function(){
111
 
        },
112
 
 
113
 
        onDragOut: function(){
114
 
        },
115
 
 
116
 
        onDragMove: function(){
117
 
        },
118
 
 
119
 
        onDropStart: function(){
120
 
        },
121
 
 
122
 
        onDrop: function(){
123
 
        },
124
 
 
125
 
        onDropEnd: function(){
126
 
        }
127
 
}, function(){
128
 
        if (this.constructor == dojo.dnd.DropTarget) { return; } // need to be subclassed
129
 
        this.acceptedTypes = [];
130
 
        dojo.dnd.dragManager.registerDropTarget(this);
131
 
});
132
 
 
133
 
// NOTE: this interface is defined here for the convenience of the DragManager
134
 
// implementor. It is expected that in most cases it will be satisfied by
135
 
// extending a native event (DOM event in HTML and SVG).
136
 
dojo.dnd.DragEvent = function(){
137
 
        this.dragSource = null;
138
 
        this.dragObject = null;
139
 
        this.target = null;
140
 
        this.eventStatus = "success";
141
 
        //
142
 
        // can be one of:
143
 
        //      [       "dropSuccess", "dropFailure", "dragMove",
144
 
        //              "dragStart", "dragEnter", "dragLeave"]
145
 
        //
146
 
}
147
 
/*
148
 
 *      The DragManager handles listening for low-level events and dispatching
149
 
 *      them to higher-level primitives like drag sources and drop targets. In
150
 
 *      order to do this, it must keep a list of the items.
151
 
 */
152
 
dojo.declare("dojo.dnd.DragManager", null, {
153
 
        selectedSources: [],
154
 
        dragObjects: [],
155
 
        dragSources: [],
156
 
        registerDragSource: function(){},
157
 
        dropTargets: [],
158
 
        registerDropTarget: function(){},
159
 
        lastDragTarget: null,
160
 
        currentDragTarget: null,
161
 
        onKeyDown: function(){},
162
 
        onMouseOut: function(){},
163
 
        onMouseMove: function(){},
164
 
        onMouseUp: function(){}
165
 
});
166
 
 
167
 
// NOTE: despite the existance of the DragManager class, there will be a
168
 
// singleton drag manager provided by the renderer-specific D&D support code.
169
 
// It is therefore sane for us to assign instance variables to the DragManager
170
 
// prototype
171
 
 
172
 
// The renderer-specific file will define the following object:
173
 
// dojo.dnd.dragManager = null;