-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
128 lines (108 loc) · 2.91 KB
/
Copy pathscript.js
File metadata and controls
128 lines (108 loc) · 2.91 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
$('.owl-carousel').owlCarousel({
loop: true,
margin: 25,
nav: false,
responsive: {
100: {
items: 1,
},
600: {
items: 2,
},
800: {
items: 3,
},
1000: {
items: 4,
},
},
});
jQuery(document).ready(function ($) {
var alterClass = function () {
var ww = document.body.clientWidth;
if (ww < 964) {
$('.nav-listitem').addClass('disable');
$('.nav-dropdown li').addClass('disable');
} else if (ww >= 964) {
$('.nav-listitem').removeClass('disable');
$('.nav-dropdown li').removeClass('disable');
}
};
$(window).resize(function () {
alterClass();
});
//Fire it when the page first loads:
alterClass();
});
const navItems = document.querySelectorAll('.nav-listitem');
function removeShow(arr, item) {
arr.forEach((element) => {
if (element !== item) {
element.classList.remove('show');
}
});
}
function removeRotate(arr, item) {
arr.forEach((element) => {
if (element !== item) {
element.classList.remove('rotate');
}
});
}
navItems.forEach((item) => {
item.addEventListener('click', () => {
removeShow(navItems, item);
item.classList.toggle('show');
removeRotate(navItems, item);
item.classList.toggle('rotate');
});
});
const carouselSlide = document.querySelector('.slides');
const slides = document.querySelectorAll('.slide');
const thumbnails = document.querySelectorAll('.thumb');
function removeActive(arr) {
arr.forEach((item) => item.classList.remove('active'));
}
thumbnails.forEach((thumb, index) => {
thumb.addEventListener('click', () => {
removeActive(thumbnails);
thumb.classList.add('active');
showSlide(index);
});
});
let counter = 0;
const size = slides[0].clientWidth;
function showSlide(index) {
console.log(size * index);
counter = index;
carouselSlide.style.transform = 'translateX(' + -size * counter + 'px)';
}
const burger = document.querySelector('.burger');
const nav = document.querySelector('.nav-links');
const navSlide = () => {
burger.addEventListener('click', () => {
nav.style.opacity = '1';
nav.classList.toggle('burger-active');
});
};
navSlide();
const closeBtn = document.querySelector('.close-btn');
closeBtn.addEventListener('click', () => nav.classList.remove('burger-active'));
//Get the button:
mybutton = document.getElementById('top');
// When the user scrolls down 20px from the top of the document, show the button
window.onscroll = function () {
scrollFunction();
};
function scrollFunction() {
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
mybutton.style.transform = 'scale(1)';
} else {
mybutton.style.transform = 'scale(0)';
}
}
// When the user clicks on the button, scroll to the top of the document
function topFunction() {
document.body.scrollTop = 0; // For Safari
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}