PageSourceSearch

https://nationalmentoringresourcecenter.org/wp-content/themes/nmrc/js/functions.js?ver=1729109896

js nationalmentoringresourcecenter.org collected 2026-10-01 13:05:56 UTC 10,155 bytes, 324 lines download raw bytes

1jQuery(document).ready(function($) {
2
3	/*
4	$(window).resize(function() {
5		if($(window).width() >= 992) {
6			$(".menu#menu-primary > li").hover(
7		  function() {
8			  $(this).addClass("show-hover");
9		  },
10		  function() {
11			  $(this).removeClass("show-hover");
12			}
13		  );
14	  }
15	}).resize();
16	*/
17	
18	// misc
19	$('a[href^="http"]').each(function() {
20	  if(this.href.indexOf(window.location.host) == -1) {
21		  $(this).attr('target', '_blank');
22		  $(this).attr('aria-label', 'Visit external site');
23		$(this).append('<i class="fal fa-external-link"></i>');
24	  }
25	  })
26
27	  $('[data-toggle="tooltip"]').tooltip();
28	  
29	  $('.mapsvg-wrap .mapsvg-controller-view-toolbar').prepend('<div class="header">');
30	  
31	  $('#bbp-search-form label').remove();
32	  
33	  $('#field_2_29 label').attr('for', 'gform_browse_button_2_29');
34  
35  
36	// accordion
37	  var acc_header = $('.accordion:not(.accordion-child) > .accordion-item > .accordion-title'),
38			  acc_content = $('.accordion:not(.accordion-child) > .accordion-item > .accordion-content'),
39			  acc_child_header = $('.accordion-child > .accordion-item > .accordion-title'),
40			  acc_child_content = $('.accordion-child > .accordion-item > .accordion-content');
41  
42	  acc_header.click(function() {
43		  if($(this).parent().hasClass('open')) {
44			  acc_header.parent().removeClass('open');
45			  acc_content.slideUp();
46		  } else {
47			  acc_header.parent().removeClass('open');
48			  $(this).parent().addClass('open');
49			  acc_content.slideUp();
50			  $(this).next().slideDown(500, function() {
51				  $('html, body').animate({
52				scrollTop: $(this).offset().top - 150
53				}, 1000);
54			  });
55		  }
56	  })
57	  
58	  acc_header.on('keydown', function(e) {
59		  if(e.keyCode == 32) {
60			  $('.accordion:not(.accordion-child) > .accordion-item > .accordion-title:focus').click();
61		  }
62	  })
63  
64	  acc_child_header.click(function() {
65		  if($(this).parent().hasClass('open')) {
66			  acc_child_header.parent().removeClass('open');
67			  acc_child_content.slideUp();
68		  } else {
69			  acc_child_header.parent().removeClass('open');
70			  $(this).parent().addClass('open');
71			  acc_child_content.slideUp();
72			  $(this).next().slideDown(500, function() {
73				  $('html, body').animate({
74				scrollTop: $(this).offset().top - 150
75				}, 1000);
76			  });
77		  }
78	  })
79	  
80	  acc_child_header.on('keydown', function(e) {
81		  if(e.keyCode == 32) {
82			  $('.accordion-child > .accordion-item > .accordion-title:focus').click();
83		  }
84	  })
85  
86  
87	  // tabs
88	  var hash = $(location).prop('hash'),
89			  nav_item = $('.nav-item'),
90			  nav_link = $('.nav-link'),
91			  sub_link = $('.sub-nav-link'),
92			  tab_pane = $('.tab-pane');
93  
94	  if(hash) {
95		  nav_link.removeClass('active').attr('aria-selected', 'false');
96		  sub_link.removeClass('active').attr('aria-selected', 'false');
97		  $('a[href="'+hash+'"]').addClass('open active').attr('aria-selected', 'true').next('ul').show();
98		  $('a[href="'+hash+'"]').closest('.nav-item').addClass('open');
99		  tab_pane.removeClass('active show');
100		  $(hash).addClass('active show');
101	  }
102  
103	  nav_link.click(function(e) {
104		  if($(this).hasClass('open')) {
105			  $(this).toggleClass('open');
106			  $(this).next().slideToggle();
107		  } else {
108			  nav_link.removeClass('open active');
109			  $('.nav-item ul').removeClass('open').slideUp();
110			  $(this).toggleClass('open');
111			  $(this).next().slideToggle();
112			  if($(this).closest('.nav-item').hasClass('open')) {
113				  //$(this).closest('.nav-item').removeClass('open');
114			  } else {
115				  nav_item.removeClass('open');
116				  $(this).closest('.nav-item').addClass('open');
117			  }
118			  $('html, body').animate({
119				scrollTop: $('#tabs-sections-content').offset().top - 150
120			}, 500);
121		  }
122		  
123		  if($(this).hasClass('active')) {
124			  e.preventDefault();
125			  return false;
126		  } else {
127			  window.location.hash = this.hash;
128			  sub_link.removeClass('active show');
129		  }
130	  })
131	  
132	  sub_link.click(function() {
133		  window.location.hash = this.hash;
134		  sub_link.removeClass('active show');
135		  $('html, body').animate({
136		  scrollTop: $('#tabs-sections-content').offset().top - 150
137	  }, 500);
138	  })
139  
140  
141	// search
142	$('#site-header .search-toggle').click(function(e) {
143		e.preventDefault();
144		$('#mobile-nav').removeClass().addClass('navbar-collapse collapse');
145		$('.navbar-toggler').addClass('collapsed');
146		$('#search-overlay').addClass('open');
147		$('#s').focus();
148		if($('#search-overlay').hasClass('open')) {
149			$('#search-overlay').attr('aria-hidden', 'false');
150		} else {
151			$('#search-overlay').attr('aria-hidden', 'true');
152		  }
153		  
154		const focusableElements = 'button, input, [tabindex]:not([tabindex="-1"])';
155		  const modal = document.querySelector('#search-overlay'); // select the modal by it's id
156		  const firstFocusableElement = modal.querySelectorAll(focusableElements)[0]; // get first element to be focused inside modal
157		  const focusableContent = modal.querySelectorAll(focusableElements);
158		  const lastFocusableElement = focusableContent[focusableContent.length - 1]; // get last element to be focused inside modal
159		  
160		  document.addEventListener('keydown', function(e) {
161			let isTabPressed = e.key === 'Tab' || e.keyCode === 9;
162		  
163			if (!isTabPressed) {
164			  return;
165			}
166		  
167			if (e.shiftKey) { // if shift key pressed for shift + tab combination
168			  if (document.activeElement === firstFocusableElement) {
169				lastFocusableElement.focus(); // add focus for the last focusable element
170				e.preventDefault();
171			  }
172			} else { // if tab key is pressed
173			  if (document.activeElement === lastFocusableElement) { // if focused has reached to last focusable element then focus first focusable element after pressing tab
174				firstFocusableElement.focus();
174 // add focus for the first focusable element
175				e.preventDefault();
176			  }
177			}
178		  });
179		  
180		  firstFocusableElement.focus();
181	})
182  
183	$('.search-close').click(function() {
184		$('#search-overlay').removeClass('open');
185		$('#mobile-nav').removeClass('show');
186	})
187  
188  
189	// mobile nav
190	$('#site-header .navbar-toggler').click(function() {
191		$('body').addClass('no-scroll');
192	  })
193  
194	$('.nav-close').click(function() {
195		$('#mobile-nav').removeClass('show');
196		$('#search-overlay').removeClass('open');
197	})
198  
199	var nav_header = $('#mobile-nav > div > ul > li.menu-item-has-children > a');
200  
201	  nav_header.click(function(e) {
202		  e.preventDefault();
203		  e.stopPropagation();
204		  if($(this).parent().hasClass('open')) {
205			  $(this).parent().removeClass('open');
206			  $(this).next().slideUp();
207		  } else {
208			  $(this).parent().addClass('open');
209			  $(this).next().slideDown();
210		  }
211	  })
212  
213  
214	// blog categories
215	$('#categories .children').parent().addClass('has-children');
216  
217	$('#categories .has-children').click(function(e) {
218		if(e.target == this) {
219			$(this).toggleClass('open').find('.children').toggle();
220		}
221	})
222  
223  
224	// select wrap
225	$('select:not(.wrapped)').addClass('wrapped').wrap('<div class="select-custom"></div>');
226	
227	
228	  // bookmarking
229	$('#single-resource .intro, .facetwp-template').on('click', 'button', function(event) {
230		post = $(this),
231		post_id = post.attr('data-post-id');
232  
233		$.ajax({
234			type : 'post',
235			dataType : 'json',
236			url : nmrc.ajax_url,
237			data : {action: 'bookmark', post_id : post_id},
238			success: function(response) {
239				if(response.result === 'added') {
240					$(post).addClass('bookmarked');
241				}
242				if(response.result === 'removed') {
243					$(post).removeClass('bookmarked');
244				}
245				if(response.result === 'unauthenticated') {
246					console.log(event);
247					window.location.href = event.currentTarget.parentElement.href;
248				}
249			}
250		});
251	});
252	
253	
254	// facet functions
255	  $('.facetwp-page.prev').html('&lsaquo;');
256	  $('.facetwp-page.next').html('&rsaquo;');
257	  $('.facetwp-page:not(.prev):not(.first):not(.dots):not(.next):not(.last)').each(function() {
258		  var page_index = $(this).attr('data-page');
259		  
260		  $(this).attr('aria-label', 'Page '+page_index);
261	  })
262	  
263	  $('select[class*="facet"]').each(function(index) {
264		  $(this).attr('id', 'select-'+index);
265		  $(this).closest('div[class*="facet"]').prev().attr('for', 'select-'+index);
266		  $(this).attr('tabindex', '0');
267	  })
268	  
269	  $('input.facetwp-search').attr('id', 'facetwp-search');
270	  $('input.facetwp-search').attr('tabindex', '0');
271	  $('input.facetwp-search').closest('.facetwp-type-search').prev().attr('for', 'facetwp-search');
272	  $('.facetwp-input-wrap .facetwp-icon').attr('tabindex', '0');
273	  
274	  $(document).on('facetwp-loaded', function() {
275		  $('[data-toggle="tooltip"]').tooltip();
276
277		  $('select:not(.wrapped)').addClass('wrapped').wrap('<div class="select-custom"></div>');
278		  
279		  $('.facetwp-page.prev').html('&lsaquo;');
280		  $('.facetwp-page.next').html('&rsaquo;');
281		  $('.facetwp-page:not(.prev):not(.first):not(.dots):not(.next):not(.last)').each(function() {
282			  var page_index = $(this).attr('data-page');
283			  
284			  $(this).attr('aria-label', 'Page '+page_index);
285		  })
286		  
287		  $('select[class*="facet"]').each(function(index) {
288			  $(this).attr('id', 'select-'+index);
289			  $(this).closest('div[class*="facet"]').prev().attr('for', 'select-'+index);
290			  $(this).attr('tabindex', '0');
291		  })
292		  
293		  $('input.facetwp-search').attr('id', 'facetwp-search');
294		  $('input.facetwp-search').attr('tabindex', '0');
295		  $('input.facetwp-search').closest('.facetwp-type-search').prev().attr('for', 'facetwp-search');
296		  $('.facetwp-input-wrap .facetwp-icon').attr('tabindex', '0');
297		  
298		  if(FWP.loaded) {
299			/*
300			$('html, body').animate({
301			  	scrollTop: $('.facetwp-template').offset().top - 150
302		  	}, 500);
303			*/
304		  
305		  	$('.facetwp-page:not(.prev):not(.first):not(.dots):not(.next):not(.last)').each(function() {
306				  var page_index = $(this).attr('data-page');
307				  
308				  $(this).attr('aria-label', 'Page '+page_index);
309			})
310	  	}
311	  });
312	  
313	  
314	  // gravity forms functions
315	  jQuery(document).on('gform_post_render', function() {
316		  $('.validation_error, .gform_confirmation_message').attr('role', 'alert');
317	  })
318  
319  
320	  // grantee profile
321	  $('.single-grantee .nav-tabs li:first-child a, .single-grantee .tab-content .tab-pane:first-child').addClass('active show');
322  
323  });
324  

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.