PageSourceSearch

https://www.greatplacetowork.com/templates/gptw15/js/gptw-components.js?4.64.01

js greatplacetowork.com collected 2026-09-24 10:05:11 UTC 6,545 bytes, 226 lines download raw bytes

1//various site-wide methods, please ensure the various libraries are loaded before this file (e.g. select2, matchHeight, etc)
2
3jQuery(document).ready(function($) {
4
5	//--------------------------------------------------------
6	// MATCH HEIGHT -- the equal-height function
7	//--------------------------------------------------------
8
9	if (jQuery.fn.matchHeight) {
10
11	    // Function to equalize heights in a section after images load
12	    function applyMatchHeight(section) {
13	        section.find('.equal-height').matchHeight();
14	    }
15
16	    // Loop through all sections containing .equal-height elements
17	    jQuery('.equal-height').each(function() {
18	        var section = jQuery(this).closest('section');
19	        var imgs = section.find('img');
20	        var loadedCount = 0;
21
22	        if (imgs.length === 0) {
23	            // No images, just apply immediately
24	            applyMatchHeight(section);
25	        } else {
26	            // Wait for all images in this section to load
27	            imgs.each(function() {
28	                if (this.complete) {
29	                    loadedCount++;
30	                    if (loadedCount === imgs.length) applyMatchHeight(section);
31	                } else {
32	                    jQuery(this).on('load', function() {
33	                        loadedCount++;
34	                        if (loadedCount === imgs.length) applyMatchHeight(section);
35	                    });
36	                }
37	            });
38	        }
39	    });
40
41	    // Pricing section logic stays the same
42	    var mhOptions = {
43	        byRow: false,
44	        property: 'height',
45	        remove: false
46	    };
47	    jQuery('#pricing-section div.description').matchHeight(mhOptions);
48	    jQuery('#pricing-section .pricing-section-equal-height').matchHeight(mhOptions);
49	}
50
51	//--------------------------------------------------------
52	// SECONDARY NAV
53	//--------------------------------------------------------
54
55	//add buttons to the parent elements to trigger the nav
56	jQuery('<i class="fa fa-chevron-down secondary-navigation-drop" aria-hidden="true"></i>').insertAfter('#secondary-navigation .parent');
57
58	//add click listeners to these elements
59	jQuery('.secondary-navigation-drop').click(function(e) {
60
61		//show this menu
62		if (jQuery(this).hasClass('fa-chevron-down')) {
63
64			jQuery(this).prev().find('ul').show();
65			jQuery(this).removeClass('fa-chevron-down').addClass('fa-chevron-up');
66
67			//shut all other menus and reset the arrows apart from this
68			jQuery('.secondary-navigation-drop').not(this).prev().find('ul').hide();
69			jQuery('.secondary-navigation-drop').not(this).removeClass('fa-chevron-up').addClass('fa-chevron-down');
70
71		}
72		//else shut all menus including this
73		else {
74
75			jQuery('.secondary-navigation-drop').prev().find('ul').hide();
76			jQuery('.secondary-navigation-drop').removeClass('fa-chevron-up').addClass('fa-chevron-down');
77
78		}
79
80		//stop the body event triggering
81		e.stopPropagation();
82		return false;
83
84	});
85
86	jQuery('#secondary-navigation .parent').mouseover(function() {
87
88		jQuery(this).find('ul').show();
89
90		jQuery(this).next().addClass('active');
91
92		if (window.innerWidth < 1200) {
93
94			jQuery(this).next().removeClass('fa-chevron-down').addClass('fa-chevron-up');
95
96		}
97
98	});
99
100	jQuery('#secondary-navigation .parent').mouseleave(function() {
101
102		jQuery(this).find('ul').hide();
103
104		jQuery('.secondary-navigation-drop').removeClass('fa-chevron-up').addClass('fa-chevron-down');
105		jQuery(this).next().removeClass('active');
106
107	});
108
109	//close all menu items if the body is clicked
110	jQuery(document).click(function() {
111
112		jQuery('#secondary-navigation .parent').find('ul').hide();
113		jQuery('.secondary-navigation-drop').removeClass('fa-chevron-up').addClass('fa-chevron-down');
114
115	});
116
117	//burger
118	jQuery('#secondary-nav-trigger').click(function() {
119
120		jQuery('#secondary-navigation .menu').slideToggle();
121
122	});
123
124	//--------------------------------------------------------
125	// SELECT 2
126	//--------------------------------------------------------
127
128	if (jQuery.fn.select2) {
129
130		//recent list filter
131		/* jQuery('#list-filter').select2({
132
133			minimumResultsForSearch: -1, //hide the search box
134			width: '340px'
135
136		}); */
137
138		//run select2 apart from in marketo
139		jQuery('select').not(".mktoFieldWrap select").select2({
140
141			minimumResultsForSearch: -1, //hide the search box
142
143		});
144	}
145
146	jQuery(document).ready(function() {
147
148		if (jQuery().tooltip) {
149
150			jQuery('[data-toggle="tooltip"]').tooltip()
151
152		}
153
154	});
155});
156
157//--------------------------------------------------------
158// GET QUERY PARAMS FROM URL
159//--------------------------------------------------------
160
161function gptwGetUrlParameter(sParam) {
162	var sPageURL = window.location.search.substring(1),
163		sURLVariables = sPageURL.split('&'),
164		sParameterName,
165		i;
166
167	for (i = 0; i < sURLVariables.length; i++) {
168		sParameterName = sURLVariables[i].split('=');
169
170		if (sParameterName[0] === sParam) {
171			return sParameterName && !sParameterName[1] ? true : decodeURIComponent(sParameterName[1]);
172		}
173	}
174};
175
176//--------------------------------------------------------
177// STICKY ELEMENTS
178//--------------------------------------------------------
179
180jQuery(document).ready(function() {
181
182	jQuery('.custom-sticky, .gptw-sticky').each(function() {
183
184		var offset = jQuery('#hello-bar:visible').height() + jQuery('#gptw-navigation .desktop-bottom:visible').height() + jQuery('.mobile-header:visible').first().height();
185		this.style.top = offset + 10 + 'px';
186
187	})
188
189});
190
191
192//--------------------------------------------------------
193// scrollToElement function
194//--------------------------------------------------------
195
196function scrollToElement(selectorOrElement, duration = 1200, offset = 0) {
197  const element = 
198    typeof selectorOrElement === "string" 
199      ? document.querySelector(selectorOrElement) 
200      : selectorOrElement;
201
202  if (!element) return;
203
204  const targetPosition = element.getBoundingClientRect().top + window.pageYOffset + offset;
205  const startPosition = window.pageYOffset;
206  const distance = targetPosition - startPosition;
207  let startTime = null;
208
209  function animation(currentTime) {
210    if (startTime === null) startTime = currentTime;
211    const timeElapsed = currentTime - startTime;
212    const run = easeInOutQuad(timeElapsed, startPosition, distance, duration);
213    window.scrollTo(0, run);
214    if (timeElapsed < duration) requestAnimationFrame(animation);
215  }
216
217  function easeInOutQuad(t, b, c, d) {
218    t /= d / 2;
219    if (t < 1) return c / 2 * t * t + b;
220    t--;
221    return -c / 2 * (t * (t - 2) - 1) + b;
222  }
223
224  requestAnimationFrame(animation);
225}
226

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.