-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscripts.js
More file actions
108 lines (96 loc) · 3.36 KB
/
Copy pathscripts.js
File metadata and controls
108 lines (96 loc) · 3.36 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
102
103
104
105
106
107
108
window.addEventListener('scroll', () => {
const nav = document.querySelector('nav');
if(window.scrollY > window.innerHeight * 0.5) {
nav.classList.add('scrolled');
} else {
nav.classList.remove('scrolled');
}
});
(function(){
const hamburger = document.getElementById('nav-hamburger');
const menu = document.getElementById('mobile-menu');
if(!hamburger || !menu) return;
hamburger.addEventListener('click', () => {
menu.classList.toggle('open');
hamburger.classList.toggle('open');
});
menu.querySelectorAll('a').forEach(link => {
link.addEventListener('click', () => {
menu.classList.remove('open');
hamburger.classList.remove('open');
});
});
})();
(function(){
const targets = [
document.querySelector('.newsletter-headline'),
document.querySelector('.newsletter-sub'),
document.querySelector('.newsletter-name-row'),
document.querySelector('.newsletter-form-row'),
].filter(Boolean);
const obs = new IntersectionObserver(entries => {
if(entries[0].isIntersecting){
targets.forEach(el => el.classList.add('nl-in'));
obs.disconnect();
}
}, { threshold: 0.15 });
const section = document.getElementById('newsletter');
if(section) obs.observe(section);
})();
(function(){
const submitBtn = document.getElementById('nl-submit');
const firstInput = document.getElementById('nl-firstname');
const lastInput = document.getElementById('nl-lastname');
const emailInput = document.getElementById('nl-email');
const errorMsg = document.getElementById('nl-error');
const formWrap = document.getElementById('newsletter-form-wrap');
const successWrap = document.getElementById('newsletter-success');
if(!submitBtn) return;
function isValidEmail(val){
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(val);
}
submitBtn.addEventListener('click', () => {
let valid = true;
[firstInput, lastInput, emailInput].forEach(el => {
el.classList.remove('error');
});
errorMsg.classList.remove('visible');
if(!firstInput.value.trim()){ firstInput.classList.add('error'); valid = false; }
if(!lastInput.value.trim()){ lastInput.classList.add('error'); valid = false; }
if(!emailInput.value.trim() || !isValidEmail(emailInput.value)){
emailInput.classList.add('error'); valid = false;
}
if(!valid){
errorMsg.classList.add('visible');
return;
}
formWrap.style.transition = 'opacity 0.4s ease';
formWrap.style.opacity = '0';
setTimeout(() => {
formWrap.style.display = 'none';
successWrap.style.display = 'flex';
requestAnimationFrame(() => {
successWrap.classList.add('visible');
});
}, 400);
});
})();
function getWalletLink() {
const ua = navigator.userAgent || navigator.vendor || window.opera;
if (/android/i.test(ua)) {
return 'https://play.google.com/store/apps/details?id=com.quantus.wallet';
}
if (/iPad|iPhone|iPod/.test(ua) && !window.MSStream) {
return 'https://apps.apple.com/us/app/quantus/id6747967405';
}
if (/Mac/.test(navigator.platform)) {
return 'https://apps.apple.com/us/app/quantus/id6747967405';
}
return 'https://play.google.com/store/apps/details?id=com.quantus.wallet';
}
window.addEventListener('load', () => {
const walletLink = getWalletLink();
document.querySelectorAll('.wallet-cta-link').forEach(el => {
el.href = walletLink;
});
});