Skip to content
Snippets Groups Projects
Verified Commit 2c341998 authored by Owen Graham's avatar Owen Graham
Browse files

Replace abused `<a>`s with `<button>`s

parent da3f3c77
No related branches found
No related tags found
No related merge requests found
...@@ -42,11 +42,18 @@ body.embedded #plotter { ...@@ -42,11 +42,18 @@ body.embedded #plotter {
display: block; display: block;
} }
#plotter-nav a { #plotter-nav a,
#plotter-nav button {
background: none;
color: inherit;
cursor: pointer;
display: block; display: block;
font-family: inherit;
font-size: 1rem;
margin: 8px; margin: 8px;
padding: 7px; padding: 7px;
border: 1px solid black; border: 1px solid black;
text-decoration: none;
width: 256px; width: 256px;
max-width: 256px; max-width: 256px;
} }
... ...
......
// Don't allow opening other embed pages in a new tab. // Don't allow opening other embed pages in a new tab.
if (EMBEDDED) { if (EMBEDDED) {
// Replace each nav hyperlink with a button.
document.querySelectorAll('#plotter-nav a').forEach(a => { document.querySelectorAll('#plotter-nav a').forEach(a => {
const href = a.getAttribute('href'); const href = a.getAttribute('href');
a.removeAttribute('href'); const button = document.createElement('button');
a.tabIndex = 0; button.innerHTML = a.innerHTML;
a.onclick = () => { const ARIA_CURRENT = 'aria-current';
if (a.hasAttribute(ARIA_CURRENT)) {
const ariaCurrent = a.getAttribute(ARIA_CURRENT);
button.setAttribute(ARIA_CURRENT, ariaCurrent);
}
button.onclick = () => {
location = href; location = href;
}; };
a.parentNode.replaceChild(button, a);
}); });
} }
// Set results of initial selections. // Set results of initial selections.
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment