generated from NewcastleRSE/Standard-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
136 lines (112 loc) · 3.62 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
var elementw = document.querySelector(".workstream-2");
var navElement = document.querySelector("nav");
var navLinkElements = document.querySelectorAll(".nav-link");
console.log(elementw);
var primaryColor = "#633188";
var handleClassToggle = (entry) => {
// console.log("toggling entry: ", entry);
entry.target.classList.toggle("visible", entry.isIntersecting);
if (entry.isIntersecting) {
observer.unobserve(entry.target);
}
};
var options = {
root: null,
rootMargin: "0px",
threshold: 0.7,
};
function callback(entries) {
entries.forEach((entry) => {
handleClassToggle(entry);
});
}
let observer = new IntersectionObserver(callback, options);
elems = document.querySelectorAll(".workstream-2,.team-card-3");
for (let i = 0; i < elems.length; i++) {
const e = elems[i];
observer.observe(e);
}
// Changing navbar color on scroll
// console.log(navElement);
// window.addEventListener("scroll", function () {
// if (window.scrollY > 800) {
// console.log("Greater than 250");
// navElement.classList.add("scrolled");
// for (const elem of navLinkElements) {
// elem.classList.add("text-white");
// }
// } else {
// navElement.classList.remove("scrolled");
// for (const elem of navLinkElements) {
// elem.classList.remove("text-white");
// }
// }
// });
// show hamburger menu and change hamburger icon
function openMenu() {
console.log('open')
const closed = document.querySelector("#closedIcon");
const open = document.querySelector("#openIcon");
closed.classList.add("hidden");
open.classList.remove("hidden");
const menu = document.querySelector("#mobile-menu");
menu.classList.remove("hidden");
}
// hide hamburger menu and change hamburger icon
function closeMenu() {
const closed = document.querySelector("#closedIcon");
const open = document.querySelector("#openIcon");
closed.classList.remove("hidden");
open.classList.add("hidden");
const menu = document.querySelector("#mobile-menu");
menu.classList.add("hidden");
}
function toggleDocsDropdown() {
const dropdown = document.querySelector("#docs-dropdown");
dropdown.classList.toggle("hidden");
}
// workstreams accordions
function toggleWorkstreamAcc(id) {
// toggle content
const acc = document.querySelector("#" + id);
acc.classList.toggle("hidden");
// toggle plus sign
const plus = document.querySelector("#plus-" + id);
plus.classList.toggle("hidden");
// toggle minus sign
const minus = document.querySelector("#minus-" + id);
minus.classList.toggle("hidden");
closeOtherWorkstreams(id);
}
function closeOtherWorkstreams(keepOpen) {
for (let i = 1; i < 6; i++) {
const ws = document.querySelector("#workstream-acc-" + i);
if (ws.id !== keepOpen) {
// close content
ws.classList.add("hidden");
// show plus sign
const plus = document.querySelector("#plus-workstream-acc-" + i);
plus.classList.remove("hidden");
// hide minus sign
const minus = document.querySelector("#minus-workstream-acc-" + i);
minus.classList.add("hidden");
}
}
}
// presentations accordion
function togglePresentationAcc() {
// toggle content
const acc = document.querySelector("#pres-content");
acc.classList.toggle("hidden");
// toggle plus sign
const plus = document.querySelector("#plus-pres");
plus.classList.toggle("hidden");
// toggle minus sign
const minus = document.querySelector("#minus-pres" );
minus.classList.toggle("hidden");
}
document.addEventListener("DOMContentLoaded", function(event) {
document.querySelectorAll('img').forEach(function(img){
img.onerror = function(){this.style.display='none';};
})
});