-
Notifications
You must be signed in to change notification settings - Fork 0
/
DeleteMsgScript.js
43 lines (40 loc) · 1.63 KB
/
DeleteMsgScript.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
function askToDelete(a) {
const deleteMsg = document.getElementById('deleteBlock');
let text = "Do you want to delete " + "'" + a + "'";
let leftPos = ((container1.offsetWidth) + ((container2.offsetWidth - 360)) / 2);
deleteMsg.style.left = leftPos.toString() + 'px';
window.addEventListener('resize', function () {
let leftPos = ((container1.offsetWidth) + ((container2.offsetWidth - 360)) / 2);
deleteMsg.style.left = leftPos.toString() + 'px';
resizeDeleteMsg();
})
document.getElementById('warningMsg').textContent = text;
document.getElementById('x').addEventListener('click', function () {
deleteMsg.style.display = "none";
revertBody();
});
document.getElementById('no').addEventListener('click', function () {
deleteMsg.style.display = "none";
revertBody();
});
document.getElementById('yes').addEventListener('click', function () {
deleteExpense();
deleteStoredExpense(clickedExpenseOriginalId);
deleteMsg.style.display = "none";
revertBody();
})
blurBody();
deleteMsg.style.display = "block";
resizeDeleteMsg();
function resizeDeleteMsg() {
const mediaQuery = window.matchMedia("(max-width: 690px)")
if (mediaQuery.matches) {
leftPos = ((container2.offsetWidth) / 2) - 180;
deleteMsg.style.left = leftPos.toString() + 'px';
deleteMsg.style.position = "fixed";
} else {
leftPos = ((container1.offsetWidth) + ((container2.offsetWidth - 360)) / 2);
deleteMsg.style.left = leftPos.toString() + 'px';
}
}
}