-
Notifications
You must be signed in to change notification settings - Fork 1
/
modal.js
60 lines (53 loc) · 2.01 KB
/
modal.js
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
cssCode = fs.readFileSync("modal.css", {
"encoding": "utf-8"
}) // * Read the CSS code
code = `
<div id='modalMain' hidden>
<div id='modalTitle'></div>
<div id='modalMessage'></div>
<br>
<button id='buttonConfirm' class='cta'>Ok</button> <button id='buttonConfirm' class='grey' onclick=killModalPopup()>Cancel</button>
</div>
` // * The HTML Code for a popup
popupDataIsThere = false
function dataInit() {
if (!popupDataIsThere) {
this.document.head.innerHTML += "<style>"+cssCode+"</style>"
this.document.body.innerHTML += code
popupDataIsThere = true
}
}
function killModalPopup() {
document.getElementById('modalMain').classList.remove('red')
setTimeout(function () {document.getElementById('modalMain').hidden = true}, 510)
flyOut('modalMain', 500)
}
function errorModal(title, message, command) {
document.getElementById('modalMain').hidden = false
document.getElementById('modalMain').classList.add('red')
document.getElementById('modalTitle').innerHTML = title
document.getElementById('modalMessage').innerHTML = message
document.getElementById('buttonConfirm').onclick = function () {
command()
killModalPopup()
}
}
function confirmModal(title, message, command) {
document.getElementById('modalMain').hidden = false
document.getElementById('modalTitle').innerHTML = title
document.getElementById('modalMessage').innerHTML = message
document.getElementById('buttonConfirm').onclick = function () {
command()
killModalPopup()
}
}
function confirmModalWarning(title, message, command) {
document.getElementById('modalMain').hidden = false
document.getElementById('modalTitle').innerHTML = title
document.getElementById('modalMessage').innerHTML = message
document.getElementById('buttonConfirm').onclick = function () {
command()
killModalPopup()
}
document.getElementById('buttonConfirm').classList.add("red")
}