-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
39 lines (31 loc) · 1.13 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
var mainButtons = document.querySelectorAll('.main-mobile__button-text');
var footerLanguages = document.querySelectorAll('.footer__language');
for (let i = 0; i < mainButtons.length; i++) {
//mainButtons[i].innerHTML = mainButtons[i].dataset.filter;
clickControlMainButton(mainButtons[i]);
}
footerLanguages.forEach(footer__language => {
clickControlLanguage(footer__language);
});
function toggleActiveMainButton(control) {
for (let j = 0; j < mainButtons.length; j++) {
mainButtons[j].classList.remove('main-mobile__button-text--active');
}
control.classList.add('main-mobile__button-text--active');
}
function toggleActiveLanguage(control) {
for (let j = 0; j < footerLanguages.length; j++) {
footerLanguages[j].classList.remove('footer__language--active');
}
control.classList.add('footer__language--active');
}
function clickControlMainButton(control) {
control.addEventListener('click', function() {
toggleActiveMainButton(control);
});
}
function clickControlLanguage(control) {
control.addEventListener('click', function() {
toggleActiveLanguage(control);
});
}