1/** 2 * @file accordion.js 3 * 4 * JS File for accordion component. 5 */ 6(function (Drupal, once) { 7 8 const autofoldItemsSelector = '[data-accordion="autofold"] [data-toggle]'; 9 10 /** 11 * @Behavior 12 */ 13 Drupal.behaviors.rddsAccordionElement = { 14 onceName: 'accordion-autofold', 15 attach(context) { 16 // Toggle other accordion items. 17 once(this.onceName, context.querySelectorAll(autofoldItemsSelector), context).forEach(function (toggle) { 18 ['click', 'touch'].forEach(function (e) { 19 toggle.addEventListener(e, function (event) { 20 if (toggle.getAttribute('accordion-closing')) { 21 toggle.removeAttribute('accordion-closing'); 22 return; 23 } 24 25 let accordion = event.target.closest('[data-accordion]'); 26 let siblings = accordion.querySelectorAll('[data-toggle][aria-expanded="true"'); 27 siblings.forEach(function (sibling) { 28 if (toggle != sibling) { 29 // Prevent infinite loop and/or closing current item. 30 sibling.setAttribute('accordion-closing', true); 31 sibling.click(); 32 } 33 }); 34 }); 35 }); 36 }); 37 }, 38 detach: function detach(context, settings, trigger) { 39 if (trigger === "unload") { 40 once.remove(this.onceName, context.querySelectorAll(autofoldItemsSelector)); 41 } 42 }, 43 }; 44})(Drupal, once);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.