-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjs.js
45 lines (37 loc) · 1.4 KB
/
js.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
function myFunction() {
var popup = document.getElementById("myPopup");
popup.classList.toggle("show");
};
const primaryNav = document.querySelector(".primary-navigation");
const navToggle = document.querySelector(" .mobile-nav-toggle");
navToggle.addEventListener("click" , () => {
const visibility = primaryNav.getAttribute("data-visible")
if (visibility === "false") {
primaryNav.setAttribute("data-visible", true);
}
else if (visibility === "true") {
primaryNav.setAttribute("data-visible", false);
}
});
/* Performance Page*/
const categoryTitle = document.querySelectorAll('.category-title');
const allCategoryPosts = document.querySelectorAll('.all');
for(let i = 0; i < categoryTitle.length; i++){
categoryTitle[i].addEventListener('click', filterPosts.bind(this, categoryTitle[i]));
}
function filterPosts(item){
changeActivePosition(item);
for(let i = 0; i < allCategoryPosts.length; i++){
if(allCategoryPosts[i].classList.contains(item.attributes.id.value)){
allCategoryPosts[i].style.display = "inline-flex";
} else {
allCategoryPosts[i].style.display = "none";
}
}
}
function changeActivePosition(activeItem){
for(let i = 0; i < categoryTitle.length; i++){
categoryTitle[i].classList.remove('active');
}
activeItem.classList.add('active');
};