-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: the popup menu on the mobile layout displays correctly (resolves #…
- Loading branch information
Showing
6 changed files
with
143 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<nav class="primary-nav" aria-labelledby="primary-nav-label"> | ||
<span id="primary-nav-label" class="screen-reader-only">Primary Navigation</span> | ||
{%- for pageItem in collections.pages %} | ||
{%- if pageItem.menu_order > 0 %} | ||
<a {% if page.url === '/' + pageItem.slug + '/' %}aria-current="page" {% endif %}href="/{{ pageItem.slug }}/">{{ pageItem.title }}</a> | ||
{%- endif %} | ||
{%- endfor %} | ||
<a {% if page.url === '/news/' %}aria-current="page" {% endif %}href="/news/">News</a> | ||
<a {% if page.url === '/views/' %}aria-current="page" {% endif %} href="/views/">Views</a> | ||
</nav> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,27 @@ | ||
/* global $, toggleMenu */ | ||
|
||
// Clicking the menu toggle button on the mobile layout opens up the popup menu | ||
// and sets the button "aria-expanded" attribute value properly. | ||
// eslint-disable-next-line | ||
toggleMenu = function (expanded) { | ||
document.getElementById("menuToggleButton").setAttribute("aria-expanded", expanded); | ||
$($(".nav-smallScreen").children("nav.primary-nav")[0]).toggle(expanded); | ||
}; | ||
|
||
// Clicking the menu toggle button on the mobile layout opens up the popup menu. | ||
// Clicking anywhere else closes this popup menu. | ||
document.addEventListener("click", (event) => { | ||
if (event.target.id === "menuToggleButton") { | ||
const expanded = "true" === event.target.getAttribute( "aria-expanded" ) || false; | ||
event.target.setAttribute( "aria-expanded", !expanded ); | ||
const expanded = "true" === event.target.getAttribute("aria-expanded") || false; | ||
toggleMenu(!expanded); | ||
} else { | ||
// click anywhere else on the page closes the pop up menu | ||
document.getElementById("menuToggleButton").setAttribute( "aria-expanded", false ); | ||
toggleMenu(false); | ||
} | ||
}); | ||
|
||
// Clicking the search svg on the header enlarges the search input box and places the focus in it. | ||
// This is required for the mobile layout where the search icon overlays on top of the input field. | ||
document.querySelector(".site-nav .search-container svg").addEventListener("click", () => { | ||
document.querySelector(".site-nav .search-container #search-form input").focus(); | ||
document.querySelector(".site-nav .nav-smallScreen .search-container svg").addEventListener("click", () => { | ||
document.querySelector(".site-nav .nav-smallScreen .search-container #search-form input").focus(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters