PageSourceSearch

https://aarweb.org/wp-content/themes/yoko-aar-child/assets/js/main.js?ver=1759340997

js aarweb.org collected 2026-09-24 08:47:36 UTC 6,876 bytes, 224 lines download raw bytes

1// Auto scrolling to top of post module when FacetWP pagination is used
2
3jQuery(document).ready(function($){
4  var firstFacetsLoaded = false;
5$(document).on('facetwp-loaded', function() {
6  // Scroll to results
7  var verticalOffset = 150,
8    speed = 1000;
9
10  // Prevent the first scroll
11  if ( firstFacetsLoaded ) {
12    $('html, body').animate({
13      scrollTop: jQuery(".facetwp-template").offset().top - verticalOffset
14    }, speed);
15  } else {
16    firstFacetsLoaded = true;
17    // Code runs only on the first FWP load
18  }
19});
20})
21
22/**
23* Makes a BB Column clickable.
24* Pre-requisite: There must be an A Tag contained within the column element.
25*/
26jQuery(document).ready(function($) {
27  // Function to check for links, add class, and propagate the <a> click
28  function makeClickable() {
29      // For .hover-card
30      $(document).off('click', '.hover-card').on('click', '.hover-card', function(event){
31          var link = $(this).find('.card-title a')[0];
32          if (link) {
33              link.click();
34          }
35      });
36
37      $(document).off('click', '.hover-card .card-title a').on('click', '.hover-card .card-title a', function(event){
38          event.stopPropagation();
39      });
40
41      // For .grid-cards
42      $(document).off('click', '.grid-cards .card').on('click', '.grid-cards .card', function(event){
43          var $card = $(this);
44          var link = $card.find('.fl-module-heading a')[0];
45          var button = $card.find('.fl-button')[0]; // .fl-button is the a tag
46
47          // Prioritize the button link if it exists
48          if (button) {
49              button.click();
50          } else if (link) {
51              link.click();
52          }
53      });
54
55      $(document).off('click', '.grid-cards .card .fl-module-heading a, .grid-cards .card .fl-button').on('click', '.grid-cards .card .fl-module-heading a, .grid-cards .card .fl-button', function(event){
56          event.stopPropagation();
57      });
58  }
59
60  // Initial load
61  makeClickable();
62
63  // Reinitialize after AJAX/pagination updates
64  $(document).on('ajaxComplete', function() {
65      makeClickable();
66  });
67});
68
69/**
70* Makes a BB list module item clickable.
71* Pre-requisite: There must be an A Tag contained within the list item.
72*/
73jQuery(document).ready(function($){
74  // Exit if BB layout is in edit mode.
75  if ( 'undefined' != typeof window.FLBuilderConfig ) {
76      return;
77  }
78  
79  $('.fl-list-item').css('cursor', 'pointer');
80  $('.fl-list-item').on('click', function(event){
81      $(this).find('a')[0].click();
82  });
83
84  $('.fl-list-item a').on('click', function(event){
85      event.stopPropagation();
86  });
87})
88
89/**
90* Hides section when there are no related posts
91*/
92
93jQuery(document).ready(function($){
94// Select all elements with class 'related-terms'
95const relatedTermsDivs = document.querySelectorAll('.related-terms');
96
97// Loop through each 'related-terms' div
98relatedTermsDivs.forEach(relatedTermsDiv => {
99  // Check if the current 'related-terms' div contains a descendant element with class 'fl-post-grid-empty'
100  if (relatedTermsDiv.querySelector('.fl-post-grid-empty')) {
101    // Add the class 'hide-post-grid-section' to the current 'related-terms' div
102    relatedTermsDiv.classList.add('hide-post-section');
103  }
104});
105});
106
107/**
108* Hides <p> and <li> when empty
109*/
110jQuery(document).ready(function($){
111  $('.meta-item p, .meta-item li, .meta-info p, .meta-info li').each(function() {
112      if ($(this).text().trim() === '') {
113          $(this).hide();
114      }
115  });
116});
117
118/**
119* Adding a jump link ID as a class to the body on menu item click.
120**/
121(function($) {
122  $(document).ready(function() {
123    const $tabLinks = $('.banner-inner-nav-col ul.menu > li > a, #event-content-row a[href^="#"]');
124    const $scrollToContainer = $('#event-content-row');
125
126    // Prevent default browser scroll to anchor
127    if ('scrollRestoration' in history) {
128      history.scrollRestoration = 'manual';
129    }
130
131    function updateBodyClass(hash) {
132      const classSuffix = hash.replace('#', '').replace(/[^a-zA-Z0-9-_]/g, '');
133      $('body').removeClass(function(_, className) {
134        return (className.match(/event-[a-zA-Z0-9-_]+-col/g) || []).join(' ');
135      });
136      $('body').addClass('event-' + classSuffix + '-col');
137    }
138
139    function scrollToEventContent() {
140      const headerHeight = $('header').outerHeight() || 0;
141      const extraPadding = 100;
142      $('html, body').stop().animate({
143        scrollTop: $scrollToContainer.offset().top - headerHeight - extraPadding
144      }, 600);
145    }
146
147    function activateMenuItem(hash) {
148      $('.banner-inner-nav-col ul.menu > li').removeClass('focus');
149      $('.banner-inner-nav-col ul.menu > li > a[href="' + hash + '"]')
150        .parent('li')
151        .addClass('focus');
152    }
153
154    $tabLinks.on('click', function(e) {
155      const hash = $(this).attr('href');
156      if (hash.startsWith('#')) {
157        e.preventDefault();
158        updateBodyClass(hash);
159        activateMenuItem(hash);
160        history.pushState(null, null, hash);
161        scrollToEventContent();
162      }
163    });
164
165    // On page load with a hash
166    if (window.location.hash) {
167      const hash = window.location.hash;
168      updateBodyClass(hash);
169      activateMenuItem(hash);
170
171      // Delay scroll to prevent jumpy browser behavior
172      setTimeout(() => {
173        scrollToEventContent();
174      }, 500);
175    }
176  });
177})(jQuery);
178
179/**
180* Adjusting the scroll position based on the header height and extra padding
181**/
182(function($) {
183  $(window).on('load', function() {
184      if (window.location.hash) { 
185          var target = $(window.location.hash);
186          if (target.length) {
187              var headerHeight = $('header').outerHeight() || 0;
188              var extraPadding = 100; // Add 100px extra space
189
190              $('html, body').stop().animate({
191                  scrollTop: target.offset().top - headerHeight - extraPadding
192              }, 0);
193          }
194      }
195  });
196})(jQuery);
197
198/*
199* Setting mega menu's top based on header, announcement bar, and admin bar heights.
200*/
201(function($) {
202  function updateMegaMenuTop() {
203      var headerHeight = $('header').outerHeight() || 0;
204      var announcementHeight = $('.announcement-bar').outerHeight() || 0;
205      var adminBarHeight = $('#wpadminbar').length ? $('#wpadminbar').outerHeight() || 0 : 0;
206
207      // Default total height includes announcement bar & admin bar
208      var totalHeight = headerHeight + announcementHeight + adminBarHeight;
209
210      // If the header is scrolled, ignore the announcement bar
211      if ($('header').hasClass('fl-theme-builder-header-scrolled')) {
212          totalHeight = headerHeight;
213      }
214
215      // Apply calculated height
216      $('ul.sub-menu > li.mega-menu-item').css('top', totalHeight + 'px');
217  }
218
219  // Run on page load
220  updateMegaMenuTop();
221
222  // Run on window resize and scroll to adjust dynamically
223  $(window).on('resize scroll', updateMegaMenuTop);
224})(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.