legendary-doc-site/apps/app/assets/js/app.js

58 lines
1.5 KiB
JavaScript
Raw Normal View History

2020-07-29 17:07:36 +00:00
// We need to import the CSS so that webpack will load it.
// The MiniCssExtractPlugin is used to separate it out into
// its own CSS file.
2021-07-20 22:13:36 +00:00
import "../css/app.css";
2020-07-29 17:07:36 +00:00
// webpack automatically bundles all modules in your
// entry points. Those entry points can be configured
// in "webpack.config.js".
//
// Import deps with the dep name or local files with a relative path, for example:
//
// import {Socket} from "phoenix"
// import socket from "./socket"
//
2021-07-20 22:13:36 +00:00
import "phoenix_html";
import "alpinejs";
import "./live";
import { ready } from "./utils";
var bloop;
function togglePasswordFieldVisibility() {
const passwordFields = document.querySelectorAll('[name="user[password]"]');
passwordFields.forEach((el) => {
2021-07-20 22:13:36 +00:00
if (el.type == "password") {
el.type = "text";
} else {
el.type = "password";
2021-03-01 21:53:31 +00:00
}
2021-07-20 22:13:36 +00:00
});
}
const toggleSidebar = (event) => {
2021-07-20 22:13:36 +00:00
document.querySelectorAll(".sidebar").forEach((el) => {
el.classList.toggle("visible");
});
};
ready(() => {
2021-07-20 22:13:36 +00:00
(document.getElementById("nav-toggle") || {}).onclick = function () {
document.getElementById("nav-content").classList.toggle("hidden");
2021-07-20 22:13:36 +00:00
};
document.querySelectorAll(".js-passwordRevealer").forEach((el) => {
el.addEventListener("click", togglePasswordFieldVisibility);
});
document.querySelectorAll(".js-SidebarOpener").forEach((el) => {
el.addEventListener("click", toggleSidebar);
});
document.querySelectorAll(".js-flash-closer").forEach((el) => {
el.addEventListener("click", () => {
el.closest(".js-flash").remove();
});
});
});