PageSourceSearch

https://popcouncil.org/wp-content/themes/Avada-Child-Theme/js/avada-toggle/avada-toggle.js?ver=7.1.2

js popcouncil.org collected 2026-09-24 08:44:37 UTC 2,062 bytes, 71 lines download raw bytes

1(function ($) {
2  // Find all accordions within the page
3  const accordianTitles = document.querySelectorAll(
4    ".fusion-accordian.accordian .panel-title"
5  );
6
7  // Find accordion toggle buttons
8  const accordianLinks = document.querySelectorAll(
9    ".fusion-accordian.accordian .panel-title a"
10  );
11
12  // Converting a DOM element into a specified new type of element
13  jQuery.fn.convertElement = function (newType) {
14    if (!jQuery(this[0]) || jQuery(this[0]) == undefined || !jQuery(this[0]).length) {
15      return;
16    } else {
17      var atts = {};
18
19      jQuery.each(this[0].attributes, function (idx, attr) {
20        let attName = String(attr.nodeName);
21        if (attName === "role") {
22          attName = "type";
23        }
24        if (attName === "href") {
25          return;
26        }
27        atts[attName] = attr.nodeValue;
28      });
29
30      this.replaceWith(function () {
31        return jQuery("<" + newType + "/>", atts).append(jQuery(this).contents());
32      });
33    }
34  }
35
36  // First replace inner link as a button
37  for (let index = 0; index < accordianLinks.length; index++) {
38    $(accordianLinks[index]).convertElement('button');
39  }
40
41  // After updating buttons inside header tag
42  // Loop through and adjust wrappers from h4 to h3
43  for (let index = 0; index < accordianTitles.length; index++) {
44    $(accordianTitles[index]).convertElement('span');
45  }
46
47  // Find accordion toggle buttons
48  const accordianButtons = document.querySelectorAll(
49    ".fusion-accordian.accordian .panel-title button"
50  );
51
52  // Attach listern to support change from Avada links
53  accordianButtons.forEach((element) => {
54    $(element).on("click", toggleAccordion);
55  });
56
57  // Listener for buttons opening
58  function toggleAccordion() {
59    if ($(this).attr("aria-expanded") === "false") {
60      $(this)
61        .attr("aria-expanded", "true")
62        .removeClass("collapsed")
63        .addClass("active");
64    } else {
65      $(this)
66        .attr("aria-expanded", "false")
67        .removeClass("active")
68        .addClass("collapsed");
69    }
70  }
71})(jQuery);

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.