-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
61 lines (61 loc) · 1.92 KB
/
index.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
const clickBtns = document.querySelectorAll('.buy-ticket');
const modal = document.querySelector('.modal');
const modalOuter = document.querySelector('.buy-container');
const closeBtns = document.querySelectorAll('.js-close');
var headerElement = document.getElementById('header');
var menuBtn = document.getElementById('menu-btn');
let slideIndex = 0;
showSlides();
function showSlides() {
let i;
let slides = document.getElementsByClassName("slider-content");
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slideIndex++;
if (slideIndex > slides.length) {slideIndex = 1}
slides[slideIndex-1].style.display = "block";
setTimeout(showSlides, 3000); // Change image every 2 seconds
}
function showModal() {
modal.classList.remove('hide');
modal.classList.add('show');
}
function hideModal() {
modal.classList.remove('show');
modal.classList.add('hide');
}
function keepModal(event) {
event.stopPropagation();
}
for (let i = 0; i < clickBtns.length; i++) {
clickBtns[i].addEventListener('click', showModal);
}
for (let i = 0; i < closeBtns.length; i++) {
closeBtns[i].addEventListener('click', hideModal);
}
modal.addEventListener('click', hideModal);
modalOuter.addEventListener('click', keepModal);
var headerHeight = headerElement.clientHeight;
menuBtn.onclick = function() {
var isClose = headerElement.clientHeight === headerHeight;
if (isClose) {
headerElement.style.height = "auto";
}
else {
headerElement.style.height = "46px";
}
}
// Automaticly hide menu when click on it
const menuItems = document.querySelectorAll('#nav li a[href*="#"]');
for (let i = 0; i < menuItems.length; i++) {
var item = menuItems[i];
item.onclick = function(event) {
var isParent = this.nextElementSibling && this.nextElementSibling.classList.contains('subNav');
if (isParent) {
event.preventDefault();
}
else
headerElement.style.height = "46px";
}
}