From e6cfa3e2a4ed23fd446f6fc34fcae8fa3196d96d Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Fri, 22 Nov 2024 09:51:38 +0100 Subject: [PATCH] doc: enhance block form initialization with detailed documentation and improved observer comments --- backend/experiment/static/collapsible_blocks.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/experiment/static/collapsible_blocks.js b/backend/experiment/static/collapsible_blocks.js index 64b03cb0f..f618875bd 100644 --- a/backend/experiment/static/collapsible_blocks.js +++ b/backend/experiment/static/collapsible_blocks.js @@ -1,5 +1,9 @@ -// collapsible_blocks.js - +/** + * Initializes an (inline) block form by adding a collapsible toggle button to the header + * and setting up the initial collapsed state of the form. + * + * @param {HTMLElement} blockForm - The block form element to initialize. + */ function initializeBlockForm(blockForm) { let header = blockForm.querySelector('h3'); @@ -116,7 +120,7 @@ document.addEventListener('DOMContentLoaded', function () { firstBlock.parentNode.parentNode.querySelector('h2').appendChild(buttonsContainer); } - // Add observer for dynamically added blocks + // Add observer for dynamically added blocks (e.g. when adding a new block) const observer = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { mutation.addedNodes.forEach(function (node) {