From 91aee0743ce607987513b2823e23dfdbc6da2135 Mon Sep 17 00:00:00 2001 From: Yaroslav Afenkin <91559310+yaroslavafenkin@users.noreply.github.com> Date: Mon, 4 Nov 2024 15:02:59 +0200 Subject: [PATCH] [JENKINS-74025] Extract inline JavaScript from `checkboxContent.jelly` --- .../unochoice/common/checkbox-content.js | 19 ++++++++++++ .../unochoice/common/checkboxContent.jelly | 30 +++---------------- 2 files changed, 23 insertions(+), 26 deletions(-) create mode 100644 src/main/resources/org/biouno/unochoice/common/checkbox-content.js diff --git a/src/main/resources/org/biouno/unochoice/common/checkbox-content.js b/src/main/resources/org/biouno/unochoice/common/checkbox-content.js new file mode 100644 index 00000000..39d8add4 --- /dev/null +++ b/src/main/resources/org/biouno/unochoice/common/checkbox-content.js @@ -0,0 +1,19 @@ +window.addEventListener("DOMContentLoaded", () => { + document.querySelectorAll(".checkbox-content-data-holder").forEach((dataHolder) => { + const { maxCount, randomName } = dataHolder.dataset; + + var height = 0; + var refElement = document.getElementById(`ecp_${randomName}_0`); + if (maxCount > 0 && refElement && refElement.offsetHeight != 0) { + for (var i = 0; i < maxCount; i++) { + height += refElement.offsetHeight + 3; + } + } + else { + height = maxCount * 25.5; + } + + height = Math.floor(height); + document.getElementById(`ecp_${randomName}`).style.height = height + "px"; + }); +}); diff --git a/src/main/resources/org/biouno/unochoice/common/checkboxContent.jelly b/src/main/resources/org/biouno/unochoice/common/checkboxContent.jelly index 628ab211..f2109d0b 100644 --- a/src/main/resources/org/biouno/unochoice/common/checkboxContent.jelly +++ b/src/main/resources/org/biouno/unochoice/common/checkboxContent.jelly @@ -1,7 +1,8 @@ + xmlns:transitionWrapper="transitionWrapper" + xmlns:st="jelly:stapler"> @@ -101,29 +102,6 @@ - + +