-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathfileInput.ts
More file actions
38 lines (32 loc) · 1.19 KB
/
fileInput.ts
File metadata and controls
38 lines (32 loc) · 1.19 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
import { FileInputController } from './fileinput/controller';
import { FileInputUI } from './fileinput/ui';
import { FileInputDropzone } from './fileinput/dropzone';
import { HasMaxFiles } from './fileinput/hasMaxFiles';
import { FileCounter } from './fileinput/fileCounter';
import { FileInputisEmpty } from './fileinput/isEmpty';
class FileInput {
private form: HTMLElement | undefined;
constructor(form: HTMLElement) {
if(form) {
this.form = form;
this.initFileInputs();
}
}
private initFileInputs() {
const fileInputs = this.form?.querySelectorAll('[data-js-file="input"]') || [];
fileInputs.forEach((input) => {
const controller = new FileInputController(input as HTMLInputElement);
const dropzone = input.closest('[data-js-file="dropzone"]') as HTMLElement;
if (dropzone) {
//Main functionality
new FileInputUI(dropzone, controller);
new FileInputDropzone(dropzone, input as HTMLInputElement);
//Detached event listeners
HasMaxFiles(controller, dropzone);
FileCounter(controller, dropzone);
FileInputisEmpty(controller, dropzone);
}
});
}
}
export default FileInput;