-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontroller.js
More file actions
21 lines (17 loc) · 848 Bytes
/
controller.js
File metadata and controls
21 lines (17 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
window.onload = () => {
const navMenu = document.querySelector('.nav-menu');
const navItems = document.querySelectorAll('.nav-item');
const hamburger = document.querySelector('.nav-toggle');
const toggle = e => e.classList.toggle('is-active');
const toggleNav = ({ target }) => Array.from(navMenu.classList).includes('is-active') ? toggle(navMenu) : null;
hamburger.addEventListener('click', () => toggle(navMenu, 'is-active'));
Array.from(navItems).forEach(e => e.addEventListener('click', toggleNav));
}
function copyToClipboard(text) {
var textarea = document.createElement("textarea");
textarea.textContent = text;
document.body.appendChild(textarea);
textarea.select();
document.execCommand("copy");
document.body.removeChild(textarea);
}