-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
241 lines (198 loc) · 7.36 KB
/
app.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
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
///////////////////// NAVBAR JS ///////////////////////////////////////
const sidenav = document.getElementById("mySidenav")
const openBtn = document.getElementById("openBtn")
const navig = document.getElementsByClassName("sidenav")
const burgerIcon = document.getElementsByClassName("burger-icon")
openBtn.addEventListener("click", () => {
// quand on click sur le burger-menu
sidenav.classList.add("active")
if (sidenav.classList.contains("transitionOut"))
sidenav.classList.remove("transitionOut")
})
document.addEventListener("click", (a) => {
// quand on click n'importe ou sur l ecran
if (
!a.target.closest(".burger-icon") && // on précise tout sauf burger icon
sidenav.classList.contains("active")
) {
sidenav.classList.remove("active")
sidenav.classList.add("transitionOut")
}
})
function removeActive(x) {
if (x.matches) {
sidenav.classList.remove("active")
sidenav.classList.remove("transitionOut")
}
}
const x = window.matchMedia("(min-width: 768px)")
removeActive(x)
x.addListener(removeActive)
//////////////////// NAVBAR JS ///////////////////////////////////////
///////////////////// DROPDONW AND FILTER JS ///////////////////////////////////////
filterSelection("all")
function filterSelection(c) {
let x, i
x = document.querySelectorAll(".filterDiv")
if (c == "all") c == ""
for (i = 0; i < x.length; i++) {
removeClass(x[i], "showFilteredElements")
if (x[i].className.indexOf(c) > -1) addClass(x[i], "showFilteredElements")
}
}
// montrer les elements selectioner
function addClass(element, name) {
let i, arr1, arr2
arr1 = element.className.split(" ")
arr2 = name.split(" ")
for (i = 0; i < arr2.length; i++)
if (arr1.indexOf(arr2[i]) == -1) {
element.className += " " + arr2[i]
}
}
// cacher les elemens non selectione
function removeClass(element, name) {
let i, arr1, arr2
arr1 = element.className.split(" ")
arr2 = name.split(" ")
for (i = 0; i < arr2.length; i++) {
while (arr1.indexOf(arr2[i]) > -1) {
arr1.splice(arr1.indexOf(arr2[i]), 1)
}
}
element.className = arr1.join(" ")
}
//ajout de la classe "active" sur le bouton actuel choisi
let dropDownContainer = document.querySelector("#myDropdown")
let choiceSelection = dropDownContainer.querySelectorAll("a")
choiceSelection.forEach(function (choice) {
choice.addEventListener("click", function () {
myDropDownMenu()
})
})
// cache/montre le contenu du drop down menu
function myDropDownMenu() {
document.getElementById("myDropdown").classList.toggle("show")
}
function filterFunction() {
let input, filter, ul, li, a, i
input = document.getElementById("myInput")
filter = input.value.toUpperCase()
div = document.getElementById("myDropdown")
a = div.getElementsByTagName("a")
for (i = 0; i < a.length; i++) {
txtValue = a[i].textContent || a[i].innerText
if (txtValue.toUpperCase().indexOf(filter) > -1) {
a[i].style.display = ""
} else {
a[i].style.display = "none"
}
}
}
///////////////////// DROPDONW AND FILTER JS ///////////////////////////////////////
///////////////////// Click pop up ////////////////////////////////////////////////
const main = document.querySelector(".main")
const footer = document.querySelector("#bottom")
//when the user click on Auguste picture
const clickAuguste = document.querySelector("#popupAuguste")
const popupAuguste = document.querySelector("#popupBakeryAuguste")
const closeButAuguste = document.querySelector("#close-btnAuguste")
const body = document.querySelector("body")
clickAuguste.addEventListener("click", function () {
popupAuguste.style.display = "flex"
main.classList.add("activePopup")
body.classList.add("bodyActivePopup")
footer.classList.add("activePopup")
})
closeButAuguste.addEventListener("click", function () {
popupAuguste.style.display = "none"
main.classList.remove("activePopup")
body.classList.remove("bodyActivePopup")
footer.classList.remove("activePopup")
})
//when the user click on Toque picture
const clickToque = document.querySelector("#popupToque")
const popupToque = document.querySelector("#popupBakeryToque")
const closeButToque = document.querySelector("#close-btnToque")
clickToque.addEventListener("click", function () {
popupToque.style.display = "flex"
main.classList.add("activePopup")
body.classList.add("bodyActivePopup")
footer.classList.add("activePopup")
})
closeButToque.addEventListener("click", function () {
popupToque.style.display = "none"
main.classList.remove("activePopup")
body.classList.remove("bodyActivePopup")
footer.classList.remove("activePopup")
})
//when the user click on Eric picture
const clickEric = document.querySelector("#popupEric")
const popupEric = document.querySelector("#popupBakeryEric")
const closeButEric = document.querySelector("#close-btnEric")
clickEric.addEventListener("click", function () {
popupEric.style.display = "flex"
main.classList.add("activePopup")
body.classList.add("bodyActivePopup")
footer.classList.add("activePopup")
})
closeButEric.addEventListener("click", function () {
popupEric.style.display = "none"
main.classList.remove("activePopup")
body.classList.remove("bodyActivePopup")
footer.classList.remove("activePopup")
})
//when the user click on Louis picture
const clickLouis = document.querySelector("#popupLouis")
const popupLouis = document.querySelector("#popupBakeryLouis")
const closeButLouis = document.querySelector("#close-btnLouis")
clickLouis.addEventListener("click", function () {
popupLouis.style.display = "flex"
main.classList.add("activePopup")
body.classList.add("bodyActivePopup")
footer.classList.add("activePopup")
})
closeButLouis.addEventListener("click", function () {
popupLouis.style.display = "none"
main.classList.remove("activePopup")
body.classList.remove("bodyActivePopup")
footer.classList.remove("activePopup")
})
//when the user click on Pain picture
const clickPain = document.querySelector("#popupPain")
const popupPain = document.querySelector("#popupBakeryPain")
const closeButPain = document.querySelector("#close-btnPain")
clickPain.addEventListener("click", function () {
popupPain.style.display = "flex"
main.classList.add("activePopup")
body.classList.add("bodyActivePopup")
footer.classList.add("activePopup")
})
closeButPain.addEventListener("click", function () {
popupPain.style.display = "none"
main.classList.remove("activePopup")
body.classList.remove("bodyActivePopup")
footer.classList.remove("activePopup")
})
//when the user click on Boulanger picture
const clickBoulanger = document.querySelector("#popupBoulanger")
const popupBoulanger = document.querySelector("#popupBakeryBoulanger")
const closeButBoulanger = document.querySelector("#close-btnBoulanger")
clickBoulanger.addEventListener("click", function () {
popupBoulanger.style.display = "flex"
main.classList.add("activePopup")
body.classList.add("bodyActivePopup")
footer.classList.add("activePopup")
})
closeButBoulanger.addEventListener("click", function () {
popupBoulanger.style.display = "none"
main.classList.remove("activePopup")
body.classList.remove("bodyActivePopup")
footer.classList.remove("activePopup")
})
///////////////////// Click pop up ////////////////////////////////////////////////
openBtn.addEventListener("click", () => {
sidenav.classList.add("active")
if (sidenav.classList.contains("transitionOut"))
sidenav.classList.remove("transitionOut")
})