1/** 2 * Toggles PageBuilder accordion content types on the storefront. 3 * 4 * Loaded as a plain script (see view/frontend/layout/default.xml), not as a RequireJS/AMD 5 * module: the Hyva theme in this project removes Magento_PageBuilder's own widget-initializer 6 * block (see vendor/hyva-themes/magento2-reset-theme/Magento_PageBuilder/layout/override/base/default.xml), 7 * so there is no RequireJS/jQuery runtime left on the frontend to load an AMD widget with. 8 */ 9!function () { 10 "use strict"; 11 12 function toggle(accordion, trigger, content) { 13 var expand = content.getAttribute("data-expanded") !== "true"; 14 15 content.setAttribute("data-expanded", expand ? "true" : "false"); 16 trigger.setAttribute("aria-expanded", expand ? "true" : "false"); 17 18 var label = trigger.querySelector('[data-element="trigger-label"]'); 19 20 if (label) { 21 label.textContent = expand ? accordion.getAttribute("data-text-open") : accordion.getAttribute("data-text-closed"); 22 } 23 } 24 25 function initAccordion(accordion) { 26 var trigger = accordion.querySelector('[data-element="trigger"]'), 27 content = accordion.querySelector('[data-element="content"]'); 28 29 if (!trigger || !content) { 30 return; 31 } 32 33 trigger.addEventListener("click", function () { 34 toggle(accordion, trigger, content); 35 }); 36 } 37 38 document.addEventListener("DOMContentLoaded", function () { 39 document.querySelectorAll('[data-content-type="accordion"]').forEach(initAccordion); 40 }); 41}();
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.