Skip to content

Commit 4451c6b

Browse files
authored
Merge pull request #25 from Simon-Initiative/dev
Dev
2 parents 093e5f2 + 6893426 commit 4451c6b

23 files changed

Lines changed: 320 additions & 256 deletions

File tree

_includes/_navigation.html

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@
55
- Mobile drawer managed by inline JS (no Foundation JS required)
66
{% endcomment %}
77

8-
{% comment %} Keep original nav in DOM (hidden by CSS) so Foundation JS doesn't error {% endcomment %}
8+
{% comment %} Keep original nav element in DOM so Foundation JS does not throw errors,
9+
but do NOT include data-topbar — that would let Foundation JS hijack click events {% endcomment %}
910
<div id="navigation" class="sticky" style="display:none!important;height:0;overflow:hidden" aria-hidden="true">
10-
<nav class="top-bar" role="navigation" data-topbar></nav>
11+
<nav class="top-bar" role="navigation"></nav>
1112
</div>
1213

1314
<!-- ═══ Modern Nav Bar ═══════════════════════════════════════ -->
@@ -136,19 +137,25 @@
136137

137138

138139
<script>
139-
(function () {
140+
// Wait for full page (including Foundation JS) to initialise before
141+
// registering our custom hamburger and dropdown handlers.
142+
document.addEventListener('DOMContentLoaded', function () {
143+
140144
/* ── Hamburger / Mobile Drawer ──────────────────── */
141145
var btn = document.getElementById('easiHamburger');
142146
var drawer = document.getElementById('easi-mobile-drawer');
143147

144148
if (btn && drawer) {
149+
// Use capture phase + stopImmediatePropagation so Foundation JS cannot
150+
// intercept or cancel this click before we handle it.
145151
btn.addEventListener('click', function (e) {
146-
e.stopPropagation();
152+
e.stopImmediatePropagation();
153+
e.preventDefault();
147154
var isOpen = drawer.classList.toggle('open');
148155
btn.classList.toggle('open', isOpen);
149156
btn.setAttribute('aria-expanded', String(isOpen));
150-
drawer.setAttribute('aria-hidden', String(!isOpen));
151-
});
157+
drawer.setAttribute('aria-hidden', String(!isOpen));
158+
}, true); /* capture phase */
152159

153160
// Close drawer on outside click
154161
document.addEventListener('click', function (e) {
@@ -177,17 +184,13 @@
177184
ddTriggers.forEach(function (trigger) {
178185
var parentLi = trigger.parentElement;
179186

180-
// Click on trigger toggles the dropdown
181187
trigger.addEventListener('click', function (e) {
182-
// Only intercept when a dropdown exists on this item
183188
var dropdown = parentLi.querySelector('.easi-dropdown');
184189
if (!dropdown) return;
185-
186-
e.preventDefault(); // stop navigation on the parent link; sub-links still work
190+
e.preventDefault();
187191
var isOpen = parentLi.classList.toggle('dd-open');
188192
trigger.setAttribute('aria-expanded', String(isOpen));
189193

190-
// Close all other open dropdowns
191194
document.querySelectorAll('.easi-nav-links > li.dd-open').forEach(function (li) {
192195
if (li !== parentLi) {
193196
li.classList.remove('dd-open');
@@ -220,5 +223,6 @@
220223
}
221224
});
222225
});
223-
})();
226+
227+
}); /* end DOMContentLoaded */
224228
</script>

_site/404.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100

101101
<div id="navigation" class="sticky" style="display:none!important;height:0;overflow:hidden" aria-hidden="true">
102-
<nav class="top-bar" role="navigation" data-topbar></nav>
102+
<nav class="top-bar" role="navigation"></nav>
103103
</div>
104104

105105
<!-- ═══ Modern Nav Bar ═══════════════════════════════════════ -->
@@ -330,19 +330,25 @@
330330

331331

332332
<script>
333-
(function () {
333+
// Wait for full page (including Foundation JS) to initialise before
334+
// registering our custom hamburger and dropdown handlers.
335+
document.addEventListener('DOMContentLoaded', function () {
336+
334337
/* ── Hamburger / Mobile Drawer ──────────────────── */
335338
var btn = document.getElementById('easiHamburger');
336339
var drawer = document.getElementById('easi-mobile-drawer');
337340

338341
if (btn && drawer) {
342+
// Use capture phase + stopImmediatePropagation so Foundation JS cannot
343+
// intercept or cancel this click before we handle it.
339344
btn.addEventListener('click', function (e) {
340-
e.stopPropagation();
345+
e.stopImmediatePropagation();
346+
e.preventDefault();
341347
var isOpen = drawer.classList.toggle('open');
342348
btn.classList.toggle('open', isOpen);
343349
btn.setAttribute('aria-expanded', String(isOpen));
344-
drawer.setAttribute('aria-hidden', String(!isOpen));
345-
});
350+
drawer.setAttribute('aria-hidden', String(!isOpen));
351+
}, true); /* capture phase */
346352

347353
// Close drawer on outside click
348354
document.addEventListener('click', function (e) {
@@ -371,17 +377,13 @@
371377
ddTriggers.forEach(function (trigger) {
372378
var parentLi = trigger.parentElement;
373379

374-
// Click on trigger toggles the dropdown
375380
trigger.addEventListener('click', function (e) {
376-
// Only intercept when a dropdown exists on this item
377381
var dropdown = parentLi.querySelector('.easi-dropdown');
378382
if (!dropdown) return;
379-
380-
e.preventDefault(); // stop navigation on the parent link; sub-links still work
383+
e.preventDefault();
381384
var isOpen = parentLi.classList.toggle('dd-open');
382385
trigger.setAttribute('aria-expanded', String(isOpen));
383386

384-
// Close all other open dropdowns
385387
document.querySelectorAll('.easi-nav-links > li.dd-open').forEach(function (li) {
386388
if (li !== parentLi) {
387389
li.classList.remove('dd-open');
@@ -414,7 +416,8 @@
414416
}
415417
});
416418
});
417-
})();
419+
420+
}); /* end DOMContentLoaded */
418421
</script>
419422

420423

_site/about/index.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100

101101
<div id="navigation" class="sticky" style="display:none!important;height:0;overflow:hidden" aria-hidden="true">
102-
<nav class="top-bar" role="navigation" data-topbar></nav>
102+
<nav class="top-bar" role="navigation"></nav>
103103
</div>
104104

105105
<!-- ═══ Modern Nav Bar ═══════════════════════════════════════ -->
@@ -330,19 +330,25 @@
330330

331331

332332
<script>
333-
(function () {
333+
// Wait for full page (including Foundation JS) to initialise before
334+
// registering our custom hamburger and dropdown handlers.
335+
document.addEventListener('DOMContentLoaded', function () {
336+
334337
/* ── Hamburger / Mobile Drawer ──────────────────── */
335338
var btn = document.getElementById('easiHamburger');
336339
var drawer = document.getElementById('easi-mobile-drawer');
337340

338341
if (btn && drawer) {
342+
// Use capture phase + stopImmediatePropagation so Foundation JS cannot
343+
// intercept or cancel this click before we handle it.
339344
btn.addEventListener('click', function (e) {
340-
e.stopPropagation();
345+
e.stopImmediatePropagation();
346+
e.preventDefault();
341347
var isOpen = drawer.classList.toggle('open');
342348
btn.classList.toggle('open', isOpen);
343349
btn.setAttribute('aria-expanded', String(isOpen));
344-
drawer.setAttribute('aria-hidden', String(!isOpen));
345-
});
350+
drawer.setAttribute('aria-hidden', String(!isOpen));
351+
}, true); /* capture phase */
346352

347353
// Close drawer on outside click
348354
document.addEventListener('click', function (e) {
@@ -371,17 +377,13 @@
371377
ddTriggers.forEach(function (trigger) {
372378
var parentLi = trigger.parentElement;
373379

374-
// Click on trigger toggles the dropdown
375380
trigger.addEventListener('click', function (e) {
376-
// Only intercept when a dropdown exists on this item
377381
var dropdown = parentLi.querySelector('.easi-dropdown');
378382
if (!dropdown) return;
379-
380-
e.preventDefault(); // stop navigation on the parent link; sub-links still work
383+
e.preventDefault();
381384
var isOpen = parentLi.classList.toggle('dd-open');
382385
trigger.setAttribute('aria-expanded', String(isOpen));
383386

384-
// Close all other open dropdowns
385387
document.querySelectorAll('.easi-nav-links > li.dd-open').forEach(function (li) {
386388
if (li !== parentLi) {
387389
li.classList.remove('dd-open');
@@ -414,7 +416,8 @@
414416
}
415417
});
416418
});
417-
})();
419+
420+
}); /* end DOMContentLoaded */
418421
</script>
419422

420423

_site/adaptive/index.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100

101101
<div id="navigation" class="sticky" style="display:none!important;height:0;overflow:hidden" aria-hidden="true">
102-
<nav class="top-bar" role="navigation" data-topbar></nav>
102+
<nav class="top-bar" role="navigation"></nav>
103103
</div>
104104

105105
<!-- ═══ Modern Nav Bar ═══════════════════════════════════════ -->
@@ -330,19 +330,25 @@
330330

331331

332332
<script>
333-
(function () {
333+
// Wait for full page (including Foundation JS) to initialise before
334+
// registering our custom hamburger and dropdown handlers.
335+
document.addEventListener('DOMContentLoaded', function () {
336+
334337
/* ── Hamburger / Mobile Drawer ──────────────────── */
335338
var btn = document.getElementById('easiHamburger');
336339
var drawer = document.getElementById('easi-mobile-drawer');
337340

338341
if (btn && drawer) {
342+
// Use capture phase + stopImmediatePropagation so Foundation JS cannot
343+
// intercept or cancel this click before we handle it.
339344
btn.addEventListener('click', function (e) {
340-
e.stopPropagation();
345+
e.stopImmediatePropagation();
346+
e.preventDefault();
341347
var isOpen = drawer.classList.toggle('open');
342348
btn.classList.toggle('open', isOpen);
343349
btn.setAttribute('aria-expanded', String(isOpen));
344-
drawer.setAttribute('aria-hidden', String(!isOpen));
345-
});
350+
drawer.setAttribute('aria-hidden', String(!isOpen));
351+
}, true); /* capture phase */
346352

347353
// Close drawer on outside click
348354
document.addEventListener('click', function (e) {
@@ -371,17 +377,13 @@
371377
ddTriggers.forEach(function (trigger) {
372378
var parentLi = trigger.parentElement;
373379

374-
// Click on trigger toggles the dropdown
375380
trigger.addEventListener('click', function (e) {
376-
// Only intercept when a dropdown exists on this item
377381
var dropdown = parentLi.querySelector('.easi-dropdown');
378382
if (!dropdown) return;
379-
380-
e.preventDefault(); // stop navigation on the parent link; sub-links still work
383+
e.preventDefault();
381384
var isOpen = parentLi.classList.toggle('dd-open');
382385
trigger.setAttribute('aria-expanded', String(isOpen));
383386

384-
// Close all other open dropdowns
385387
document.querySelectorAll('.easi-nav-links > li.dd-open').forEach(function (li) {
386388
if (li !== parentLi) {
387389
li.classList.remove('dd-open');
@@ -414,7 +416,8 @@
414416
}
415417
});
416418
});
417-
})();
419+
420+
}); /* end DOMContentLoaded */
418421
</script>
419422

420423

_site/agenda/index.html

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@
9999

100100

101101
<div id="navigation" class="sticky" style="display:none!important;height:0;overflow:hidden" aria-hidden="true">
102-
<nav class="top-bar" role="navigation" data-topbar></nav>
102+
<nav class="top-bar" role="navigation"></nav>
103103
</div>
104104

105105
<!-- ═══ Modern Nav Bar ═══════════════════════════════════════ -->
@@ -330,19 +330,25 @@
330330

331331

332332
<script>
333-
(function () {
333+
// Wait for full page (including Foundation JS) to initialise before
334+
// registering our custom hamburger and dropdown handlers.
335+
document.addEventListener('DOMContentLoaded', function () {
336+
334337
/* ── Hamburger / Mobile Drawer ──────────────────── */
335338
var btn = document.getElementById('easiHamburger');
336339
var drawer = document.getElementById('easi-mobile-drawer');
337340

338341
if (btn && drawer) {
342+
// Use capture phase + stopImmediatePropagation so Foundation JS cannot
343+
// intercept or cancel this click before we handle it.
339344
btn.addEventListener('click', function (e) {
340-
e.stopPropagation();
345+
e.stopImmediatePropagation();
346+
e.preventDefault();
341347
var isOpen = drawer.classList.toggle('open');
342348
btn.classList.toggle('open', isOpen);
343349
btn.setAttribute('aria-expanded', String(isOpen));
344-
drawer.setAttribute('aria-hidden', String(!isOpen));
345-
});
350+
drawer.setAttribute('aria-hidden', String(!isOpen));
351+
}, true); /* capture phase */
346352

347353
// Close drawer on outside click
348354
document.addEventListener('click', function (e) {
@@ -371,17 +377,13 @@
371377
ddTriggers.forEach(function (trigger) {
372378
var parentLi = trigger.parentElement;
373379

374-
// Click on trigger toggles the dropdown
375380
trigger.addEventListener('click', function (e) {
376-
// Only intercept when a dropdown exists on this item
377381
var dropdown = parentLi.querySelector('.easi-dropdown');
378382
if (!dropdown) return;
379-
380-
e.preventDefault(); // stop navigation on the parent link; sub-links still work
383+
e.preventDefault();
381384
var isOpen = parentLi.classList.toggle('dd-open');
382385
trigger.setAttribute('aria-expanded', String(isOpen));
383386

384-
// Close all other open dropdowns
385387
document.querySelectorAll('.easi-nav-links > li.dd-open').forEach(function (li) {
386388
if (li !== parentLi) {
387389
li.classList.remove('dd-open');
@@ -414,7 +416,8 @@
414416
}
415417
});
416418
});
417-
})();
419+
420+
}); /* end DOMContentLoaded */
418421
</script>
419422

420423

0 commit comments

Comments
 (0)