NO MORE JQUERY!
This commit is contained in:
parent
cfeb62458e
commit
62a64161c5
10 changed files with 125 additions and 81 deletions
|
|
@ -17,6 +17,7 @@
|
|||
&.rainbow {
|
||||
background: linear-gradient(45deg, #ff0000, #ffb200, #f2ff00, #00c00c, #00d2d0, #0040d2, #a400f6, #f600f1);
|
||||
background-size: 1600% 1600%;
|
||||
color: #252525;
|
||||
|
||||
-webkit-animation: RainbowGradient 30s ease infinite;
|
||||
-moz-animation: RainbowGradient 30s ease infinite;
|
||||
|
|
|
|||
|
|
@ -67,16 +67,29 @@
|
|||
}
|
||||
|
||||
.mobile-menu {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
|
||||
position: fixed;
|
||||
z-index: 1024;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: none;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba($background, 0.95);
|
||||
color: $foreground;
|
||||
|
||||
transition-duration: 200ms, 200ms;
|
||||
transition-property: visibility, opacity;
|
||||
|
||||
&.visible {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
transition-duration: 200ms, 0;
|
||||
transition-property: opacity, visibility;
|
||||
transition-delay: 0, 200ms;
|
||||
}
|
||||
|
||||
.close-mobile-menu {
|
||||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
.modal {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
|
|
@ -13,6 +16,17 @@
|
|||
overflow: auto;
|
||||
background-color: $background;
|
||||
background-color: rgba(0, 0, 0, 0.75);
|
||||
|
||||
transition-duration: 400ms, 400ms;
|
||||
transition-property: visibility, opacity;
|
||||
|
||||
&.visible {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
transition-duration: 400ms, 0;
|
||||
transition-property: opacity, visibility;
|
||||
transition-delay: 0, 400ms;
|
||||
}
|
||||
}
|
||||
|
||||
/* Modal Content */
|
||||
|
|
@ -54,16 +68,20 @@
|
|||
|
||||
/* The Close Button */
|
||||
.close {
|
||||
color: #eeeeee;
|
||||
color: $foreground;
|
||||
float: right;
|
||||
font-size: 28px;
|
||||
font-weight: bold;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
color: #ffffff;
|
||||
color: invert($foreground, 20%);
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.modal-no-scroll {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -443,6 +443,7 @@ img.large {
|
|||
.masthead.gradient.rainbow {
|
||||
background: linear-gradient(45deg, #ff0000, #ffb200, #f2ff00, #00c00c, #00d2d0, #0040d2, #a400f6, #f600f1);
|
||||
background-size: 1600% 1600%;
|
||||
color: #252525;
|
||||
-webkit-animation: RainbowGradient 30s ease infinite;
|
||||
animation: RainbowGradient 30s ease infinite;
|
||||
}
|
||||
|
|
@ -593,15 +594,31 @@ body {
|
|||
}
|
||||
|
||||
.mobile-menu {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
position: fixed;
|
||||
z-index: 1024;
|
||||
top: 0;
|
||||
left: 0;
|
||||
display: none;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba(37, 37, 37, 0.95);
|
||||
color: #eeeeee;
|
||||
-webkit-transition-duration: 200ms, 200ms;
|
||||
transition-duration: 200ms, 200ms;
|
||||
-webkit-transition-property: visibility, opacity;
|
||||
transition-property: visibility, opacity;
|
||||
}
|
||||
|
||||
.mobile-menu.visible {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
-webkit-transition-duration: 200ms, 0;
|
||||
transition-duration: 200ms, 0;
|
||||
-webkit-transition-property: opacity, visibility;
|
||||
transition-property: opacity, visibility;
|
||||
-webkit-transition-delay: 0, 200ms;
|
||||
transition-delay: 0, 200ms;
|
||||
}
|
||||
|
||||
.mobile-menu .close-mobile-menu {
|
||||
|
|
@ -699,6 +716,8 @@ body {
|
|||
}
|
||||
|
||||
.modal {
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
|
|
@ -721,6 +740,21 @@ body {
|
|||
overflow: auto;
|
||||
background-color: #252525;
|
||||
background-color: rgba(0, 0, 0, 0.75);
|
||||
-webkit-transition-duration: 400ms, 400ms;
|
||||
transition-duration: 400ms, 400ms;
|
||||
-webkit-transition-property: visibility, opacity;
|
||||
transition-property: visibility, opacity;
|
||||
}
|
||||
|
||||
.modal.visible {
|
||||
visibility: visible;
|
||||
opacity: 1;
|
||||
-webkit-transition-duration: 400ms, 0;
|
||||
transition-duration: 400ms, 0;
|
||||
-webkit-transition-property: opacity, visibility;
|
||||
transition-property: opacity, visibility;
|
||||
-webkit-transition-delay: 0, 400ms;
|
||||
transition-delay: 0, 400ms;
|
||||
}
|
||||
|
||||
/* Modal Content */
|
||||
|
|
@ -771,11 +805,15 @@ body {
|
|||
}
|
||||
|
||||
.modal-content .close:hover, .modal-content .close:focus {
|
||||
color: #ffffff;
|
||||
color: #c2c2c2;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.modal-no-scroll {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
a,
|
||||
p,
|
||||
h1,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
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");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
12
index.html
12
index.html
|
|
@ -11,8 +11,6 @@
|
|||
|
||||
<link href="Libraries/css/themekit/main.css" rel="stylesheet">
|
||||
|
||||
<script src="Libraries/js/jquery-3.4.1.min.js"></script>
|
||||
<script src="Libraries/js/jquery-ui.min.js"></script>
|
||||
<script src="Libraries/js/themekit/menu.js"></script>
|
||||
<script src="Libraries/js/themekit/modal.js"></script>
|
||||
<title>Juice-UI</title>
|
||||
|
|
@ -174,7 +172,7 @@
|
|||
</div>
|
||||
|
||||
|
||||
<div class="divider"> </div>
|
||||
<div class="wide divider"> </div>
|
||||
|
||||
<div class="container">
|
||||
<h2 class="centered">
|
||||
|
|
@ -253,7 +251,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="divider"> </div>
|
||||
<div class="wide divider"> </div>
|
||||
|
||||
<div class="container">
|
||||
<h2 class="centered">Buttons</h2>
|
||||
|
|
@ -368,7 +366,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
<div class="wide divider"></div>
|
||||
|
||||
<div class="container">
|
||||
<h2 class="centered">
|
||||
|
|
@ -425,7 +423,7 @@
|
|||
src="https://i.ytimg.com/vi/5tjr7g5WFqc/maxresdefault.jpg">
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
<div class="wide divider"></div>
|
||||
|
||||
<h2 class="centered">
|
||||
Cards!
|
||||
|
|
@ -509,7 +507,7 @@
|
|||
This page was written with mobile optimization first!
|
||||
</li>
|
||||
<li>
|
||||
This ThemeKit is written from scratch with minimal JQuery (using DOM where possible)
|
||||
This ThemeKit is written from scratch with minimal <b>NO</b> JQuery (using DOM)
|
||||
</li>
|
||||
<li>
|
||||
This page not only shows you how these things work, but demo to me how they're turning out
|
||||
|
|
|
|||
Loading…
Reference in a new issue