- Replace hardcoded position strings with POSITIONS.* constants - Prefix unused variables with _ to resolve no-unused-vars warnings - Fix no-prototype-builtins with Object.prototype.hasOwnProperty.call() - Extract menuUtils.js (543 lines) into 6 focused modules under menu/ - menuUtils.js now 35 lines, delegates via prototype mixin pattern - Add 158 unit tests for ConfigManager, MeasurementContainer, ValidationUtils Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
57 lines
1.9 KiB
JavaScript
57 lines
1.9 KiB
JavaScript
/**
|
|
* Toggle initialization methods for MenuUtils.
|
|
* Controls visibility of UI elements based on checkbox/dropdown state.
|
|
*/
|
|
|
|
const toggles = {
|
|
initBasicToggles(elements) {
|
|
// Toggle visibility for log level
|
|
elements.logCheckbox.addEventListener("change", function () {
|
|
elements.rowLogLevel.style.display = this.checked ? "block" : "none";
|
|
});
|
|
elements.rowLogLevel.style.display = elements.logCheckbox.checked
|
|
? "block"
|
|
: "none";
|
|
},
|
|
|
|
// Define the initialize toggles function within scope
|
|
initMeasurementToggles(elements) {
|
|
// Toggle visibility for scaling inputs
|
|
elements.scalingCheckbox.addEventListener("change", function () {
|
|
elements.rowInputMin.style.display = this.checked ? "block" : "none";
|
|
elements.rowInputMax.style.display = this.checked ? "block" : "none";
|
|
});
|
|
|
|
// Set initial states
|
|
elements.rowInputMin.style.display = elements.scalingCheckbox.checked
|
|
? "block"
|
|
: "none";
|
|
elements.rowInputMax.style.display = elements.scalingCheckbox.checked
|
|
? "block"
|
|
: "none";
|
|
},
|
|
|
|
initTensionToggles(elements, node) {
|
|
const currentMethod = node.interpolationMethod;
|
|
elements.rowTension.style.display =
|
|
currentMethod === "monotone_cubic_spline" ? "block" : "none";
|
|
console.log(
|
|
"Initial tension row display: ",
|
|
elements.rowTension.style.display
|
|
);
|
|
|
|
elements.interpolationMethodInput.addEventListener("change", function () {
|
|
const selectedMethod = this.value;
|
|
console.log(`Interpolation method changed: ${selectedMethod}`);
|
|
node.interpolationMethod = selectedMethod;
|
|
|
|
// Toggle visibility for tension input
|
|
elements.rowTension.style.display =
|
|
selectedMethod === "monotone_cubic_spline" ? "block" : "none";
|
|
console.log("Tension row display: ", elements.rowTension.style.display);
|
|
});
|
|
},
|
|
};
|
|
|
|
module.exports = toggles;
|