yosup/web/js/ui/util.js
Thomas Mathews 6eb67bc3af web: Refactor UI code
* Created directory for UI
 * Moved rendering code to js/ui/render.js
 * Created initial js/ui/util.js for UI utilities

Notice I did not use modules. I was thinking of doing this but I am
avoiding it for now as it is much easier to just have everything
declared as global at this time. For onclick methods this makes sense;
but for code (such as rendering) I think it would be better off as a
module that gets imported. This is a task for another day.
2022-11-12 09:41:54 -08:00

13 lines
564 B
JavaScript

// This file contains utility functions related to UI manipulation. Some code
// may be specific to areas of the UI and others are more utility based. As
// this file grows specific UI area code should be migrated to its own file.
// toggle_cw changes the active stage of the Content Warning for a post. It is
// relative to the element that is pressed.
function toggle_cw(el) {
el.classList.toggle("active");
const isOn = el.classList.contains("active");
const input = el.parentElement.querySelector("input.cw");
input.classList.toggle("hide", !isOn);
}