PageSourceSearch

https://www.firstrespondersfornetneutrality.com/wp-content/themes/fight/js/block-scripts.js?v=1791263017

js firstrespondersfornetneutrality.com collected 2026-10-06 05:03:42 UTC 4,162 bytes, 124 lines download raw bytes

1/* TODO: move this into blocks at some point when we have time */
2
3// on ready functions
4document.addEventListener("DOMContentLoaded", function () {
5  Object.values(blockInitializers).forEach((initializer) => {
6    initializer();
7  });
8});
9
10const blockInitializers = {
11  // LOGO CLOUD EXPANDABLE
12  initLogoCloud: function() {
13    const expandableContainers = document.querySelectorAll('.expandable-content');
14    Array.from(expandableContainers).forEach((container) => {
15      const viewMoreButton = container.querySelector('.view-more a');
16      if (viewMoreButton) {
17        viewMoreButton.addEventListener('click', () => {
18          container.classList.add('show-all');
19          console.log('adding show-all class');
20        });
21      }
22    });
23  },
24
25  // ACCORDION
26  initAccordion: function() {
27    const accordionButtons = document.getElementsByClassName('accordion-button');
28    Array.from(accordionButtons).forEach((accordionButton) => {
29      accordionButton.addEventListener('click', () => {
30        const accordionItem = accordionButton.parentNode.parentNode;
31        accordionItem.classList.toggle('show');
32        getSiblings(accordionItem).forEach((el) => {
33          el.classList.remove('show');
34        });
35      });
36    });
37
38    function openAccordionFromHash() {
39      const id = location.hash.slice(1);
40      if (!id) return;
41
42      const panel = document.getElementById(id);
43      if (!panel || !panel.classList.contains('accordion-collapse')) return;
44
45      const item = panel.closest('.accordion-item');
46      const button = document.querySelector(`[data-bs-target="#${CSS.escape(id)}"]`);
47      const scrollTarget = button || item || panel;
48
49      const scrollToAccordion = () => {
50        // Prefer the question button so the hash doesn't land mid-answer
51        scrollTarget.scrollIntoView({ behavior: 'smooth', block: 'start' });
52      };
53
54      // Match your existing visual state
55      if (item) {
56        item.classList.add('show');
57        getSiblings(item).forEach((el) => el.classList.remove('show'));
58      }
59      if (button) button.classList.remove('collapsed');
60
61      // Open via Bootstrap, then scroll to the header (not the panel body)
62      panel.addEventListener('shown.bs.collapse', scrollToAccordion, { once: true });
63      bootstrap.Collapse.getOrCreateInstance(panel, { toggle: false }).show();
64
65      // If already open, shown.bs.collapse won't fire
66      if (panel.classList.contains('show')) {
67        scrollToAccordion();
68      }
69    }
70
71    openAccordionFromHash();
72    window.addEventListener('hashchange', openAccordionFromHash);
73  },
74
75  // PROGRESS BAR
76  initProgressBars: function() {
77    const progressBars = document.querySelectorAll('.progress-bar')
78    progressBars.forEach(progressBar => {
79      setTimeout(() => {
80        progressBar.style.width = `${progressBar.getAttribute('aria-valuenow')}%`
81      }, 100)
82    })
83  },
84
85  initMadlibPetitions: function() {
86    const madlibPetitions = document.querySelectorAll('.wp-block-fight-madlib-petition')
87    madlibPetitions.forEach(madlibPetition => {
88      const button = madlibPetition.querySelector('.wp-block-button__link')
89      if (button) {
90        button.addEventListener('click', () => {
91          const petition = madlibPetition.querySelector('.petition-wrapper')
92          if (petition) {
93            const comment = petition.dataset.defaultComment
94            const autocomplete = madlibPetition.querySelector('.autocomplete input')
95
96            if (autocomplete) {
97              petition.querySelector('#form-comments').value = comment.replace("_USER_INPUT_", autocomplete.value)
98            }
99          }
100
101          const modal = madlibPetition.querySelector('.modal')
102          if (modal) {
103            new bootstrap.Modal(modal).show()
104          }
105        })
106      }
107    })
108  },
109
110  initModal: function() {
111    if (document.querySelector('.modal.auto-open')) {
112      new bootstrap.Modal(document.querySelector('.modal.auto-open'), {
113      keyboard: true,
114      focus: true
115      }).show()
116    }
117  }
118};
119
120function getSiblings (elem) {
121  return Array.from(elem.parentNode.children).filter(function (sibling) {
122    return sibling !== elem;
123  });
124}

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.