@openeuropa/bcl-theme-joinup 1.9.0 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4742,6 +4742,45 @@
4742
4742
  }
4743
4743
  }
4744
4744
 
4745
+ /* eslint-disable prefer-destructuring */
4746
+ class AccordionToggle {
4747
+ static isInitialized = false;
4748
+ constructor(buttonElement) {
4749
+ this.buttonElement = buttonElement;
4750
+ this.targetAccordionId = buttonElement.getAttribute("data-target");
4751
+ this.action = buttonElement.getAttribute("data-action");
4752
+ this.accordionElement = SelectorEngine.findOne(`#${this.targetAccordionId}`);
4753
+ this.accordionItems = SelectorEngine.find(".accordion-collapse", this.accordionElement);
4754
+ this.addEventListeners();
4755
+ }
4756
+ addEventListeners() {
4757
+ EventHandler.on(this.buttonElement, "click", event => this.handleAccordionAction(event));
4758
+ }
4759
+ handleAccordionAction(event) {
4760
+ const item = event.target;
4761
+ const action = item.getAttribute('data-action');
4762
+ const accordionItems = this.accordionItems;
4763
+ accordionItems.forEach(accordionItem => {
4764
+ const collapseInstance = Collapse.getOrCreateInstance(accordionItem, {
4765
+ toggle: false
4766
+ });
4767
+ if (action === 'expand') {
4768
+ collapseInstance.show();
4769
+ } else if (action === 'collapse') {
4770
+ collapseInstance.hide();
4771
+ }
4772
+ });
4773
+ }
4774
+ static init() {
4775
+ if (AccordionToggle.isInitialized) {
4776
+ return;
4777
+ }
4778
+ const toggleButtons = SelectorEngine.find('[data-action][data-target]');
4779
+ toggleButtons.forEach(buttonElement => new AccordionToggle(buttonElement));
4780
+ AccordionToggle.isInitialized = true;
4781
+ }
4782
+ }
4783
+
4745
4784
  /**
4746
4785
  * --------------------------------------------------------------------------
4747
4786
  * Bootstrap (v5.2.3): util/sanitizer.js
@@ -6557,6 +6596,7 @@
6557
6596
  Gallery,
6558
6597
  Modal,
6559
6598
  AccessibleToggle,
6599
+ AccordionToggle,
6560
6600
  Offcanvas,
6561
6601
  Popover,
6562
6602
  ScrollSpyV2: ScrollSpy$1,