PageSourceSearch

https://www.maryscenter.org/wp-content/themes/mc/js/navigation.js

js maryscenter.org collected 2026-10-01 11:32:46 UTC 7,043 bytes, 170 lines download raw bytes

1/**
2 * File navigation.js.
3 *
4 * Handles toggling the navigation menu for small screens and enables TAB key
5 * navigation support for dropdown menus.
6 */
7( function() {
8	var container, button, menu, links, i, len;
9
10	container = document.getElementById( 'site-navigation' );
11	if ( ! container ) {
12		return;
13	}
14
15	button = container.getElementsByTagName( 'button' )[0];
16	if ( 'undefined' === typeof button ) {
17		return;
18	}
19
20	menu = container.getElementsByTagName( 'ul' )[0];
21
22	// Hide menu toggle button if menu is empty and return early.
23	if ( 'undefined' === typeof menu ) {
24		button.style.display = 'none';
25		return;
26	}
27
28	menu.setAttribute( 'aria-expanded', 'false' );
29	if ( -1 === menu.className.indexOf( 'nav-menu' ) ) {
30		menu.className += ' nav-menu';
31	}
32
33	button.onclick = function() {
34		if ( -1 !== container.className.indexOf( 'toggled' ) ) {
35			container.className = container.className.replace( ' toggled', '' );
36			button.setAttribute( 'aria-expanded', 'false' );
37			menu.setAttribute( 'aria-expanded', 'false' );
38		} else {
39			container.className += ' toggled';
40			button.setAttribute( 'aria-expanded', 'true' );
41			menu.setAttribute( 'aria-expanded', 'true' );
42		}
43	};
44
45	// Get all the link elements within the menu.
46	links    = menu.getElementsByTagName( 'a' );
47
48	// Each time a menu link is focused or blurred, toggle focus.
49	for ( i = 0, len = links.length; i < len; i++ ) {
50		links[i].addEventListener( 'focus', toggleFocus, true );
51		links[i].addEventListener( 'blur', toggleFocus, true );
52	}
53
54	/**
55	 * Sets or removes .focus class on an element.
56	 */
57	function toggleFocus() {
58		var self = this;
59
60		// Move up through the ancestors of the current link until we hit .nav-menu.
61		while ( -1 === self.className.indexOf( 'nav-menu' ) ) {
62
63			// On li elements toggle the class .focus.
64			if ( 'li' === self.tagName.toLowerCase() ) {
65				if ( -1 !== self.className.indexOf( 'focus' ) ) {
66					self.className = self.className.replace( ' focus', '' );
67				} else {
68					self.className += ' focus';
69				}
70			}
71
72			self = self.parentElement;
73		}
74	}
75
76	/**
77	 * Toggles `focus` class to allow submenu access on tablets.
78	 */
79	( function( container ) {
80		var touchStartFn, i,
81			parentLink = container.querySelectorAll( '.menu-item-has-children > a, .page_item_has_children > a' );
82
83		if ( 'ontouchstart' in window ) {
84			touchStartFn = function( e ) {
85				var menuItem = this.parentNode, i;
86
87				if ( ! menuItem.classList.contains( 'focus' ) ) {
88					
89					e.preventDefault();
90					for ( i = 0; i < menuItem.parentNode.children.length; ++i ) {
91						if ( menuItem === menuItem.parentNode.children[i] ) {
92							continue;
93						}
94						menuItem.parentNode.children[i].classList.remove( 'focus' );
95					}
96					menuItem.classList.add( 'focus' );
97				} else {
98					menuItem.classList.remove( 'focus' );
99				}
100			};
101
102			for ( i = 0; i < parentLink.length; ++i ) {
103				parentLink[i].addEventListener( 'touchstart', touchStartFn, false );
104			}
105		}
106	}( container ) );
107} )();
108
109
110$(document).ready(function(){
111        $('.page-item-60 a').attr('target','_blank');
112        $('.page-item-58 a').attr('target','_blank');
113        $('.page-item-64 a').attr('target','_blank');
114    });
115
116
117    $("#filter").keyup(function() {
118
119  // Retrieve the input field text and reset the count to zero
120  var filter = $(this).val(),
121    count = 0;
122
123  // Loop through the comment list
124  $('.staff-member').each(function() {
125
126
127    // If the list item does not contain the text phrase fade it out
128    if ($(this).text().search(new RegExp(filter, "i")) < 0) {
129      $(this).hide();
130
131      // Show the list item if the phrase matches and increase the count by 1
132    } else {
133      $(this).show();
134      count++;
135    }
136
137  });
138
139});
140
141
142/**
143 * @license
144 * Lodash (Custom Build) lodash.com/license | Underscore.js 1.8.3 underscorejs.org/LICENSE
145 * Build: `lodash include="throttle"`
146 */
147;(function(){function t(){}function e(t){return null==t?t===l?d:y:I&&I in Object(t)?n(t):r(t)}function n(t){var e=$.call(t,I),n=t[I];try{t[I]=l;var r=true}catch(t){}var o=_.call(t);return r&&(e?t[I]=n:delete t[I]),o}function r(t){return _.call(t)}function o(t,e,n){function r(e){var n=d,r=g;return d=g=l,x=e,v=t.apply(r,n)}function o(t){return x=t,O=setTimeout(c,e),T?r(t):v}function i(t){var n=t-h,r=t-x,o=e-n;return w?k(o,j-r):o}function f(t){var n=t-h,r=t-x;return h===l||n>=e||n<0||w&&r>=j}function c(){
148    var t=D();return f(t)?p(t):(O=setTimeout(c,i(t)),l)}function p(t){return O=l,S&&d?r(t):(d=g=l,v)}function s(){O!==l&&clearTimeout(O),x=0,d=h=g=O=l}function y(){return O===l?v:p(D())}function m(){var t=D(),n=f(t);if(d=arguments,g=this,h=t,n){if(O===l)return o(h);if(w)return O=setTimeout(c,e),r(h)}return O===l&&(O=setTimeout(c,e)),v}var d,g,j,v,O,h,x=0,T=false,w=false,S=true;if(typeof t!="function")throw new TypeError(b);return e=a(e)||0,u(n)&&(T=!!n.leading,w="maxWait"in n,j=w?M(a(n.maxWait)||0,e):j,S="trailing"in n?!!n.trailing:S),
149    m.cancel=s,m.flush=y,m}function i(t,e,n){var r=true,i=true;if(typeof t!="function")throw new TypeError(b);return u(n)&&(r="leading"in n?!!n.leading:r,i="trailing"in n?!!n.trailing:i),o(t,e,{leading:r,maxWait:e,trailing:i})}function u(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}function f(t){return null!=t&&typeof t=="object"}function c(t){return typeof t=="symbol"||f(t)&&e(t)==m}function a(t){if(typeof t=="number")return t;if(c(t))return s;if(u(t)){var e=typeof t.valueOf=="function"?t.valueOf():t;
150    t=u(e)?e+"":e}if(typeof t!="string")return 0===t?t:+t;t=t.replace(g,"");var n=v.test(t);return n||O.test(t)?h(t.slice(2),n?2:8):j.test(t)?s:+t}var l,p="4.17.5",b="Expected a function",s=NaN,y="[object Null]",m="[object Symbol]",d="[object Undef
150ined]",g=/^\s+|\s+$/g,j=/^[-+]0x[0-9a-f]+$/i,v=/^0b[01]+$/i,O=/^0o[0-7]+$/i,h=parseInt,x=typeof global=="object"&&global&&global.Object===Object&&global,T=typeof self=="object"&&self&&self.Object===Object&&self,w=x||T||Function("return this")(),S=typeof exports=="object"&&exports&&!exports.nodeType&&exports,N=S&&typeof module=="object"&&module&&!module.nodeType&&module,E=Object.prototype,$=E.hasOwnProperty,_=E.toString,W=w.Symbol,I=W?W.toStringTag:l,M=Math.max,k=Math.min,D=function(){
151    return w.Date.now()};t.debounce=o,t.throttle=i,t.isObject=u,t.isObjectLike=f,t.isSymbol=c,t.now=D,t.toNumber=a,t.VERSION=p,typeof define=="function"&&typeof define.amd=="object"&&define.amd?(w._=t, define(function(){return t})):N?((N.exports=t)._=t,S._=t):w._=t}).call(this);
152
153// This function will run a throttled script every 300 ms
154var checkHeader = _.throttle(() => {
155
156    // Detect scroll position
157    let scrollPosition = Math.round(window.scrollY);
158
159    // If we've scrolled 100px, add "sticky" class to the header
160    if (scrollPosition > 235){
161        document.querySelector('#main-nav').classList.add('sticky');
162    }
163    // If not, remove "sticky" class from nav
164    else {
165        document.querySelector('#main-nav').classList.remove('sticky');
166    }
167}, 300);
168
169// Run the checkHeader function every time you scroll
170window.addEventListener('scroll', checkHeader);

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.