-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
102 lines (92 loc) · 2.6 KB
/
script.js
File metadata and controls
102 lines (92 loc) · 2.6 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Script för att lösa språkalternativet i sidebaren i headern.
document
.getElementById("btn-language-mobile")
.addEventListener("click", function (event) {
event.preventDefault(); // prevent the default action
var languageOptions = document.getElementById("languages");
if (languageOptions.style.display === "none") {
languageOptions.style.display = "block";
} else {
languageOptions.style.display = "none";
}
});
const glide = new Glide(".glide", {
type: "carousel",
breakpoints: {
1800: {
perView: 3,
},
1300: {
autoplay: 0,
perView: 3,
},
1024: {
autoplay: 3000,
perView: 2,
rewind: true,
},
768: {
autoplay: 3000,
perView: 1,
rewind: true,
},
},
});
// Funktion för att ändra paginationsglidern till orange vid aktivt läge.
const glideBullets = document.querySelectorAll(".glidebullet");
glide.on("run", function () {
const activeIndex = glide.index;
glideBullets.forEach(function (bullet, index) {
if (index === activeIndex) {
bullet.classList.add("glidebullet-active");
} else {
bullet.classList.remove("glidebullet-active");
}
});
});
glide.mount();
//Footer Collapse börjar här
let collapseButton = document.getElementsByClassName("footerButton");
//expandera och kollapsa footer
function toggleVisibility() {
this.classList.toggle("visible");
let buttonContent = this.nextElementSibling;
if (this.classList.contains("visible")) {
buttonContent.style.maxHeight = buttonContent.scrollHeight + "px";
} else {
buttonContent.style.maxHeight = null;
}
}
//Ser till att footerknappen inte funkar, utan allt content syns, när fönstret är större än 768px
function updateButtonListeners() {
for (let i = 0; i < collapseButton.length; i++) {
let buttonContent = collapseButton[i].nextElementSibling;
if (window.innerWidth <= 768) {
collapseButton[i].addEventListener("click", toggleVisibility);
buttonContent.style.maxHeight = null;
} else {
collapseButton[i].removeEventListener("click", toggleVisibility);
buttonContent.style.maxHeight = buttonContent.scrollHeight + "px";
}
}
}
updateButtonListeners();
//Ser till att footern uppdateras när fönstret ändrar storlek
window.addEventListener("resize", updateButtonListeners);
//info section swiper
const swiper = new Swiper("#swiper1", {
loop: true,
pagination: {
el: "#swiper1 .swiper-pagination",
},
breakpoints: {
645: {
slidesPerView: 2,
spaceBetween: 0,
},
950: {
slidesPerView: 3,
spaceBetween: 0,
},
},
});