PageSourceSearch

https://www.hiddenbrain.org/wp-content/plugins/ultimate-blocks/src…/content-toggle/front.build.js?ver=3.6.0

js hiddenbrain.org collected 2026-09-24 08:42:42 UTC 7,204 bytes, 149 lines download raw bytes

1"use strict";
2
3function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
4function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
5function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
6function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
7function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
8function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
9var convertToPixels = function convertToPixels(amount, unit) {
10  return unit === "%" ? amount / 100 * window.innerWidth : amount;
11};
12var togglePanel = function togglePanel(target) {
13  var topPadding = 0,
14    bottomPadding = 0;
15  var indicator = target.querySelector(".wp-block-ub-content-toggle-accordion-state-indicator");
16  var panelContent = target.nextElementSibling;
17  var toggleContainer = target.closest(".wp-block-ub-content-toggle");
18  if (panelContent.classList.contains("ub-hide")) {
19    var computedStyles = getComputedStyle(panelContent);
20    var topPaddingUnit = computedStyles.paddingTop.match(/[^\d.]+/)[0];
21    var bottomPaddingUnit = computedStyles.paddingBottom.match(/[^\d.]+/)[0];
22    topPadding = convertToPixels(parseFloat(computedStyles.paddingTop), topPaddingUnit);
23    bottomPadding = convertToPixels(parseFloat(computedStyles.paddingBottom), bottomPaddingUnit);
24    panelContent.classList.remove("ub-hide");
25    panelContent.classList.add("ub-hiding");
26    if (toggleContainer.dataset.showonlyone === "true") {
27      _toConsumableArray(toggleContainer.children).forEach(function (child) {
28        var siblingToggle = child.querySelector(".wp-block-ub-content-toggle-accordion-title-wrap");
29        if (siblingToggle !== target) {
30          var siblingContent = siblingToggle.nextElementSibling;
31          var siblingIndicator = siblingToggle.querySelector(".wp-block-ub-content-toggle-accordion-state-indicator");
32          if (!siblingContent.classList.contains("ub-hide")) {
33            if (siblingIndicator) siblingIndicator.classList.remove("open");
34            siblingContent.classList.add("ub-toggle-transition");
35            siblingContent.style.height = "".concat(siblingContent.scrollHeight, "px");
36            setTimeout(function () {
37              siblingContent.classList.add("ub-hiding");
38              siblingContent.style.height = "";
39            }, 20);
40          }
41        }
42      });
43    }
44  } else {
45    panelContent.style.height = getComputedStyle(panelContent).height;
46  }
47  panelContent.classList.add("ub-toggle-transition");
48  if (indicator) indicator.classList.toggle("open");
49  setTimeout(function () {
50    if (panelContent.classList.contains("ub-hiding")) {
51      panelContent.style.height = "".concat(panelContent.scrollHeight + topPadding + bottomPadding, "px");
52      panelContent.style.paddingTop = "".concat(topPadding, "px");
53      panelContent.style.paddingBottom = "".concat(bottomPadding, "px");
54      document.querySelectorAll(".ub_image_slider").forEach(function (slider) {
55        new Swiper("#".concat(slider.id), JSON.parse(slider.dataset.swiperData));
56      });
57      setTimeout(function () {
58        return window.dispatchEvent(new Event("resize"));
59      }, 100);
60    } else {
61      panelContent.classList.add("ub-hiding");
62      panelContent.style.height = "";
63    }
64  }, 20);
65  panelContent.addEventListener("transitionend", function () {
66    panelContent.classList.remove("ub-toggle-transition");
67    panelContent.setAttribute("aria-expanded", panelContent.offsetHeight !== 0);
68    if (panelContent.offsetHeight === 0) {
69      panelContent.classList.add("ub-hide");
70    } else {
71      panelContent.removeAttribute("style");
72    }
73    panelContent.classList.remove("ub-hiding");
74  });
75  panelContent.querySelectorAll(".wp-block-embed iframe").forEach(function (embeddedContent) {
76    embeddedContent.style.removeProperty("width");
77    embeddedContent.style.removeProperty("height");
78  });
79};
80var handleKeyDown = function handleKeyDown(e, i, toggleHeads) {
81  var key = e.key;
82  if (key === "ArrowUp" && i > 0) {
83    e.preventDefault();
84    toggleHeads[i - 1].focus();
85  } else if (key === "ArrowDown" && i < toggleHeads.length - 1) {
86    e.preventDefault();
87    toggleHeads[i + 1].focus();
88  } else if ([" ", "Enter"].includes(key)) {
89    e.preventDefault();
90    togglePanel(e.currentTarget);
91  } else if (key === "Home" && i > 0) {
92    e.preventDefault();
93    toggleHeads[0].focus();
94  } else if (key === "End" && i < toggleHeads.length - 1) {
95    e.preventDefault();
96    toggleHeads[toggleHeads.length - 1].focus();
97  }
98};
99var attachTogglePanelEvents = function attachTogglePanelEvents(toggleContainer) {
100  var toggleHeads = Array.from(toggleContainer.children).map(function (toggle) {
101    return toggle.children[0];
102  }).filter(function (toggle) {
103    return toggle && toggle.classList.contains("wp-block-ub-content-toggle-accordion-title-wrap");
104  });
105  toggleHeads.forEach(function (toggleHead, i) {
106    toggleHead.removeEventListener("keydown", handleKeyDown);
107    toggleHead.addEventListener("keydown", function (e) {
108      return handleKeyDown(e, i, toggleHeads);
109    });
110    toggleHead.removeEventListener("click", togglePanel);
111    toggleHead.addEventListener("click", function (e) {
112      e.stopImmediatePropagation();
113      togglePanel(toggleHead);
114    });
115  });
116};
117var initTogglePanels = function initTogglePanels() {
118  document.querySelectorAll(".wp-block-ub-content-toggle").forEach(function (toggleContainer) {
119    if (window.innerWidth < 700 && JSON.parse(toggleContainer.dataset.mobilecollapse)) {
120      _toConsumableArray(toggleContainer.children).forEach(function (child) {
121        var panel = child.children[0].nextElementSibling;
122        if (!panel.classList.contains("ub-hide")) {
123          togglePanel(child.children[0]);
124        }
125      });
126    }
127    attachTogglePanelEvents(toggleContainer);
128  });
129};
130document.addEventListener("DOMContentLoaded", function () {
131  initTogglePanels();
132  var observer = new MutationObserver(function (mutations) {
133    mutations.forEach(function (mutation) {
134      if (mutation.type === "childList") {
135        var addedNodes = _toConsumableArray(mutation.addedNodes);
136        addedNodes.forEach(function (node) {
137          var _node$classList;
138          if ((_node$classList = node.classList) !== null && _node$classList !== void 0 && _node$classList.contains("wp-block-ub-content-toggle")) {
139            attachTogglePanelEvents(node);
140          }
141        });
142      }
143    });
144  });
145  observer.observe(document.body, {
146    childList: true,
147    subtree: true
148  });
149});

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.