-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
100 lines (81 loc) · 2.5 KB
/
script.js
File metadata and controls
100 lines (81 loc) · 2.5 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
// highlight menu for max-width 1024px
const navIconEl = document.getElementById("navIcon-el");
const navHiglight = document.querySelector(".nav-highlight");
const highlightEl = document.getElementById("highlight-el");
navIconEl.addEventListener("click", function () {
navHiglight.classList.add("nav-highlight-active");
});
highlightEl.addEventListener("click", function () {
if (navHiglight.classList.contains("nav-highlight-active")) {
navHiglight.classList.remove("nav-highlight-active");
}
});
// animation for carousel
const dot1 = document.querySelector("#dot1");
const dot2 = document.querySelector("#dot2");
const dot3 = document.querySelector("#dot3");
const slide1 = document.querySelector("#slide1");
const slide2 = document.querySelector("#slide2");
const slide3 = document.querySelector("#slide3");
const activeSlide = () => {
let active = document.querySelector(".header-content__img--active");
active.classList.remove("header-content__img--active");
};
const addActicveClass = (slide) => {
slide.classList.add("header-content__img--active");
};
const dotArray = [];
function colorDot(dot) {
for (const ch of dotArray) {
if (ch !== dot) {
ch.setAttribute("src", "./images/dot-gray.png");
} else {
dot.setAttribute("src", "./images/dot-white.png");
}
}
}
const showSlide1 = () => {
addActicveClass(slide1);
colorDot(dot1);
};
const showSlide2 = () => {
addActicveClass(slide2);
colorDot(dot2);
};
const showSlide3 = () => {
addActicveClass(slide3);
colorDot(dot3);
};
dot1.addEventListener("click", () => {
dotArray.push(dot1);
activeSlide();
showSlide1();
});
dot2.addEventListener("click", () => {
dotArray.push(dot2);
activeSlide();
showSlide2();
dot2.setAttribute("src", "./images/dot-white.png");
});
dot3.addEventListener("click", () => {
dotArray.push(dot3);
activeSlide();
showSlide3();
});
// highlight button for donate in section Header and Event
const headerBtn = document.getElementById("header-btn");
const eventBtn1 = document.getElementById("event-btn1");
const eventBtn2 = document.getElementById("event-btn2");
headerBtn.addEventListener("click", () => {
donateBtn(headerBtn);
});
eventBtn1.addEventListener("click", () => {
donateBtn(eventBtn1);
});
eventBtn2.addEventListener("click", () => {
donateBtn(eventBtn2);
});
function donateBtn(event) {
event.textContent = "THANK YOU";
event.style.background = "goldenrod";
}