Repository navigation
Expand file tree
/
Copy pathmain.js
More file actions
337 lines (297 loc) · 11.1 KB
/
Copy pathmain.js
File metadata and controls
337 lines (297 loc) · 11.1 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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
/**
* SPDX-License-Identifier: Apache-2.0 OR MIT
* Visage Interactive Client Engine — Bank Statement Parser
*/
'use strict';
(function () {
var root = document.documentElement;
/* 1. Visage 3-State Theme Engine */
function applyTheme(mode) {
if (mode === 'system') {
root.removeAttribute('data-theme');
try { localStorage.removeItem('theme'); } catch (e) {}
} else {
root.setAttribute('data-theme', mode);
try { localStorage.setItem('theme', mode); } catch (e) {}
}
var state = document.getElementById('mode-state');
if (state) {
state.textContent = mode.charAt(0).toUpperCase() + mode.slice(1);
}
}
var modeToggle = document.getElementById('mode-toggle');
if (modeToggle) {
var order = ['system', 'light', 'dark'];
function currentMode() {
var val = root.getAttribute('data-theme');
return val === 'light' || val === 'dark' ? val : 'system';
}
modeToggle.addEventListener('click', function () {
var next = order[(order.indexOf(currentMode()) + 1) % order.length];
applyTheme(next);
});
}
/* 2. Responsive Navigation Drawer */
var navToggle = document.getElementById('navToggle') || document.getElementById('navbarToggle');
var navMenu = document.getElementById('navMenu') || document.getElementById('navbarMenu');
function navbarToggle(open) {
if (!navToggle || !navMenu) return;
navToggle.setAttribute('aria-expanded', String(open));
navMenu.setAttribute('data-open', String(open));
}
if (navToggle && navMenu) {
navbarToggle(false);
navToggle.addEventListener('click', function () {
var isOpen = navToggle.getAttribute('aria-expanded') === 'true';
navbarToggle(!isOpen);
});
navMenu.addEventListener('click', function (e) {
if (e.target.closest('a')) navbarToggle(false);
});
document.addEventListener('keydown', function (e) {
if (e.key === 'Escape' && navToggle.getAttribute('aria-expanded') === 'true') {
navbarToggle(false);
navToggle.focus();
}
});
document.addEventListener('click', function (e) {
if (!navMenu.contains(e.target) && !navToggle.contains(e.target)) {
navbarToggle(false);
}
});
}
/* 3. Search Modal Controller */
function searchModal(open) {
var modal = document.getElementById('searchModal');
if (modal) {
modal.classList.toggle('active', open);
}
}
window.searchModal = searchModal;
/* Remove extraneous search button if SSG injects one */
var searchWidget = document.getElementById('ssg-search-widget');
var searchButton = document.getElementById('ssg-search-btn');
if (searchWidget) searchWidget.remove();
else if (searchButton) searchButton.remove();
/* 4. Apple-Grade Interactive FAQ Controller */
function initFaqController() {
var searchInput = document.getElementById('faqSearchInput');
var filterPills = document.querySelectorAll('.faq-pill');
var countLabel = document.getElementById('faqCountLabel');
var toggleAllBtn = document.getElementById('faqToggleAllBtn');
var faqCards = document.querySelectorAll('.faq-card');
var noResults = document.getElementById('faqNoResults');
var resetBtn = document.getElementById('faqResetBtn');
if (!faqCards.length) return;
var currentCategory = 'all';
var currentQuery = '';
var totalCount = faqCards.length;
function applyFilters() {
var visibleCount = 0;
var query = currentQuery.toLowerCase().trim();
faqCards.forEach(function (card) {
var cardCategory = card.getAttribute('data-category') || '';
var categoryMatch = (currentCategory === 'all') || (cardCategory === currentCategory);
var textContent = (card.textContent || '').toLowerCase();
var searchMatch = !query || textContent.indexOf(query) !== -1;
if (categoryMatch && searchMatch) {
card.style.display = '';
visibleCount++;
} else {
card.style.display = 'none';
}
});
// Update count label
if (countLabel) {
if (query) {
countLabel.textContent = 'Showing ' + visibleCount + ' of ' + totalCount + ' questions for "' + currentQuery.trim() + '"';
} else if (currentCategory !== 'all') {
var activePill = document.querySelector('.faq-pill.active');
var catName = activePill ? activePill.childNodes[0].textContent.trim() : currentCategory;
countLabel.textContent = 'Showing ' + visibleCount + ' of ' + totalCount + ' questions in ' + catName;
} else {
countLabel.textContent = 'Showing ' + visibleCount + ' of ' + totalCount + ' questions';
}
}
// Show / hide no results placeholder
if (noResults) {
if (visibleCount === 0) {
noResults.classList.add('visible');
} else {
noResults.classList.remove('visible');
}
}
// Auto-open matched cards if few results
if (query && visibleCount <= 3 && visibleCount > 0) {
faqCards.forEach(function (card) {
if (card.style.display !== 'none') {
card.open = true;
}
});
}
}
// Keyword Search Listener
if (searchInput) {
searchInput.addEventListener('input', function (e) {
currentQuery = e.target.value;
applyFilters();
});
searchInput.addEventListener('keydown', function (e) {
if (e.key === 'Escape') {
searchInput.value = '';
currentQuery = '';
applyFilters();
}
});
}
// Category Filter Pills Listener
filterPills.forEach(function (pill) {
pill.addEventListener('click', function () {
filterPills.forEach(function (p) { p.classList.remove('active'); });
pill.classList.add('active');
currentCategory = pill.getAttribute('data-filter') || 'all';
applyFilters();
});
});
// Expand / Collapse All Toggle Listener
if (toggleAllBtn) {
toggleAllBtn.addEventListener('click', function () {
var isExpanded = toggleAllBtn.getAttribute('aria-expanded') === 'true';
var nextState = !isExpanded;
toggleAllBtn.setAttribute('aria-expanded', String(nextState));
var btnText = toggleAllBtn.querySelector('.btn-text');
if (btnText) {
btnText.textContent = nextState ? 'Collapse all' : 'Expand all';
}
faqCards.forEach(function (card) {
if (card.style.display !== 'none') {
card.open = nextState;
}
});
});
}
// Reset Button Listener
if (resetBtn) {
resetBtn.addEventListener('click', function () {
if (searchInput) searchInput.value = '';
currentQuery = '';
currentCategory = 'all';
filterPills.forEach(function (p) {
if (p.getAttribute('data-filter') === 'all') {
p.classList.add('active');
} else {
p.classList.remove('active');
}
});
applyFilters();
});
}
}
/* 5. Apple Vision Pro Spatial Dynamics & Scroll Effects */
function initSpatialEffects() {
root.classList.add('js-ready');
// A. Sticky Header Frost & Scroll Indicator Controller
var header = document.querySelector('.site-header');
var isHeroPage = !!document.querySelector('.hero-spatial');
var scrollIndicator = document.querySelector('.hero-scroll-indicator');
var heroPhoto = document.querySelector('.hero-bg-photo');
var heroContent = document.querySelector('.hero-spatial .hero-content');
var prefersReducedMotion = window.matchMedia && window.matchMedia('(prefers-reduced-motion: reduce)').matches;
if (header && isHeroPage) {
header.classList.add('on-hero');
}
var ticking = false;
function onScroll() {
var scrollY = window.pageYOffset || document.documentElement.scrollTop;
if (header) {
if (scrollY > 20) {
header.classList.add('scrolled');
if (isHeroPage) header.classList.remove('on-hero');
} else {
header.classList.remove('scrolled');
if (isHeroPage) header.classList.add('on-hero');
}
}
if (scrollIndicator) {
if (scrollY > 50) {
scrollIndicator.style.opacity = '0';
scrollIndicator.style.pointerEvents = 'none';
} else {
scrollIndicator.style.opacity = '';
scrollIndicator.style.pointerEvents = '';
}
}
// Parallax scroll fallback if CSS scroll-timeline is unsupported and motion allowed
var hasCssScrollTimeline = window.CSS && window.CSS.supports && window.CSS.supports('animation-timeline', 'scroll()');
if (!prefersReducedMotion && heroPhoto && !hasCssScrollTimeline) {
var vh = window.innerHeight || 800;
if (scrollY <= vh) {
var ratio = scrollY / vh;
heroPhoto.style.transform = 'scale(' + (1.03 + ratio * 0.12) + ') translate3d(0, ' + (scrollY * 0.25) + 'px, 0)';
if (heroContent) {
heroContent.style.opacity = String(1 - ratio * 0.85);
heroContent.style.transform = 'translate3d(0, ' + (scrollY * 0.35) + 'px, 0)';
}
}
}
ticking = false;
}
window.addEventListener('scroll', function () {
if (!ticking) {
window.requestAnimationFrame(onScroll);
ticking = true;
}
}, { passive: true });
onScroll();
// B. VisionOS Specular Cursor Tracking
var glassElements = document.querySelectorAll(
'.trust-strip li, .three-cells article, .process-grid article, .consultation-card, .terminal-box'
);
glassElements.forEach(function (el) {
el.addEventListener('pointermove', function (e) {
var rect = el.getBoundingClientRect();
var x = e.clientX - rect.left;
var y = e.clientY - rect.top;
el.style.setProperty('--mouse-x', x + 'px');
el.style.setProperty('--mouse-y', y + 'px');
}, { passive: true });
});
// C. Scroll-Reveal via IntersectionObserver
var revealTargets = document.querySelectorAll(
'.trust-strip li, .terminal-box, .three-cells article, .process-grid article, .consultation-card'
);
if ('IntersectionObserver' in window && !prefersReducedMotion) {
var revealObserver = new IntersectionObserver(function (entries, observer) {
entries.forEach(function (entry) {
if (entry.isIntersecting) {
entry.target.classList.add('in-view');
observer.unobserve(entry.target);
}
});
}, {
rootMargin: '0px 0px -40px 0px',
threshold: 0.15
});
revealTargets.forEach(function (el, index) {
el.classList.add('scroll-reveal');
// Gentle stagger for adjacent grid items
var delay = (index % 4) * 0.08;
el.style.transitionDelay = delay + 's';
revealObserver.observe(el);
});
} else {
revealTargets.forEach(function (el) {
el.classList.add('scroll-reveal', 'in-view');
});
}
}
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', function () {
initFaqController();
initSpatialEffects();
});
} else {
initFaqController();
initSpatialEffects();
}
})();