PageSourceSearch

https://wearehfc.org/wp-content/themes/CommuneDiviChild/styles-scripts/public.js?ver=1273659506

js wearehfc.org collected 2026-09-25 14:55:31 UTC 5,823 bytes, 184 lines download raw bytes

1(function($) {
2
3	document.addEventListener("DOMContentLoaded", function () {
4  		document.querySelectorAll('a[href^="#"]').forEach(anchor => {
5    		anchor.addEventListener("click", function () {
6      		history.pushState(null, null, this.getAttribute("href"));
7    		});
8  		});
9	});
10	
11  // Preserve existing onreadystatechange listener
12  var oldReadyStateChange = document.onreadystatechange; 
13  // Attach new listener
14  document.onreadystatechange = function () {
15      if (oldReadyStateChange) {
16          oldReadyStateChange(); // execute old listener function if it exists
17      }
18      if (document.readyState === 'complete') {
19  
20    // Overwrite scrollTo method before Divi calls it
21    var oldScrollTo = window.scrollTo;
22    window.scrollTo = function(){ return false; };
23
24          setTimeout(function() {
25              window.scrollTo = oldScrollTo; // restore window.scrollTo
26          }, 50);
27      }
28  };
29
30 
31// Close divi accordian on load
32$(document).ready(function () {
33
34(function() {
35
36if (window.location.hash) {
37  window.location.hash = window.location.hash.toLowerCase();
38  
39  if (document.getElementById(window.location.hash.split('?')[0].slice(1))) {
40	var topHeaderHeight = $('div.top-header').innerHeight();
41  	$("header").css("translate", `0 -${topHeaderHeight}px`);
42  	$("hdr-bot").css("translate", `0 -${topHeaderHeight}px`);
43  }
44}
45
46})();
47//global filtering buton
48$('.et_pb_menu__search-button').addClass('openSearch');
49$('.et_pb_menu__search-button').removeClass('et_pb_menu__search-button');
50$(".openSearch, .closex").click(function(){
51         var headerHeight = $('header').innerHeight();
52   $('.global-search, .closex').css("top", headerHeight);
53   $('.global-search, #main-content, body, header').toggleClass("filter-on");
54   $('.closex').toggleClass("toggle-visibility");
55   $('.global-search-toggle').toggleClass("hide");
56   $('.search-overlay').toggleClass("search-overlay-visible");
57   $('header').toggleClass("search");
58   $('input.orig').focus();
59    });
60
61 $('.et_pb_module.et_pb_accordion .et_pb_accordion_item.et_pb_toggle_open')
62    .addClass('et_pb_toggle_close')
63    .removeClass('et_pb_toggle_open');
64    
65  $('.et_pb_toggle').click(function(){
66    $('.et_pb_toggle_open').removeClass('et_pb_toggle_open');
67  });
68});
69
70
71
72$(window).on("load", function() {
73	
74//accessibility
75$('.et_pb_menu__logo a').attr("aria-label", "Home Page");
76$('#footer-logo a').attr("aria-label", "Home Page");
77$('button.openSearch').attr("aria-label", "Search");
78$('.et_pb_scroll_top').attr("aria-label", "Back to top");
79$('#about-us-footer').attr("role", "navigation").attr("aria-label", 'About Us Footer');
80$('#learn-with-us-footer').attr("role", "navigation").attr("aria-label", 'Learn With Us Footer');
81$('#connect-with-us-footer').attr("role", "navigation").attr("aria-label", 'Connect With Us Footer');
82$('#policy-footer').attr("role", "navigation").attr("aria-label", 'Policy Footer');
83$('.da11y-submenu').attr("aria-haspopup", "true");
84$('.et_pb_scroll_top').attr("role", "button").attr("tabindex", "0");;
85$('.et_clickable').attr("role", "button").attr("tabindex", "0");;
86	
87$('a[target="_blank"]').attr('aria-label', function() {
88	return (this.textContent.trim() + " (Opens in new tab)");
89});
90	
91// set pixels away from anchor points
92window.et_pb_smooth_scroll = function( $target, $top_section, speed, easing ) {
93var $window_width = $( window ).width();
94$menu_offset = -1;
95var headerHeight = 75;
96if ( $ ('#wpadminbar').length && $window_width <= 980 ) {
97$menu_offset += $( '#wpadminbar' ).outerHeight() + headerHeight;
98} else {
99$menu_offset += headerHeight;
100}
101//fix sidenav scroll to top
102if ( $top_section ) {
103$scroll_position = 0;
104} else {
105$scroll_position = $target.offset().top - $menu_offset;
106}
107// set swing (animate's scrollTop default) as default value
108if( typeof easing === 'undefined' ){
109easing = 'swing';
110}
111$( 'html, body' ).animate( { scrollTop : $scroll_position }, speed, easing );
112}
113  //Sticky Header
114var prevScrollpos = window.scrollY;
115window.onscroll = function() {
116  var topHeaderHeight = $('div.top-header').innerHeight();
117  var currentScrollPos = window.scrollY;
118  
119  // Only apply the translation after scrolling 100px
120  if (currentScrollPos > 100) {
121    if (prevScrollpos > currentScrollPos) {
122      $("header").css("translate", "0");
123    } else {
124      $("header").css("translate", `0 -${topHeaderHeight}px`);
125      $("hdr-bot").css("translate", `0 -${topHeaderHeight}px`);
126    }
127  } else {
128    // Reset translation when scroll position is less than 100px
129    $("header").css("translate", "0");
130    $("hdr-bot").css("translate", "0");
131  }
132  prevScrollpos = currentScrollPos;
133}
134$(".close-hdr").click(function(){
135$('.da-close').click();
136});
137
138var fired = false;
139
140// Observe the body for changes (Mailchimp may inject the success element later)
141var observer = new MutationObserver(function(mutations) {
142  if (fired) return;
143
144  var successEl = document.querySelector('#mce-success-response');
145  if (!successEl) return;
146
147  var style = window.getComputedStyle(successEl);
148  if (style.display !== "none" && successEl.innerText.trim() !== "") {
149    fired = true; // Ensure we only fire once
150
151	gtag('event', 'mailchimp_submission', {
152      newsletter: 'HFC Newsletter',
153      page: window.location.href
154    });
155
156    observer.disconnect();
157  }
158});
159
160observer.observe(document.body, { childList: true, subtree: true, attributes: true });
161
162	
163window.addEventListener('scroll', function() {
164
165// Check if the window is scrolled to the top or beyond
166if (window.scrollY <= 0) {
167 $("header").addClass("hdr-top");
168}
169else {
170  $("header").removeClass("hdr-top");
171}
172if ((window.innerHeight + window.scrollY) >= document.body.offsetHeight - 55) {
173
174  // Code to execute when scrolled to the bottom
175  $("header").addClass("hdr-bot");
176}
177else {
178  $("header").removeClass("hdr-bot");
179}
180});
181
182});
183
184})(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.