-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
101 lines (81 loc) · 3.09 KB
/
Copy pathscript.js
File metadata and controls
101 lines (81 loc) · 3.09 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
document.addEventListener('DOMContentLoaded', () => {
// Loader Logic
const loader = document.getElementById('loader');
// Simulate loading time or wait for window load
window.addEventListener('load', () => {
setTimeout(() => {
loader.style.opacity = '0';
setTimeout(() => {
loader.style.display = 'none';
}, 500); // Wait for fade out transition
}, 1000); // Minimum 1 second load time for effect
});
// Mobile Menu Logic
const hamburger = document.querySelector('.hamburger');
const navMenu = document.querySelector('.nav-menu');
const closeMenu = document.querySelector('.close-menu');
const navLinks = document.querySelectorAll('.nav-link');
function toggleMenu() {
navMenu.classList.toggle('active');
document.body.style.overflow = navMenu.classList.contains('active') ? 'hidden' : '';
}
hamburger.addEventListener('click', toggleMenu);
closeMenu.addEventListener('click', toggleMenu);
// Close menu when a link is clicked
navLinks.forEach(link => {
link.addEventListener('click', () => {
if (navMenu.classList.contains('active')) {
toggleMenu();
}
});
});
// Cookie Consent Logic
const cookiePopup = document.getElementById('cookie-popup');
const acceptBtn = document.getElementById('accept-cookies');
const rejectBtn = document.getElementById('reject-cookies');
// Check if user has already made a choice
const cookieConsent = localStorage.getItem('velocitysole_cookie_consent');
if (!cookieConsent) {
// Show popup after a short delay
setTimeout(() => {
cookiePopup.classList.add('show');
}, 2000);
}
acceptBtn.addEventListener('click', () => {
localStorage.setItem('velocitysole_cookie_consent', 'accepted');
cookiePopup.classList.remove('show');
});
rejectBtn.addEventListener('click', () => {
localStorage.setItem('velocitysole_cookie_consent', 'rejected');
cookiePopup.classList.remove('show');
});
// Modal Logic for Footer Links
const modals = {
'impressum-link': 'impressum-popup',
'privacy-link': 'privacy-popup',
'terms-link': 'terms-popup'
};
// Open Modals
for (const [linkId, popupId] of Object.entries(modals)) {
const link = document.getElementById(linkId);
const popup = document.getElementById(popupId);
if (link && popup) {
link.addEventListener('click', (e) => {
e.preventDefault();
popup.classList.add('show');
});
}
}
// Close Modals (X button)
document.querySelectorAll('.close-modal').forEach(closeBtn => {
closeBtn.addEventListener('click', () => {
closeBtn.closest('.modal').classList.remove('show');
});
});
// Close Modals (Click outside)
window.addEventListener('click', (e) => {
if (e.target.classList.contains('modal')) {
e.target.classList.remove('show');
}
});
});