NO MORE JQUERY!
This commit is contained in:
parent
cfeb62458e
commit
62a64161c5
10 changed files with 125 additions and 81 deletions
2
Libraries/js/jquery-3.4.1.min.js
vendored
2
Libraries/js/jquery-3.4.1.min.js
vendored
File diff suppressed because one or more lines are too long
13
Libraries/js/jquery-ui.min.js
vendored
13
Libraries/js/jquery-ui.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -1,24 +1,8 @@
|
|||
const rotate = ($elem, angle) => {
|
||||
$({ deg: 0 }).animate({ deg: angle }, {
|
||||
duration: 150,
|
||||
step: function (now) {
|
||||
$elem.css({
|
||||
transform: 'rotate(' + now + 'deg)'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Uses ZERO Jquery!!
|
||||
*/
|
||||
|
||||
const unrotate = ($elem, angle) => {
|
||||
$({ deg: angle }).animate({ deg: 0 }, {
|
||||
duration: 150,
|
||||
step: function (now) {
|
||||
$elem.css({
|
||||
transform: 'rotate(' + now + 'deg)'
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
let menuOpen = false;
|
||||
|
||||
const toggleSubMenu = (el) => {
|
||||
$(`[for="${el.getAttribute("from")}"`).toggle("slide", "down");
|
||||
|
|
@ -27,29 +11,30 @@ const toggleSubMenu = (el) => {
|
|||
let isOpen = icon.hasAttribute("submenuOpen") ? parseInt(icon.getAttribute("submenuOpen")) : 0;
|
||||
|
||||
if (isOpen == 1) {
|
||||
unrotate($(icon), 90);
|
||||
icon.style.transition = "transform ease-in-out 250ms";
|
||||
icon.style.transform = "rotate(0deg)";
|
||||
icon.setAttribute("submenuOpen", 0);
|
||||
} else { // Not open..
|
||||
rotate($(icon), 90);
|
||||
icon.style.transition = "transform ease-in-out 250ms";
|
||||
icon.style.transform = "rotate(90deg)";
|
||||
icon.setAttribute("submenuOpen", 1);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleMenu = () => {
|
||||
$(".mobile-menu").toggle("slide", "left", () => {
|
||||
|
||||
let visible = document.querySelector(".mobile-menu").style.display != "none";
|
||||
|
||||
if (visible) {
|
||||
document.body.classList.add("no-scroll");
|
||||
} else {
|
||||
document.body.classList.remove("no-scroll");
|
||||
}
|
||||
});
|
||||
let menu = document.querySelector(".mobile-menu");
|
||||
menuOpen = !menuOpen;
|
||||
|
||||
if (menuOpen) {
|
||||
menu.classList.add("visible");
|
||||
document.body.classList.add("no-scroll");
|
||||
} else {
|
||||
menu.classList.remove("visible");
|
||||
document.body.classList.remove("no-scroll");
|
||||
}
|
||||
};
|
||||
|
||||
$(document).ready(() => {
|
||||
window.addEventListener("DOMContentLoaded", (evt) => {
|
||||
document.querySelectorAll(".compact.submenu.item").forEach((el) => {
|
||||
let id = `subMenu_${new Date().getMilliseconds()}`;
|
||||
el.setAttribute("from", id);
|
||||
|
|
|
|||
|
|
@ -1,37 +1,43 @@
|
|||
$(document).ready(() => {
|
||||
// Close when clicking on *not* the modal-contents
|
||||
window.addEventListener("DOMContentLoaded", (evt) => {
|
||||
window.onclick = (event) => {
|
||||
if (event.target.classList.contains("modal")) {
|
||||
$(event.target).hide("fade", {
|
||||
direction: "out",
|
||||
}, 300);
|
||||
document.body.classList.remove("no-scroll");
|
||||
let modal = event.target;
|
||||
modal.classList.remove("visible");
|
||||
modal.removeAttribute("active");
|
||||
document.body.classList.remove("modal-no-scroll");
|
||||
}
|
||||
};
|
||||
|
||||
document.querySelectorAll(".modal .close").forEach((closeBtn) => {
|
||||
closeBtn.addEventListener('click', (evt) => {
|
||||
$(closeBtn.parentElement.parentElement).hide("fade", {
|
||||
direction: "out",
|
||||
}, 300);
|
||||
document.body.classList.remove("no-scroll");
|
||||
let modal = closeBtn.parentElement.parentElement;
|
||||
modal.classList.remove("visible");
|
||||
modal.removeAttribute("active");
|
||||
document.body.classList.remove("modal-no-scroll");
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll("[for-modal]").forEach((modalTrigerEl) => {
|
||||
modalTrigerEl.addEventListener('click', (evt) => {
|
||||
// document.getElementById(modalTrigerEl.getAttribute("for-modal")).style.display = "flex";
|
||||
$(`#${modalTrigerEl.getAttribute("for-modal")}`).show("fade", {
|
||||
direction: "in",
|
||||
}, 300);
|
||||
document.body.classList.add("no-scroll");
|
||||
let modal = document.getElementById(modalTrigerEl.getAttribute("for-modal"));
|
||||
modal.classList.add("visible");
|
||||
modal.setAttribute("active", "");
|
||||
document.body.classList.add("modal-no-scroll");
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$(document).ready(() => {
|
||||
document.querySelectorAll("[for-modal]").forEach((modalTrigerEl) => {
|
||||
$(`#${modalTrigerEl.getAttribute("for-modal")}`).hide();
|
||||
let modal = document.getElementById(modalTrigerEl.getAttribute("for-modal"));
|
||||
modal.classList.remove("visible");
|
||||
modal.removeAttribute("active");
|
||||
});
|
||||
|
||||
document.body.addEventListener('keydown', (evt) => {
|
||||
if (evt.key == "Escape") {
|
||||
let modal = document.querySelector(".modal[active]");
|
||||
modal.classList.remove("visible");
|
||||
modal.removeAttribute("active");
|
||||
document.body.classList.remove("modal-no-scroll");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue