-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataTransfer.cljs
397 lines (284 loc) · 12.4 KB
/
DataTransfer.cljs
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
(ns web.drag.DataTransfer
"The DataTransfer object is used to hold the data that is being
during a drag and drop operation. It may hold one or more data
each of one or more data types. For more information about drag
drop, see HTML Drag and Drop API."
(:refer-clojure :exclude []))
(def constructor
"Constructor.
The DataTransfer constructor creates a new `web.drag.DataTransfer` object instance.
None.
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/DataTransfer`"
js/DataTransfer)
(defn clear-data
"Method.
The DataTransfer.clearData() method removes the drag operation's
data` for the given type. If data for the given type does not
this method does nothing.
`DataTransfer.clearData([format]);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/clearData`"
[this & args]
(-> this .-clearData (.apply this (clj->js args))))
(defn get-data
"Method.
The DataTransfer.getData() method retrieves drag data (as a `web.dom.DOMString`)
the specified type. If the drag operation does not include data,
method returns an empty string.
`dataTransfer.getData(format);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/getData`"
[this format]
(-> this (.getData format)))
(defn set-data
"Method.
The DataTransfer.setData() method sets the drag operation's `drag
to the specified data and type. If data for the given type does
exist, it is added at the end of the drag data store, such that
last item in the `types` list will be the new type. If data for
given type already exists, the existing data is replaced in the
position. That is, the order of the `types` list is not changed
replacing data of the same type.
`void dataTransfer.setData(format, data);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setData`"
[this format data]
(-> this (.setData format data)))
(defn set-drag-image
"Method.
When a drag occurs, a translucent image is generated from the
target (the element the dragstart event is fired at), and follows
mouse pointer during the drag. This image is created automatically,
you do not need to create it yourself. However, if a custom image
desired, the DataTransfer.setDragImage() method can be used to
the custom image to be used. The image will typically be an `<image>`
but it can also be a `<canvas>` or any other image element.
`void dataTransfer.setDragImage(img, xOffset, yOffset);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/setDragImage`"
[this img x-offset y-offset]
(-> this (.setDragImage img x-offset y-offset)))
(defn add-element
"Method.
The DataTransfer.addElement() method sets the drag source to
given element. This element will be the element to which drag
dragend events are fired, and not the defaut target (the node
was dragged).
`void dataTransfer.addElement(el);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/addElement`"
[this el]
(-> this (.addElement el)))
(defn moz-clear-data-at
"Method.
The DataTransfer.mozClearDataAt() method removes the data associated
the given format for an item at the specified index. The index
be in the range from zero to the number of items minus one.
`void dataTransfer.mozClearDataAt([type], index);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozClearDataAt`"
[this & args]
(-> this .-mozClearDataAt (.apply this (clj->js args))))
(defn moz-get-data-at
"Method.
The DataTransfer.mozGetDataAt() method is used to retrieve an
in the drag event's `data transfer` object, based on a given
and index. This method returns null if the specified item does
exist or if the index is not in the range from zero to the number
items minus one.
`nsIVariant dataTransfer.mozGetDataAt([type], index);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozGetDataAt`"
[this & args]
(-> this .-mozGetDataAt (.apply this (clj->js args))))
(defn moz-set-data-at
"Method.
The DataTransfer.mozSetDataAt() method is used to add data to
specific index in the drag event's `data transfer` object.
`void dataTransfer.mozSetDataAt([type], data, index);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozSetDataAt`"
[this & args]
(-> this .-mozSetDataAt (.apply this (clj->js args))))
(defn moz-types-at
"Method.
The DataTransfer.mozTypesAt() method returns a list of the format
that are stored for an item at the specified index. If the index
not in the range from 0 to the number of items minus one, an
string list is returned.
`nsIVariant dataTransfer.mozTypesAt(index);`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozTypesAt`"
[this index]
(-> this (.mozTypesAt index)))
(defn drop-effect
"Property.
The DataTransfer.dropEffect property controls the feedback (typically
the user is given during a drag and drop operation. It will affect
cursor is displayed while dragging. For example, when the user
over a target drop element, the browser's cursor may indicate
type of operation will occur.
`dataTransfer.dropEffect;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/dropEffect`"
[this]
(-> this (.-dropEffect)))
(defn set-drop-effect!
"Property.
The DataTransfer.dropEffect property controls the feedback (typically
the user is given during a drag and drop operation. It will affect
cursor is displayed while dragging. For example, when the user
over a target drop element, the browser's cursor may indicate
type of operation will occur.
`dataTransfer.dropEffect;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/dropEffect`"
[this val]
(aset this "dropEffect" val))
(defn effect-allowed
"Property.
The DataTransfer.effectAllowed property specifies the effect
is allowed for a drag operation. The copy operation is used to
that the data being dragged will be copied from its present location
the drop location. The move operation is used to indicate that
data being dragged will be moved, and the link operation is used
indicate that some form of relationship or connection will be
between the source and drop locations.
`dataTransfer.effectAllowed;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/effectAllowed`"
[this]
(-> this (.-effectAllowed)))
(defn set-effect-allowed!
"Property.
The DataTransfer.effectAllowed property specifies the effect
is allowed for a drag operation. The copy operation is used to
that the data being dragged will be copied from its present location
the drop location. The move operation is used to indicate that
data being dragged will be moved, and the link operation is used
indicate that some form of relationship or connection will be
between the source and drop locations.
`dataTransfer.effectAllowed;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/effectAllowed`"
[this val]
(aset this "effectAllowed" val))
(defn files
"Property.
The DataTransfer.files property is a `list of the files` in the
operation. If the operation includes no files, the list is empty.
`dataTransfer.files;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/files`"
[this]
(-> this (.-files)))
(defn set-files!
"Property.
The DataTransfer.files property is a `list of the files` in the
operation. If the operation includes no files, the list is empty.
`dataTransfer.files;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/files`"
[this val]
(aset this "files" val))
(defn items
"Property.
The read-only `web.drag.DataTransfer` property items property
a `list` of the `data transfer items` in a drag operation. The
includes one item for each item in the operation and if the operation
no items, the list is empty.
`itemList = dataTransfer.items;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/items`"
[this]
(-> this (.-items)))
(defn set-items!
"Property.
The read-only `web.drag.DataTransfer` property items property
a `list` of the `data transfer items` in a drag operation. The
includes one item for each item in the operation and if the operation
no items, the list is empty.
`itemList = dataTransfer.items;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/items`"
[this val]
(aset this "items" val))
(defn types
"Property.
The DataTransfer.types read-only property returns an array of
drag data formats (as `strings`) that were set in the dragstart
The order of the formats is the same order as the data included
the drag operation.
`dataTransfer.types;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types`"
[this]
(-> this (.-types)))
(defn set-types!
"Property.
The DataTransfer.types read-only property returns an array of
drag data formats (as `strings`) that were set in the dragstart
The order of the formats is the same order as the data included
the drag operation.
`dataTransfer.types;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/types`"
[this val]
(aset this "types" val))
(defn moz-cursor
"Property.
The DataTransfer.mozCursor property returns or sets the drag
state. This is primarily used to control the cursor during tab
`dataTransfer.mozCursor;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozCursor`"
[this]
(-> this (.-mozCursor)))
(defn set-moz-cursor!
"Property.
The DataTransfer.mozCursor property returns or sets the drag
state. This is primarily used to control the cursor during tab
`dataTransfer.mozCursor;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozCursor`"
[this val]
(aset this "mozCursor" val))
(defn moz-item-count
"Property.
The DataTransfer.mozItemCount property returns the number of
being dragged. This can be used, for example, to get the number
files being dragged.
`dataTransfer.mozItemCount;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozItemCount`"
[this]
(-> this (.-mozItemCount)))
(defn set-moz-item-count!
"Property.
The DataTransfer.mozItemCount property returns the number of
being dragged. This can be used, for example, to get the number
files being dragged.
`dataTransfer.mozItemCount;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozItemCount`"
[this val]
(aset this "mozItemCount" val))
(defn moz-source-node
"Property.
The DataTransfer.mozSourceNode property is used to determine
`web.Node` over which the mouse cursor was located when the the
operation was initiated (for example, when a `<button>` was clicked).
external drags or if the calling function cannot reach the node,
is returned.
`dataTransfer.mozSourceNode;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozSourceNode`"
[this]
(-> this (.-mozSourceNode)))
(defn set-moz-source-node!
"Property.
The DataTransfer.mozSourceNode property is used to determine
`web.Node` over which the mouse cursor was located when the the
operation was initiated (for example, when a `<button>` was clicked).
external drags or if the calling function cannot reach the node,
is returned.
`dataTransfer.mozSourceNode;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozSourceNode`"
[this val]
(aset this "mozSourceNode" val))
(defn moz-user-cancelled
"Property.
The DataTransfer.mozUserCancelled property is used in the dragend
handler to determine if the user canceled the drag or not. If
user canceled the event, the property returns true and returns
otherwise. This property only applies to the dragend event.
`dataTransfer.mozUserCancelled;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozUserCancelled`"
[this]
(-> this (.-mozUserCancelled)))
(defn set-moz-user-cancelled!
"Property.
The DataTransfer.mozUserCancelled property is used in the dragend
handler to determine if the user canceled the drag or not. If
user canceled the event, the property returns true and returns
otherwise. This property only applies to the dragend event.
`dataTransfer.mozUserCancelled;`
See also: `https://developer.mozilla.org/en-US/docs/Web/API/DataTransfer/mozUserCancelled`"
[this val]
(aset this "mozUserCancelled" val))