{"version":3,"file":"toggle-accordion.bundle.js","mappings":"MACA,IAAQA,EAAWC,OAAXD,OACR,IAAKA,EACH,MAAM,IAAIE,MACR,4EAIJ,IAAMC,EAAIH,EAGV,SAASI,IAAuC,IAAtBC,EAAe,UAAH,8CACpCF,EAAE,mBAAmBG,MAAK,WACxB,IAAMC,EAASJ,EAAEK,MAAMC,KAAK,0BACtBC,EAAkBH,EAAOI,KAAK,kBAG/BN,GAAoC,UAApBK,IAAkCL,GAAoC,SAApBK,IACrEH,EAAOK,OAEX,GACF,CAEAT,EAAEU,UAAUC,OAAM,WAIhBX,EAAE,mCAAmCY,GAAG,SAAS,WAC/CX,GAAiB,EACnB,IAGAD,EAAE,iCAAiCY,GAAG,SAAS,WAC7CX,GAAiB,EACnB,GACF,G","sources":["webpack://developer.gov.sg/./apps/src/communities/toggle-accordion.js"],"sourcesContent":["// Check if jQuery is loaded\nconst { jQuery } = window;\nif (!jQuery) {\n throw new Error(\n \"Toggle-Accordion couldn't initialize; please make sure jQuery is loaded!\"\n );\n}\n\nconst $ = jQuery;\n\n// Function to toggle accordions\nfunction toggleAccordions(shouldExpand = false) {\n $(\".sgds-accordion\").each(function () {\n const header = $(this).find(\".sgds-accordion-header\");\n const headerAttribute = header.attr(\"aria-expanded\");\n\n // Check if the header attribute matches the desired state for expansion/collapse\n if ((shouldExpand && headerAttribute === \"false\") || (!shouldExpand && headerAttribute === \"true\")) {\n header.click(); // Trigger a click event on the header to toggle the accordion\n }\n });\n}\n\n$(document).ready(function () {\n // Add event listeners to buttons\n\n // Button to collapse all accordions\n $(\"#button-collapse-all-accordions\").on(\"click\", function () {\n toggleAccordions(false); // Call the toggleAccordions function with the 'shouldExpand' parameter set to false\n });\n\n // Button to expand all accordions\n $(\"#button-expand-all-accordions\").on(\"click\", function () {\n toggleAccordions(true); // Call the toggleAccordions function with the 'shouldExpand' parameter set to true\n });\n});\n"],"names":["jQuery","window","Error","$","toggleAccordions","shouldExpand","each","header","this","find","headerAttribute","attr","click","document","ready","on"],"sourceRoot":""}