PageSourceSearch

https://shop.dailymaverick.co.za/wp-content/plugins/responsive-blo…/blocks/accordion/accordion.js?ver=2.2.3

js dailymaverick.co.za collected 2026-10-01 07:54:01 UTC 9,033 bytes, 242 lines download raw bytes

1function slideUp(target, duration) {
2  target.style.transitionProperty = "height, margin, padding";
3  target.style.transitionDuration = duration + "ms";
4  target.style.boxSizing = "border-box";
5  target.style.height = target.offsetHeight + "px";
6  target.offsetHeight;
7  target.style.overflow = "hidden";
8  target.style.height = 0;
9  target.style.paddingTop = 0;
10  target.style.paddingBottom = 0;
11  target.style.marginTop = 0;
12  target.style.marginBottom = 0;
13  window.setTimeout(function () {
14    target.style.display = "none";
15    target.style.removeProperty("height");
16    target.style.removeProperty("padding-top");
17    target.style.removeProperty("padding-bottom");
18    target.style.removeProperty("margin-top");
19    target.style.removeProperty("margin-bottom");
20    target.style.removeProperty("overflow");
21    target.style.removeProperty("transition-duration");
22    target.style.removeProperty("transition-property");
23  }, duration);
24}
25
26function slideDown(target, duration) {
27  target.style.removeProperty("display");
28  var display = window.getComputedStyle(target).display;
29
30  if (display === "none") display = "block";
31
32  target.style.display = display;
33  var height = target.offsetHeight;
34  target.style.overflow = "hidden";
35  target.style.height = 0;
36  target.style.paddingTop = 0;
37  target.style.paddingBottom = 0;
38  target.style.marginTop = 0;
39  target.style.marginBottom = 0;
40  target.offsetHeight;
41  target.style.boxSizing = "border-box";
42  target.style.transitionProperty = "height, margin, padding";
43  target.style.transitionDuration = duration + "ms";
44  target.style.height = height + "px";
45  target.style.removeProperty("padding-top");
46  target.style.removeProperty("padding-bottom");
47  target.style.removeProperty("margin-top");
48  target.style.removeProperty("margin-bottom");
49  window.setTimeout(function () {
50    target.style.removeProperty("height");
51    target.style.removeProperty("overflow");
52    target.style.removeProperty("transition-duration");
53    target.style.removeProperty("transition-property");
54  }, duration);
55}
56
57function slideToggle(target, duration) {
58  if (window.getComputedStyle(target).display === "none") {
59    return slideDown(target, duration);
60  } else {
61    return slideUp(target, duration);
62  }
63}
64
65function setupAccordion() {
66  var pattern = new RegExp("^[\\w\\-]+$");
67  var hashval = window.location.hash.substring(1);
68  var expandFirstelements = document.getElementsByClassName(
69    "responsive-block-editor-addons-accordion-expand-first-true"
70  );
71  var inactiveOtherelements = document.getElementsByClassName(
72    "responsive-block-editor-addons-accordion-inactive-other-false"
73  );
74
75  if (pattern.test(hashval)) {
76    var elementToOpen = document.getElementById(hashval);
77      if( elementToOpen.getElementsByClassName( 'responsive-block-editor-addons-accordion-item' )[0] !== undefined ){
78          elementToOpen.getElementsByClassName( 'responsive-block-editor-addons-accordion-item' )[0].classList.add( 'responsive-block-editor-addons-accordion-item-active' );
79          elementToOpen.getElementsByClassName( 'responsive-block-editor-addons-accordion-item' )[0].setAttribute( 'aria-expanded', true );
80          slideDown( elementToOpen.getElementsByClassName( 'responsive-block-editor-addons-accordion-content' )[0], 500 );
81      }
82  } else {
83    for (var item = 0; item < expandFirstelements.length; item++) {
84      if (
85        true ===
86        expandFirstelements[item].classList.contains(
87          "responsive-block-editor-addons-accordion-layout-accordion"
88        )
89      ) {
90        expandFirstelements[item]
91          .querySelectorAll(
92            ".responsive-block-editor-addons-accordion-item__outer-wrap"
93          )[0]
94          .getElementsByClassName(
95            "responsive-block-editor-addons-accordion-item"
96          )[0]
97          .classList.add(
98            "responsive-block-editor-addons-accordion-item-active"
99          );
100        expandFirstelements[item]
101          .querySelectorAll(
102            ".responsive-block-editor-addons-accordion-item__outer-wrap"
103          )[0]
104          .getElementsByClassName(
105            "responsive-block-editor-addons-accordion-item"
106          )[0]
107          .setAttribute("aria-expanded", true);
108        expandFirstelements[item]
109          .querySelectorAll(
110            ".responsive-block-editor-addons-accordion-item__outer-wrap"
111          )[0]
112          .getElementsByClassName(
113            "responsive-block-editor-addons-accordion-item"
114          )[0]
115          .querySelectorAll(
116            ".responsive-block-editor-addons-accordion-content"
117          )[0].style.display = "block";
118      }
119    }
120  }
121  for (var item = 0; item < inactiveOtherelements.length; item++) {
122    if (
123      true ===
124      inactiveOtherelements[item].classList.contains(
125        "responsive-block-editor-addons-accordion-layout-accordion"
126      )
127    ) {
128      var otherItems = inactiveOtherelements[item].querySelectorAll(
129        ".responsive-block-editor-addons-accordion-item__outer-wrap"
130      );
131
132      for (var childItem = 0; childItem < otherItems.length; childItem++) {
133        otherItems[childItem]
134          .getElementsByClassName(
135            "responsive-block-editor-addons-accordion-item"
136          )[0]
137          .classList.add(
138            "responsive-block-editor-addons-accordion-item-active"
139          );
140        otherItems[childItem]
141          .getElementsByClassName(
142            "responsive-block-editor-addons-accordion-item"
143          )[0]
144          .setAttribute("aria-expanded", true);
145        otherItems[childItem]
146          .getElementsByClassName(
147            "responsive-block-editor-addons-accordion-item"
148          )[0]
149          .querySelectorAll(
150            ".responsive-block-editor-addons-accordion-content"
151          )[0].style.display = "block";
152      }
153    }
154  }
155}
156
157window.addEventListener("load", function () {
158  setupAccordion();
159
160  var accordionElements = document.getElementsByClassName(
161    "responsive-block-editor-addons-accordion-layout-accordion"
162  );
163  for (var item = 0; item < accordionElements.length; item++) {
164    var titleButtons = accordionElements[item].querySelectorAll(
165      ".responsive-block-editor-addons-accordion-titles-button"
166    );
167
168    for (var button = 0; button < titleButtons.length; button++) {
169      titleButtons[button].addEventListener("click", function (e) {
170        accordionClick(e, this.parentElement, titleButtons);
171      });
172      titleButtons[button].addEventListener("keypress", function (e) {
173        accordionClick(e, this.parentElement, titleButtons);
174      });
175    }
176  }
177});
178
179function accordionClick(e, accordionItem, titleButtons) {
180    if (e.keyCode === 13 || e.keyCode === 32 || e.button === 0) { // enter || spacebar || left mouse click.
181        if (
182            accordionItem.classList.contains(
183                "responsive-block-editor-addons-accordion-item-active"
184            )
185        ) {
186
187            accordionItem.classList.remove(
188                "responsive-block-editor-addons-accordion-item-active"
189            );
190            accordionItem.setAttribute("aria-expanded", false);
191            slideUp(
192                accordionItem.getElementsByClassName(
193                    "responsive-block-editor-addons-accordion-content"
194                )[0],
195                500
196            );
197        } else {
198            var parent = e.currentTarget.closest('.wp-block-responsive-block-editor-addons-accordion');
199            var accordionToggle = "true";
200
201            if (
202                parent.classList.contains(
203                    "wp-block-responsive-block-editor-addons-accordion"
204                )
205            ) {
206                accordionToggle = parent.getAttribute("data-accordiontoggle");
207            }
208            accordionItem.classList.add(
209                "responsive-block-editor-addons-accordion-item-active"
210            );
211            accordionItem.setAttribute("aria-expanded", true);
212            slideDown(
213                accordionItem.getElementsByClassName(
214                    "responsive-block-editor-addons-accordion-content"
215                )[0],
216                500
217            );
218            if ("true" === accordionToggle) {
219                for (
220                    var buttonChild = 0;
221                    buttonChild < titleButtons.length;
222                    buttonChild++
223                ) {
224                    var buttonItem = titleButtons[buttonChild].parentElement;
225                    if (buttonItem === accordionItem) {
226                        continue;
227                    }
228                    buttonItem.classList.remove(
229                        "responsive-block-editor-addons-accordion-item-active"
230                    );
231                    buttonItem.setAttribute("aria-expanded", false);
232                    slideUp(
233                        buttonItem.getElementsByClassName(
234                            "responsive-block-editor-addons-accordion-content"
235                        )[0],
236                        500
237                    );
238                }
239            }
240        }
241    }
242}

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.