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.
This commit is contained in:
parent
8bec3e126c
commit
6eb67bc3af
4 changed files with 364 additions and 349 deletions
13
web/js/ui/util.js
Normal file
13
web/js/ui/util.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
// 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);
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue