-
-
Notifications
You must be signed in to change notification settings - Fork 50
/
index.js
90 lines (59 loc) · 2.33 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
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
const RESPONSIVE_WIDTH = 1024
gsap.registerPlugin(ScrollTrigger)
let headerWhiteBg = false
let isHeaderCollapsed = window.innerWidth < 1024
const collapseHeaderItems = document.getElementById("collapsed-items")
const collapseBtn = document.getElementById("collapse-btn")
const menuItemContainer = document.querySelectorAll(".menu-item-container")
menuItemContainer.forEach(e => {
const img = e.querySelector("img")
e.addEventListener("mouseenter", () => {
img.style.scale = 1.1
})
e.addEventListener("mouseleave", () => {
img.style.scale = 1
})
})
const reviewContainer = document.querySelector(".review-container")
const reviewSlideShow = new SlideShow(reviewContainer, true, 10000)
function onHeaderClickOutside(e) {
if (!collapseHeaderItems.contains(e.target)) {
toggleHeader()
}
}
function toggleHeader() {
if (isHeaderCollapsed) {
// collapseHeaderItems.classList.remove("max-md:tw-opacity-0")
collapseHeaderItems.classList.add("!tw-opacity-100",)
collapseHeaderItems.style.width = "60vw"
collapseBtn.classList.remove("bi-list", "primary-text-color")
collapseBtn.classList.add("bi-x")
isHeaderCollapsed = false
setTimeout(() => window.addEventListener("click", onHeaderClickOutside), 1)
} else {
collapseHeaderItems.classList.remove("!tw-opacity-100")
collapseHeaderItems.style.width = "0vw"
collapseBtn.classList.remove("bi-x")
collapseBtn.classList.add("bi-list", headerWhiteBg ? "primary-text-color" : null)
isHeaderCollapsed = true
window.removeEventListener("click", onHeaderClickOutside)
}
}
function responsive() {
if (window.innerWidth > RESPONSIVE_WIDTH) {
collapseHeaderItems.style.width = ""
}else{
isHeaderCollapsed = true
collapseBtn.classList.add("bi-list", headerWhiteBg ? "primary-text-color" : null)
}
}
// function
window.addEventListener("resize", responsive)
const bookingDate = document.querySelector("#date")
const today = new Date().toISOString().split('T')[0]
bookingDate.setAttribute('min', today)
const timings = document.querySelector("#timings")
for (let x=7; x < 20; x+=0.30){
const nextTime = `${x.toFixed(2)}`.replace(".", ":")
timings.innerHTML += `<option value="${nextTime}">${nextTime}</option>`
}