PageSourceSearch

https://acoel.org/wp-content/themes/acoel/js/scripts.js?ver=1.0.1b

js acoel.org collected 2026-09-24 19:22:14 UTC 3,778 bytes, 134 lines download raw bytes

1// Wrap links in mobile side-nav found on pages
2
3function wrapPageSubMenu() {
4  const targetDiv = document.getElementById('page-subnav');
5  if (!targetDiv) return;
6
7  // Prevent duplicate wrapping
8  if (targetDiv.parentElement?.tagName.toLowerCase() === 'details') {
9    return;
10  }
11
12  const wrapperDiv = document.createElement('details');
13  wrapperDiv.classList.add('page-subnav-wrapper');
14
15  const summary = document.createElement('summary');
16  summary.textContent = 'Navigate this Section';
17
18  wrapperDiv.appendChild(summary);
19
20  // Insert wrapper before target, then move target inside it
21  targetDiv.parentNode.insertBefore(wrapperDiv, targetDiv);
22  wrapperDiv.appendChild(targetDiv);
23}
24
25function unwrapSubnavForDesktop() {
26  const targetDiv = document.getElementById('page-subnav');
27  if (!targetDiv) return;
28
29  const parent = targetDiv.parentElement;
30
31  if (parent && parent.tagName.toLowerCase() === 'details') {
32    parent.parentNode.insertBefore(targetDiv, parent);
33    parent.remove();
34  }
35}
36
37function checkWidth() {
38  if (window.innerWidth <= 768) {
39    wrapPageSubMenu();
40  } else {
41    unwrapSubnavForDesktop();
42  }
43}
44
45window.addEventListener('load', checkWidth);
46window.addEventListener('resize', checkWidth);
47
48(function($) {
49  $(function() {
50    if ('object' != typeof FWP) return;
51
52    /* Modify the flyout wrapper HTML */
53    FWP.hooks.addFilter('facetwp/flyout/flyout_html', function(flyout_html) {
54      return flyout_html.replace(' <div class="facetwp-flyout-close">x</div>', ' <div class="facetwp-flyout-close"><a><i class="fa-solid fa-circle-xmark"></i></a></div>'); // Replace "Close" with your desired text
55    });
56
57    $(document).on('facetwp-loaded', function() {
58        $.each(FWP.settings.num_choices, function(key, val) {
59        // Select the facet container
60        var $facet = $('.facetwp-facet-' + key);
61        
62        // Select the element immediately before the facet (<label>)
63        var $label = $facet.prev();
64
65        if (0 === val) {
66            $facet.hide();
67            $label.hide();
68        } else {
69            $facet.show();
70            $label.show();
71        }
72    });
73    })
74  });
75
76  // Fill fellow defualt profiles.
77  function fillEmptyThumbnails() {
78    $('.home-results .thumbnail a').each(function () {
79      if ($(this).find('img').length === 0) {
80        $('<img>', {
81          src: '/wp-content/themes/acoel/img/profile-default.png',
82          alt: 'Image of ACOEL logo'
83        }).appendTo(this);
84      }
85    });
86  }
87
88  function wrapFacetResults() {
89    //$('.el-p1u8zd').wrapInner('<div class="fellow-details"></div>');
90    //$('.el-5kq8xc').wrapInner('<div class="fellow-details"></div>');
91  }
92
93  // Run on initial page load
94  $(document).ready(function () {
95    fillEmptyThumbnails();
96    wrapFacetResults();
97
98    // Hide 3rd level menu
99    // If div has children
100    // We get url of the top item
101    // Check with current url
102    $('.page_item_has_children').each(function () {
103      console.log($(this).attr('href'));
104    });
105
106
107  });
108
109  // Run after FacetWP AJAX pagination / filtering
110  $(document).on('facetwp-loaded', function () {
111    fillEmptyThumbnails();
112
113     if ( FWP.loaded ) { // Run only after the initial page load
114          $('html, body').animate({
115            scrollTop: $('.facetwp-template').offset().top -30 // Scroll to the top of the element with class "facetp-template"
116          }, 500);
117        }
118  });
119
120
121})(jQuery);
122
123//  Update WP Facet Pagination
124document.addEventListener('facetwp-loaded', function() {
125  
126  document.querySelectorAll('.facetwp-page.prev').forEach(el => {
127    el.innerHTML = `<i class="fa-solid fa-chevron-left"></i>`;
128  });
129
130  document.querySelectorAll('.facetwp-page.next').forEach(el => {
131    el.innerHTML = `<i class="fa-solid fa-chevron-right"></i>`;
132  });
133
134});

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.