From 2e948f58d7c167c72858ab7f0f8d9a3706ab4895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bl=C3=A4sta?= Date: Wed, 23 Oct 2024 10:56:10 +0200 Subject: [PATCH] Lint fixes --- src/controls/editor/edithandler.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/controls/editor/edithandler.js b/src/controls/editor/edithandler.js index 48088a30b..222761154 100644 --- a/src/controls/editor/edithandler.js +++ b/src/controls/editor/edithandler.js @@ -915,26 +915,25 @@ function onAttributesSave(features, attrs) { if (document.getElementById(`${attribute.elId}-0`).getAttribute('type') === 'checkbox') { if (attribute.options && attribute.options.length > 0) { Array.from(document.getElementsByName(attribute.name)).forEach((element) => { - if (element.tagName === 'INPUT' && element.getAttribute("type") === 'checkbox' && element.checked === true) { + if (element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox' && element.checked === true) { // Check if this is a free text checkbox - if (element.nextElementSibling.getAttribute("type") === 'text') { + if (element.nextElementSibling.getAttribute('type') === 'text') { checkboxValues.push(element.nextElementSibling.value.trim()); } else { - checkboxValues.push(element.getAttribute("value")); + checkboxValues.push(element.getAttribute('value')); } } }); - editEl[attribute.name] = checkboxValues.join('; '); } else { - editEl[attribute.name] = $(attribute.elId).is(':checked') ? 1 : 0; + editEl[attribute.name] = document.getElementById(attribute.elId).checked ? 1 : 0; } } } else { // Read value from input text, textarea or select const checkedValue = (attribute.config && attribute.config.checkedValue) || 1; const uncheckedValue = (attribute.config && attribute.config.uncheckedValue) || 0; editEl[attribute.name] = document.getElementById(attribute.elId).checked ? checkedValue : uncheckedValue; - } + } } else if (attribute.type === 'searchList') { // SearchList may have its value in another place than the input element itself. Query the "Component" instead. // Note that inputValue still contains the value of the input element, which is used to validate required. @@ -1126,7 +1125,7 @@ function addListener() { /** * Returns a function that adds an event handler to enable/disable the textbox for a free text checkbox - * + * * @function * @name addCheckboxListener * @kind function @@ -1137,13 +1136,13 @@ function addCheckboxListener() { const fn = (obj) => { Array.from(document.getElementsByName(obj.name)).forEach((element) => { // Add a listener on the checkbox if it has input text as next element - if (element.tagName === 'INPUT' && element.getAttribute("type") === 'checkbox' && element.nextElementSibling.getAttribute("type") === 'text') { - element.addEventListener('change', (e) => { + if (element.tagName === 'INPUT' && element.getAttribute('type') === 'checkbox' && element.nextElementSibling.getAttribute('type') === 'text') { + element.addEventListener('change', () => { if (element.checked === true) { - element.nextElementSibling.disabled = false; + document.getElementById(element.nextElementSibling.id).disabled = false; } else { - element.nextElementSibling.value = ''; - element.nextElementSibling.disabled = true; + document.getElementById(element.nextElementSibling.id).value = ''; + document.getElementById(element.nextElementSibling.id).disabled = true; } }); } @@ -1298,7 +1297,7 @@ function editAttributes(feat) { obj.isVisible = true; obj.elId = `input-${obj.name}`; obj.addListener = addCheckboxListener(); - } else if (obj.type === 'image') { + } else if (obj.type === 'image') { obj.isVisible = true; obj.elId = `input-${currentLayer}-${obj.name}`; obj.addListener = addImageListener();