-
Notifications
You must be signed in to change notification settings - Fork 0
/
sharedcontent.js
47 lines (38 loc) · 1.39 KB
/
sharedcontent.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
const buttonMobile = document.querySelector('.button-mobile')
const navMobile = document.querySelector('.link-nav-ul')
const userMobile = document.querySelector('.user-photo-head-of-page')
//hamburguer button mobile
function toggleMenu(event) {
if (event.type === 'touchstart') event.preventDefault();
const menuNav = document.querySelector('.menu-nav')
menuNav.classList.toggle('active');
const active = menuNav.classList.contains('active')
event.currentTarget.setAttribute('aria-expended', active)
if (active) {
event.currentTarget.setAttribute('aria-label', 'Fermer Menu')
} else {
event.currentTarget.setAttribute('aria-label', 'Ouvrir Menu')
}
}
buttonMobile.addEventListener('click', toggleMenu)
buttonMobile.addEventListener('touchstart', toggleMenu)
//user profile button mobile
window.addEventListener('resize', mobileManage)
document.onload=mobileManage()
function mobileManage() {
console.log("hello")
let size = window.innerWidth
console.log(size)
if(size < 1024) {
navMobile.append(userMobile)
}else {
document.querySelector('.head-of-page').append(userMobile)
}
}
//function search bar
let inputSearch = document.querySelector('.searchInput')
function changePage(event) {
event.preventDefault()
location.replace("/alura_challenge/communaute.html")
}
inputSearch.addEventListener('submit', changePage)