-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathedit.js
More file actions
41 lines (35 loc) · 1.55 KB
/
Copy pathedit.js
File metadata and controls
41 lines (35 loc) · 1.55 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
document.addEventListener('DOMContentLoaded', () => {
const buttons = document.querySelectorAll('.edit-button');
const overlay = document.querySelector('.modal-overlay')
buttons.forEach(button => {
const parentDiv = button.closest('div');
const editDialog = parentDiv.querySelector('.edit-dialog');
// Show dialog when the button is clicked
button.addEventListener('click', (event) => {
event.preventDefault(); // Prevent the form from submitting
event.stopPropagation(); // Prevent the click from bubbling up
editDialog.style.display = 'block';
overlay.style.display = 'block'
});
// Close dialog when clicking the exit button inside the dialog
const exitButton = editDialog.querySelector('.exit-button');
if (exitButton) {
exitButton.addEventListener('click', (event) => {
event.preventDefault();
editDialog.style.display = 'none';
overlay.style.display = 'none'
});
}
// Close dialog when clicking outside the dialog
document.addEventListener('click', (event) => {
if (!editDialog.contains(event.target) && !button.contains(event.target)) {
editDialog.style.display = 'none';
overlay.style.display = 'none'
}
});
// Prevent the click inside the dialog from closing it
editDialog.addEventListener('click', (event) => {
event.stopPropagation();
});
});
});