Dom,-safe
This commit is contained in:
@@ -999,26 +999,42 @@ function flashTitle(finalTitle) {
|
|||||||
}, 800);
|
}, 800);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// Tab Navigation
|
// Tab Navigation (DOM-safe)
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const tabButtons = document.querySelectorAll(".tab-button");
|
const tabButtons = document.querySelectorAll(".tab-button");
|
||||||
const tabContents = document.querySelectorAll(".tab-content");
|
const tabContents = document.querySelectorAll(".tab-content");
|
||||||
|
|
||||||
|
if (!tabButtons || !tabButtons.length || !tabContents || !tabContents.length) {
|
||||||
|
console.error("ScriptMonkey: no tab buttons or tab contents found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
tabButtons.forEach(btn => {
|
tabButtons.forEach(btn => {
|
||||||
btn.addEventListener("click", () => {
|
btn.addEventListener("click", () => {
|
||||||
// clear active state
|
// clear active state
|
||||||
tabButtons.forEach(b => b.classList.remove("active"));
|
tabButtons.forEach(b => b.classList.remove("active"));
|
||||||
tabContents.forEach(c => c.classList.remove("active"));
|
tabContents.forEach(c => c.classList.remove("active"));
|
||||||
|
|
||||||
// set new active
|
// set new active
|
||||||
btn.classList.add("active");
|
btn.classList.add("active");
|
||||||
document.getElementById(btn.dataset.tab).classList.add("active");
|
const targetId = btn.dataset.tab;
|
||||||
|
const target = document.getElementById(targetId);
|
||||||
|
if (target) target.classList.add("active");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// initialize default tab on load
|
// initialize default tab on load
|
||||||
document.querySelector(".tab-button[data-tab='{{defaultPage}}Tab']").classList.add("active");
|
const defaultBtn = document.querySelector(".tab-button[data-tab='{{defaultPage}}Tab']");
|
||||||
document.getElementById("{{defaultPage}}Tab").classList.add("active");
|
const defaultTab = document.getElementById("{{defaultPage}}Tab");
|
||||||
|
|
||||||
|
if (defaultBtn) defaultBtn.classList.add("active");
|
||||||
|
if (defaultTab) defaultTab.classList.add("active");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// =======================================================================
|
// =======================================================================
|
||||||
// Task Trigger
|
// Task Trigger
|
||||||
@@ -1092,12 +1108,17 @@ function updateOffboardSelectAll() {
|
|||||||
master.checked = Array.from(children).every(cb => cb.checked);
|
master.checked = Array.from(children).every(cb => cb.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attach off-board checkbox change handlers
|
// Attach off-board checkbox change handlers (DOM-safe)
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
const offChildren = document.querySelectorAll(
|
const offChildren = document.querySelectorAll(
|
||||||
'#offboardTab input[type=checkbox]:not(#offboardSelectAll)'
|
'#offboardTab input[type=checkbox]:not(#offboardSelectAll)'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!offChildren || !offChildren.length) {
|
||||||
|
// This just means no off-boarding items were rendered; safe to ignore.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
offChildren.forEach(cb =>
|
offChildren.forEach(cb =>
|
||||||
cb.addEventListener('change', updateOffboardSelectAll)
|
cb.addEventListener('change', updateOffboardSelectAll)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user