-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
86 lines (78 loc) · 2.5 KB
/
main.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
const isMobile = {
Android: function () {
return navigator.userAgent.match(/Android/i);
},
BlackBerry: function () {
return navigator.userAgent.match(/BlackBerry/i);
},
iOs: function () {
return navigator.userAgent.match(/iPhone|iPad|iPod/i);
},
Opera: function () {
return navigator.userAgent.match(/Opera Mini/i);
},
Windows: function () {
return navigator.userAgent.match(/IEMobile/i);
},
any: function () {
return (
isMobile.Android()||
isMobile.BlackBerry()||
isMobile.iOs()||
isMobile.Opera()||
isMobile.Windows());
}
};
if (isMobile.any()) {
document.body.classList.add('_touch');
let menuArrows = document.querySelectorAll('.menu__arrow');
if (menuArrows.length > 0) {
for (let index = 0; index < menuArrows.length; index++){
const menuArrow = menuArrows[index];
menuArrow.addEventListener("click", function (e) {
menuArrow.parentElement.classList.toggle('_active');
});
}
}
}else{
document.body.classList.add('_pc');
}
const iconMenu = document.querySelector('.menu__icon');
if(iconMenu){
const menuBody = document.querySelector('.menu__body');
iconMenu.addEventListener("click", function (e) {
document.body.classList.toggle('_lock');
iconMenu.classList.toggle('_active');
menuBody.classList.toggle('_active');
});
}
const menuLinks = document.querySelectorAll('.menu__link[data-goto]');
if (menuLinks.length > 0) {
menuLinks.forEach(menuLink => {
menuLink.addEventListener("click", onMenuLinkClick);
});
function onMenuLinkClick(e) {
const menuLink = e.target;
if (menuLink.dataset.goto && document.querySelector(menuLink.dataset.goto)) {
const gotoBlock = document.querySelector(menuLink.dataset.goto);
const gotoBlockValue = gotoBlock.getBoundingClientRect().top + pageYOffset - document.querySelector('header').offsetHeight;
window.scrollTo({
top: gotoBlockValue,
behavior: "smooth"
});
e.preventDefault();
}
}
}
$(document).ready(function(){
$("#btn1").click(function(){
$("#header__logo").hide();
$("#div22").show();
});
});
$(document).ready(function(){
$("#btn22-00").click(function(){
$("#header__logo").show();
$("#div22").hide();
});
});