Skip to content

Commit

Permalink
doc: enhance block form initialization with detailed documentation an…
Browse files Browse the repository at this point in the history
…d improved observer comments
  • Loading branch information
drikusroor committed Nov 22, 2024
1 parent ca10fa0 commit e6cfa3e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions backend/experiment/static/collapsible_blocks.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e6cfa3e

Please sign in to comment.