forked from GCA-Classroom/01-pet-fostering-cta
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
73 lines (66 loc) · 2.34 KB
/
script.js
File metadata and controls
73 lines (66 loc) · 2.34 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// script.js
document.addEventListener('DOMContentLoaded', function () {
const form = document.getElementById('newsletter-form');
if (form) {
form.addEventListener('submit', function (e) {
e.preventDefault();
const emailInput = document.getElementById('newsletter-email');
if (emailInput && emailInput.value) {
showCelebrationPopup(emailInput.value);
emailInput.value = '';
}
});
}
function showCelebrationPopup(email) {
// Create overlay
const overlay = document.createElement('div');
overlay.style.position = 'fixed';
overlay.style.top = 0;
overlay.style.left = 0;
overlay.style.width = '100vw';
overlay.style.height = '100vh';
overlay.style.background = 'rgba(0,0,0,0.3)';
overlay.style.display = 'flex';
overlay.style.alignItems = 'center';
overlay.style.justifyContent = 'center';
overlay.style.zIndex = 9999;
// Create popup box
const popup = document.createElement('div');
popup.style.background = '#fff';
popup.style.borderRadius = '20px';
popup.style.boxShadow = '0 4px 24px rgba(0,0,0,0.15)';
popup.style.padding = '2em 2.5em';
popup.style.textAlign = 'center';
popup.style.position = 'relative';
popup.style.minWidth = '300px';
// Cute emoji confetti
const confetti = document.createElement('div');
confetti.style.fontSize = '2.2em';
confetti.style.marginBottom = '0.5em';
confetti.innerText = '🎉✨🐾🎊';
popup.appendChild(confetti);
// Message
const msg = document.createElement('div');
msg.style.fontSize = '1.2em';
msg.style.marginBottom = '0.7em';
msg.innerHTML = `Thank you for subscribing,<br><b>${email}</b>!`;
popup.appendChild(msg);
// Close button
const closeBtn = document.createElement('button');
closeBtn.innerText = 'Close';
closeBtn.style.background = '#ffb347';
closeBtn.style.color = '#fff';
closeBtn.style.border = 'none';
closeBtn.style.borderRadius = '10px';
closeBtn.style.padding = '0.5em 1.5em';
closeBtn.style.fontSize = '1em';
closeBtn.style.cursor = 'pointer';
closeBtn.style.marginTop = '0.5em';
closeBtn.addEventListener('click', function () {
document.body.removeChild(overlay);
});
popup.appendChild(closeBtn);
overlay.appendChild(popup);
document.body.appendChild(overlay);
}
});