-
Notifications
You must be signed in to change notification settings - Fork 82
Expand file tree
/
Copy pathnav.js
More file actions
84 lines (69 loc) · 2.25 KB
/
Copy pathnav.js
File metadata and controls
84 lines (69 loc) · 2.25 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
document.body.addEventListener('click', function (event) {
if (event.target.dataset.section) {
handleSectionTrigger(event)
} else if (event.target.dataset.modal) {
handleModalTrigger(event)
} else if (event.target.classList.contains('modal-hide')) {
hideAllModals()
}
});
function handleSectionTrigger(event) {
hideAllSectionsAndDeselectButtons();
// Highlight clicked button and show view
event.target.classList.add('is-selected');
// Display the current section
const sectionId = event.target.dataset.section + '-section';
const section = document.getElementById(sectionId);
if (!!section) {
section.classList.add('is-shown');
}
}
function activateDefaultSection () {
document.getElementById('button-windows').click()
}
function showMainContent() {
showNav();
document.querySelector('.js-content').classList.add('is-shown');
}
function handleModalTrigger(event) {
hideAllModals();
const modalId = event.target.dataset.modal + '-modal';
if (modalId === 'about-modal') {
hideNav();
}
document.getElementById(modalId).classList.add('is-shown');
}
function hideAllModals () {
const modals = document.querySelectorAll('.modal.is-shown')
Array.prototype.forEach.call(modals, function (modal) {
modal.classList.remove('is-shown')
})
showMainContent()
}
function hideAllSectionsAndDeselectButtons () {
const sections = document.querySelectorAll('.js-section.is-shown')
Array.prototype.forEach.call(sections, function (section) {
section.classList.remove('is-shown')
})
const buttons = document.querySelectorAll('.nav-button.is-selected')
Array.prototype.forEach.call(buttons, function (button) {
button.classList.remove('is-selected')
})
}
function displayAbout() {
hideNav();
const modal = document.querySelector('#about-modal');
if (!!modal) {
modal.classList.add('is-shown');
}
}
function hideNav() {
document.querySelector('.js-nav').classList.remove('is-shown');
document.querySelector('.js-nav').style.display = 'none';
}
function showNav() {
document.querySelector('.js-nav').style.display = null;
document.querySelector('.js-nav').classList.add('is-shown');
}
activateDefaultSection();
displayAbout();