forked from l0bster2/pocket-platformer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeaderNavigationHandler.js
51 lines (48 loc) · 1.86 KB
/
HeaderNavigationHandler.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
function navDropDownClick(event, id = "myDropdown") {
event.stopPropagation();
const collection = document.getElementsByClassName("dropdown-content");
if(collection.length) {
for (let element of collection) {
if(element.id && element.id !== id) {
closeSpecificDropdown(element.id);
}
}
}
document.getElementById(id).classList.toggle("show");
}
function changeView(value) {
if(value === "sounds") {
document.getElementById("gameView").style.display = "none";
document.getElementById("soundView").style.display = "flex";
document.getElementById("gameViewCheckmark").style.display = "none";
document.getElementById("soundViewCheckmark").style.display = "block";
SoundHandlerRenderer.createSoundOverview();
}
else {
document.getElementById("gameView").style.display = "block";
document.getElementById("soundView").style.display = "none";
document.getElementById("gameViewCheckmark").style.display = "block";
document.getElementById("soundViewCheckmark").style.display = "none";
SoundHandler.checkSongOnLevelReset(tileMapHandler.currentLevel);
}
SoundHandler.stopAllSounds();
}
function closeSpecificDropdown(id) {
var myDropdown = document.getElementById(id);
if (myDropdown.classList.contains('show')) {
myDropdown.classList.remove('show');
}
}
// Close the dropdown if the user clicks outside of it
window.onclick = function (e) {
if (!e.target.matches('.dropbtn') && !e.target.matches('.dropdown-nav-item')) {
const collection = document.getElementsByClassName("dropdown-content");
if(collection.length) {
for (let element of collection) {
if(element.id) {
closeSpecificDropdown(element.id);
}
}
}
}
}