-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
74 lines (64 loc) · 2.06 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
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
function E(selector, parent){
if(selector instanceof HTMLElement)
return selector;
return (parent || document).querySelectorAll(selector);
}
function hasClass(element, className){
return element.classList.contains(className);
}
function radioClass(element, className){
E("." + className).forEach((elem) =>
elem.classList.remove(className));
element.classList.toggle(className);
}
function tabs(nav){
let navElem = E(nav)[0];
navElem.addEventListener("click", (e) => {
let target = e.target;
if(hasClass(target, "tab"))
radioClass(target, "active");
let linkedTab = E("." + target.id)[0];
radioClass(linkedTab, "visible");
});
let active = E(".tab.active")[0];
if (active){
radioClass(E("."+active.id)[0], "visible");
}
}
tabs(" .menu-nav");
let loadMoreBtn1 = document.querySelector('#load-more-1');
let currentItem1 = 4;
loadMoreBtn1.onclick = () => {
let boxes = [...document.querySelectorAll('.box-container-1 .box-1')];
for(var i = currentItem1; i < currentItem1 + 4; i++ ){
boxes[i].style.display = 'inline-block';
}
currentItem1 += 4;
if (currentItem1 >= boxes.length){
loadMoreBtn1.style.display = 'none'
}
}
let loadMoreBtn2 = document.querySelector('#load-more-2');
let currentItem2 = 4;
loadMoreBtn2.onclick = () => {
let boxes = [...document.querySelectorAll('.box-container-2 .box-2')];
for(var i = currentItem2; i < currentItem2 + 4; i++ ){
boxes[i].style.display = 'inline-block';
}
currentItem2 += 4;
if (currentItem2 >= boxes.length){
loadMoreBtn2.style.display = 'none'
}
}
let loadMoreBtn3 = document.querySelector('#load-more-3');
let currentItem3 = 4;
loadMoreBtn3.onclick = () => {
let boxes = [...document.querySelectorAll('.box-container-3 .box-3')];
for(var i = currentItem3; i < currentItem3 + 4; i++ ){
boxes[i].style.display = 'inline-block';
}
currentItem3 += 4;
if (currentItem3 >= boxes.length){
loadMoreBtn3.style.display = 'none'
}
}