add legacy support of checkbox, add documents for cookie/lgres/request
This commit is contained in:
@@ -49,7 +49,40 @@ function createCheckbox(opts) {
|
||||
return container;
|
||||
}
|
||||
|
||||
function resolveCheckbox(container) {
|
||||
function resolveCheckbox(container, legacy) {
|
||||
if (legacy) {
|
||||
const checks = container.querySelectorAll('input[type="checkbox"]');
|
||||
for (let chk of checks) {
|
||||
const id = chk.id;
|
||||
let label;
|
||||
if (id != null) {
|
||||
label = container.querySelector(`label[for="${id}"]`);
|
||||
}
|
||||
if (label == null) {
|
||||
const e = chk.nextElementSibling;
|
||||
if (e != null && e.tagName === 'LABEL') {
|
||||
label = e;
|
||||
}
|
||||
}
|
||||
if (label == null) {
|
||||
const e = chk.previousElementSibling;
|
||||
if (e != null && e.tagName === 'LABEL') {
|
||||
label = e;
|
||||
}
|
||||
}
|
||||
let text;
|
||||
if (label == null) {
|
||||
label = document.createElement('label');
|
||||
chk.parentElement.insertBefore(label, chk);
|
||||
} else {
|
||||
text = label.innerText;
|
||||
}
|
||||
label.className = 'checkbox-wrapper';
|
||||
label.replaceChildren();
|
||||
fillCheckbox(label, 'fa-regular', text);
|
||||
label.insertBefore(chk, label.firstChild);
|
||||
}
|
||||
}
|
||||
const boxes = container.querySelectorAll('label[data-checkbox]');
|
||||
for (let box of boxes) {
|
||||
if (!box.classList.contains('checkbox-wrapper')) {
|
||||
|
Reference in New Issue
Block a user