PageSourceSearch

https://my.hollywoodbowl.com/bundles/madelaphil/js/toggle.js

js hollywoodbowl.com collected 2026-09-24 08:38:45 UTC 1,881 bytes, 65 lines download raw bytes

1'use strict';
2
3const TOGGLE_BTN_SELECTOR = '[data-toggle]';
4
5function toggleEvent(event) {
6  const element = event.target.closest(TOGGLE_BTN_SELECTOR);
7
8  if (!element) {
9    return;
10  }
11
12  if ('togglePreventDefault' in element.dataset) {
13    event.preventDefault();
14  }
15
16  const toggleClass = element.dataset.toggleClass || 'is-toggled';
17  const isToggled = element.classList.contains(toggleClass);
18
19  const targetElements = document.querySelectorAll(element.dataset.toggle);
20  targetElements.forEach(targetElement => {
21    targetElement.classList.toggle(toggleClass);
22    targetElement.setAttribute('aria-hidden', isToggled ? 'true' : 'false');
23    targetElement.setAttribute('aria-expanded', isToggled ? 'false' : 'true');
24
25  });
26
27  const bodyClass = element.dataset.toggleBodyClass;
28  const triggerResize = element.dataset.triggerResize;
29
30  const toggleLabel = element.dataset.toggleLabel;
31  const labelElements = document.querySelectorAll(
32    element.dataset.toggleLabelSelector || '.js-toggle__label'
33  );
34
35  if (toggleLabel) {
36    labelElements.forEach(labelElement => {
37      element.dataset.toggleLabel = labelElement.innerHTML;
38      labelElement.innerHTML = toggleLabel;
39    });
40  }
41
42  const focusElements = document.querySelectorAll(element.dataset.toggleFocus);
43  if (!isToggled && focusElements.length > 0) {
44    focusElements[0].focus();
45  }
46
47  const closeElement = document.querySelector(element.dataset.toggleClose);
48  if (closeElement && closeElement.classList.contains(toggleClass)) {
49    closeElement.click();
50  }
51
52  element.classList.toggle(toggleClass);
53  element.setAttribute('aria-expanded', isToggled ? 'false' : 'true');
54
55  if (bodyClass) {
56    document.body.classList.toggle(bodyClass);
57  }
58  if (triggerResize) {
59    window.dispatchEvent(new Event('resize'));
60  }
61}
62
63export function init() {
64  document.addEventListener('click', toggleEvent, false);
65}

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.