Repository navigation
Expand file tree
/
Copy pathvalidation.js
More file actions
56 lines (56 loc) · 2.14 KB
/
Copy pathvalidation.js
File metadata and controls
56 lines (56 loc) · 2.14 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
56
this.default = function () {
var dropElement = document.getElementsByClassName('control-fluid')[0];
// Initialize the control with file validation
var uploadObj = new ej.inputs.Uploader({
autoUpload: false,
minFileSize: 10000,
allowedExtensions: '.doc, .docx, .xls, .xlsx',
asyncSettings: {
saveUrl: 'https://aspnetmvc.syncfusion.com/services/api/uploadbox/Save',
removeUrl: 'https://aspnetmvc.syncfusion.com/services/api/uploadbox/Remove'
},
selected: onFileSelected,
success: onUploadSuccess,
dropArea: dropElement
});
uploadObj.appendTo('#validation');
function onFileSelected(args) {
// Filter the 5 files only to showcase
args.filesData.splice(5);
var filesData = uploadObj.getFilesData();
var allFiles = filesData.concat(args.filesData);
if (allFiles.length > 5) {
for (var i = 0; i < allFiles.length; i++) {
if (allFiles.length > 5) {
allFiles.shift();
}
}
args.filesData = allFiles;
// set the modified custom data
args.modifiedFilesData = args.filesData;
}
args.isModified = true;
}
function onUploadSuccess(args) {
var _this = this;
var li = this.uploadWrapper.querySelector('[data-file-name="' + args.file.name + '"]');
if (args.operation === 'upload') {
li.querySelector('.e-file-delete-btn').onclick = function () {
generateSpinner(_this.uploadWrapper);
};
li.querySelector('.e-file-delete-btn').onkeydown = function (e) {
if (e.keyCode === 13) {
generateSpinner(e.target.closest('.e-upload'));
}
};
}
else {
ej.popups.hideSpinner(this.uploadWrapper);
ej.base.detach(this.uploadWrapper.querySelector('.e-spinner-pane'));
}
}
function generateSpinner(targetElement) {
ej.popups.createSpinner({ target: targetElement, width: '25px' });
ej.popups.showSpinner(targetElement);
}
};