init
This commit is contained in:
commit
8851786e67
353 changed files with 36724 additions and 0 deletions
48
mainapp/static/first/script.js
Executable file
48
mainapp/static/first/script.js
Executable file
|
@ -0,0 +1,48 @@
|
|||
const hamb = document.querySelector("#hamb");
|
||||
const popup = document.querySelector("#popup");
|
||||
const menu = document.querySelector("#menu").cloneNode(1);
|
||||
const body = document.body;
|
||||
|
||||
hamb.addEventListener("click", hambHandler);
|
||||
|
||||
function hambHandler(e) {
|
||||
e.preventDefault();
|
||||
popup.classList.toggle("open");
|
||||
hamb.classList.toggle("active");
|
||||
body.classList.toggle("noscroll");
|
||||
// renderPopup();
|
||||
}
|
||||
|
||||
function renderPopup() {
|
||||
popup.appendChild(menu);
|
||||
}
|
||||
|
||||
// Код для закрытия меню при нажатии на ссылку
|
||||
|
||||
const links = Array.from(menu.children);
|
||||
|
||||
links.forEach((link) => {
|
||||
link.addEventListener("click", closeOnClick);
|
||||
});
|
||||
|
||||
function closeOnClick() {
|
||||
popup.classList.remove("open");
|
||||
hamb.classList.remove("active");
|
||||
body.classList.remove("noscroll");
|
||||
}
|
||||
window.onscroll = function() {scrollFunction()};
|
||||
|
||||
function scrollFunction() {
|
||||
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
|
||||
document.getElementById("myBtn").style.display = "block";
|
||||
} else {
|
||||
document.getElementById("myBtn").style.display = "none";
|
||||
}
|
||||
}
|
||||
|
||||
// When the user clicks on the button, scroll to the top of the document
|
||||
function topFunction() {
|
||||
document.body.scrollTop = 0; // For Safari
|
||||
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue