-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
75 lines (68 loc) · 2.11 KB
/
script.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
document.addEventListener('DOMContentLoaded', () => {
const modal = document.getElementById('modal');
const modalContent = document.getElementById('modal-content-container');
const stepCards = document.querySelectorAll('.step-card');
const closeModal = document.querySelector('.close-modal');
// Add modal styles
const modalStyle = document.createElement('style');
modalStyle.textContent = `
.modal {
display: none;
position: fixed;
z-index: 1000;
left: 0;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.5);
}
.modal-content {
background-color: #f8f8f8;
margin: 5% auto;
padding: 20px;
width: 90%;
max-width: 1200px;
position: relative;
max-height: 90vh;
overflow-y: auto;
border-radius: 10px;
}
.close-modal {
position: absolute;
right: 20px;
top: 10px;
font-size: 28px;
font-weight: bold;
cursor: pointer;
}
`;
document.head.appendChild(modalStyle);
// Add click handlers to all cards
stepCards.forEach(card => {
card.addEventListener('click', () => {
console.log('Card clicked');
const cardSrc = card.getAttribute('data-card-src');
console.log('Card src:', cardSrc);
fetch(cardSrc)
.then(response => response.text())
.then(content => {
modalContent.innerHTML = content;
modal.style.display = 'block';
})
.catch(error => {
console.error('Error loading content:', error);
modalContent.innerHTML = 'Error loading content';
});
});
});
// Close modal when clicking X
closeModal.addEventListener('click', () => {
modal.style.display = 'none';
});
// Close modal when clicking outside
window.addEventListener('click', (event) => {
if (event.target === modal) {
modal.style.display = 'none';
}
});
});