website/themes/terminal-plus-minus/assets/js/toggle-node.js

23 lines
561 B
JavaScript
Raw Normal View History

2019-09-01 17:51:06 +00:00
function toggleVisibilityEvent({event, target="", oneTime=false, callback} = {}) {
const element = event.target;
return toggleVisibility({element, target, oneTime, callback});
}
function toggleVisibility({element, target="", oneTime=false, callback} = {}) {
let exit = 0;
if (oneTime) {
element.classList.toggle("hidden");
}
if (target.length > 0) {
const targetElement = element.closest(target);
targetElement.classList.toggle("hidden");
}
if (callback) {
callback()
}
return exit;
}