-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
65 lines (56 loc) · 2.42 KB
/
script.js
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
// offcanvas functionality
let hamburgerMenuBtn = document.getElementById(`hamburgerMenuBtn`)
let offcanvasContent = document.getElementsByClassName(`offcanvas`)
let offcanvasCloseBtn = document.getElementById(`offcanvas-close-btn`)
function openOffcanvas(e) {
e.preventDefault()
offcanvasContent[0].classList.add(`show`)
}
function closeOffcanvas (e) {
e.preventDefault()
offcanvasContent[0].classList.remove(`show`)
}
hamburgerMenuBtn.addEventListener(`click`, openOffcanvas)
offcanvasCloseBtn.addEventListener(`click`, closeOffcanvas)
// list group/collapse functionality
let listGroupItems = document.getElementsByClassName(`list-group-item`)
let adnetCollapse = document.getElementById(`adnet`)
let attainCollapse = document.getElementById(`attain`)
let bestInClassCollapse = document.getElementById(`best-in-class`)
let edibleArrangementsCollapse = document.getElementById(`edible-arrangements`)
function activateListGroupItem (e) {
e.preventDefault()
for (let i=0; i < listGroupItems.length; i++) {
let listItem = listGroupItems[i]
listItem.classList.remove(`active`)
listItem.setAttribute(`aria-current`,`false`)
}
e.target.classList.add(`active`)
e.target.setAttribute(`aria-current`,`true`)
if (e.target.id === `adnet-collapse`) {
adnetCollapse.classList.add(`show`)
attainCollapse.classList.remove(`show`)
bestInClassCollapse.classList.remove(`show`)
edibleArrangementsCollapse.classList.remove(`show`)
} else if (e.target.id === `attain-collapse`) {
adnetCollapse.classList.remove(`show`)
attainCollapse.classList.add(`show`)
bestInClassCollapse.classList.remove(`show`)
edibleArrangementsCollapse.classList.remove(`show`)
} else if (e.target.id === `best-in-class-collapse`) {
adnetCollapse.classList.remove(`show`)
attainCollapse.classList.remove(`show`)
bestInClassCollapse.classList.add(`show`)
edibleArrangementsCollapse.classList.remove(`show`)
} else if (e.target.id === `edible-arrangements-collapse`) {
adnetCollapse.classList.remove(`show`)
attainCollapse.classList.remove(`show`)
bestInClassCollapse.classList.remove(`show`)
edibleArrangementsCollapse.classList.add(`show`)
} else {
console.log(`error`)
}
}
for (let i = 0; i < listGroupItems.length; i++) {
listGroupItems[i].addEventListener(`click`, activateListGroupItem)
}