blob: 761c29f5cb06b5fe2c1c718a37b9bc3845e59e6c (
plain)
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
|
import { Miscellaneous } from "../config";
export class ModalInstance {
private modalOpen: boolean = false;
private elementId: string = Miscellaneous.MODAL_ID;
private contentId: string = Miscellaneous.MODAL_CONTENT_ID;
public open(content: string) {
const modal = document.getElementById(this.elementId);
const modalContent = document.getElementById(this.contentId);
if (!modal || this.modalOpen) {
return;
}
this.modalOpen = true;
modal.style.display = "flex";
modal.style.animation = "fadeIn 0.25s";
modalContent!.innerHTML = content;
modalContent!.style.animation = "scaleUp 0.25s";
}
public vanish(): Promise<void> {
const modal = document.getElementById(this.elementId);
const modalContent = document.getElementById(this.contentId);
return new Promise((res, _rej) => {
if (!(modal && this.modalOpen && modalContent)) {
res();
return;
}
modal.style.animation = "fadeOut 0.25s";
modalContent.style.animation = "scaleDown 0.25s";
setTimeout(() => {
modalContent.innerHTML = "";
modal.style.display = "none";
this.modalOpen = false;
res();
}, 200);
});
}
}
export const ModalSingleton = new ModalInstance();
|