20 lines
534 B
JavaScript
20 lines
534 B
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.toggleSwitch = toggleSwitch;
|
|
exports.getSwitch = getSwitch;
|
|
exports.setSwitch = setSwitch;
|
|
function toggleSwitch(el, force) {
|
|
if (!el)
|
|
return;
|
|
const next = force === undefined ? !el.classList.contains('on') : force;
|
|
el.classList.toggle('on', next);
|
|
}
|
|
function getSwitch(el) {
|
|
return el?.classList.contains('on') ?? false;
|
|
}
|
|
function setSwitch(el, value) {
|
|
if (!el)
|
|
return;
|
|
el.classList.toggle('on', value);
|
|
}
|