-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathFileDrop.js
More file actions
55 lines (39 loc) · 1.58 KB
/
FileDrop.js
File metadata and controls
55 lines (39 loc) · 1.58 KB
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
'use strict';
import CONFIG from './../config.json';
export default ($parse, FileUploader, FileDrop) => {
return {
link: (scope, element, attributes) => {
var uploader = scope.$eval(attributes.uploader),
fileDropOptions = {
uploader: uploader,
element: element
},
onDragEnterCallback = scope.$eval(attributes.onDragEnter),
onDragLeaveCallback = scope.$eval(attributes.onDragLeave);
if (!(uploader instanceof FileUploader)) {
throw new TypeError('"Uploader" must be an instance of FileUploader');
}
if (!uploader.isHTML5) return;
if (onDragEnterCallback) {
if (typeof onDragEnterCallback !== 'function') {
throw new TypeError('"onDragEnter" callback must be a functions');
}
fileDropOptions._onDragEnterCallback = onDragEnterCallback;
}
if (onDragLeaveCallback) {
if (typeof onDragLeaveCallback !== 'function') {
throw new TypeError('"onDragLeave" callback must be a functions');
}
fileDropOptions._onDragLeaveCallback = onDragLeaveCallback;
}
var object = new FileDrop(fileDropOptions);
object.getOptions = $parse(attributes.options).bind(object, scope);
object.getFilters = () => attributes.filters;
}
};
}
module.exports.$inject = [
'$parse',
'FileUploader',
'FileDrop'
];