create-template-html-css 1.1.1 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,69 +1,74 @@
|
|
|
1
|
-
//
|
|
2
|
-
document.
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
// Wait for DOM to load
|
|
2
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
3
|
+
// Open modal
|
|
4
|
+
document.querySelectorAll('[data-modal]').forEach(button => {
|
|
5
|
+
button.addEventListener('click', function() {
|
|
6
|
+
const modalId = this.getAttribute('data-modal');
|
|
7
|
+
const modal = document.getElementById(modalId);
|
|
8
|
+
if (modal) {
|
|
9
|
+
modal.classList.add('active');
|
|
10
|
+
}
|
|
11
|
+
});
|
|
7
12
|
});
|
|
8
|
-
});
|
|
9
13
|
|
|
10
|
-
// Close modal on X click
|
|
11
|
-
document.querySelectorAll('.modal-close').forEach(closeBtn => {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
// Close modal on X click
|
|
15
|
+
document.querySelectorAll('.modal-close').forEach(closeBtn => {
|
|
16
|
+
closeBtn.addEventListener('click', function() {
|
|
17
|
+
this.closest('.modal').classList.remove('active');
|
|
18
|
+
});
|
|
14
19
|
});
|
|
15
|
-
});
|
|
16
20
|
|
|
17
|
-
// Close modal on outside click
|
|
18
|
-
document.querySelectorAll('.modal').forEach(modal => {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
// Close modal on outside click
|
|
22
|
+
document.querySelectorAll('.modal').forEach(modal => {
|
|
23
|
+
modal.addEventListener('click', function(e) {
|
|
24
|
+
if (e.target === this) {
|
|
25
|
+
this.classList.remove('active');
|
|
26
|
+
}
|
|
27
|
+
});
|
|
23
28
|
});
|
|
24
|
-
});
|
|
25
29
|
|
|
26
|
-
// Close modal on button click
|
|
27
|
-
document.querySelectorAll('.modal-btn').forEach(button => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
// Close modal on button click
|
|
31
|
+
document.querySelectorAll('.modal-btn').forEach(button => {
|
|
32
|
+
button.addEventListener('click', function(e) {
|
|
33
|
+
if (!this.type || this.type !== 'submit') {
|
|
34
|
+
this.closest('.modal').classList.remove('active');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
32
37
|
});
|
|
33
|
-
});
|
|
34
38
|
|
|
35
|
-
// Handle form submission
|
|
36
|
-
document.querySelectorAll('.modal-form').forEach(form => {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
39
|
+
// Handle form submission
|
|
40
|
+
document.querySelectorAll('.modal-form').forEach(form => {
|
|
41
|
+
form.addEventListener('submit', function(e) {
|
|
42
|
+
e.preventDefault();
|
|
43
|
+
console.log('Form submitted');
|
|
44
|
+
alert('Form submitted successfully!');
|
|
45
|
+
this.closest('.modal').classList.remove('active');
|
|
46
|
+
this.reset();
|
|
47
|
+
});
|
|
43
48
|
});
|
|
44
|
-
});
|
|
45
49
|
|
|
46
|
-
// Cancel button
|
|
47
|
-
document.querySelectorAll('.btn-cancel').forEach(button => {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
// Cancel button
|
|
51
|
+
document.querySelectorAll('.btn-cancel').forEach(button => {
|
|
52
|
+
button.addEventListener('click', function() {
|
|
53
|
+
this.closest('.modal').classList.remove('active');
|
|
54
|
+
});
|
|
50
55
|
});
|
|
51
|
-
});
|
|
52
56
|
|
|
53
|
-
// Confirm button
|
|
54
|
-
document.querySelectorAll('.btn-confirm').forEach(button => {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// Confirm button
|
|
58
|
+
document.querySelectorAll('.btn-confirm').forEach(button => {
|
|
59
|
+
button.addEventListener('click', function() {
|
|
60
|
+
console.log('Action confirmed');
|
|
61
|
+
alert('Item deleted successfully');
|
|
62
|
+
this.closest('.modal').classList.remove('active');
|
|
63
|
+
});
|
|
59
64
|
});
|
|
60
|
-
});
|
|
61
65
|
|
|
62
|
-
// Close modal on ESC key
|
|
63
|
-
document.addEventListener('keydown', function(e) {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
66
|
+
// Close modal on ESC key
|
|
67
|
+
document.addEventListener('keydown', function(e) {
|
|
68
|
+
if (e.key === 'Escape') {
|
|
69
|
+
document.querySelectorAll('.modal.active').forEach(modal => {
|
|
70
|
+
modal.classList.remove('active');
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
});
|
|
69
74
|
});
|