PageSourceSearch

https://www.resourcemfg.com/wp-content/themes/sol-blank-slate/assets/js/main.js?ver=20260929122250

js resourcemfg.com collected 2026-09-29 12:33:29 UTC 13,539 bytes, 408 lines download raw bytes

1jQuery(document).ready(function() {
2	// Offset top of page-banner to height of header
3	setTimeout(function() {
4		var headerHeight = jQuery('header.site-header').height();
5		var popupHeight = jQuery('#popmake-3899').outerHeight();
6		if(typeof popupHeight == 'undefined') {
7			popupHeight = 0;
8		}
9		var mainOffset = Math.floor(headerHeight + popupHeight);
10		jQuery('main').css('margin-top', mainOffset);
11	}, 250);
12	
13	// Offset top of header by height of admin bar
14	setTimeout(function() {
15		if(jQuery('body').hasClass('admin-bar')) { 
16			var adminBarHeight = jQuery('#wpadminbar').height();
17			jQuery('header.site-header').css('top', adminBarHeight);
18		}
19	}, 250);
20	
21	// Offset top of header by height of popup
22	setTimeout(function() {
23		var popupHeight = jQuery('#popmake-3899').outerHeight();
24		if(typeof popupHeight == 'undefined') {
25			popupHeight = 0;
26		}
27		jQuery('header.site-header').css('padding-top', popupHeight);
28	}, 250);
29	
30	// Offset footer padding bottom by height of Cookies banner
31	var cookieBannerHeight = jQuery('#popmake-123').outerHeight();
32	if(cookieBannerHeight > 0) {
33		jQuery('footer').css('padding-bottom', cookieBannerHeight);
34	}
35	
36	// Open Accordions on the Locations page by default on page load
37	jQuery('.post-type-archive-locations .accordion-block .accordion .accordion-content').css('height', 'auto');
38	
39	jQuery(document).on( 'click', '.accordion', function() {
40		jQuery(this).children('a').on('click', function(e) {
41			e.stopImmediatePropagation;
42		}); 
43		if(jQuery(this).children('.accordion-content').hasClass('clicked')) {
44			jQuery(this).children('.accordion-content').removeClass('clicked');
45			curHeight = jQuery(this).children('.accordion-content').height();
46			jQuery(this).children('.accordion-content').height(curHeight).animate({height: 0}, 250);			
47		} else {
48			jQuery(this).children('.accordion-content').addClass('clicked');
49			curHeight = jQuery(this).children('.accordion-content').height();
50			autoHeight = jQuery(this).children('.accordion-content').css('height', 'auto').height();
51			jQuery(this).children('.accordion-content').height(curHeight).animate({height: autoHeight}, 250);	
52		}
53		if(jQuery(this).children('.accordion-head').hasClass('clicked')) {
54			jQuery(this).children('.accordion-head').removeClass('clicked');
55		} else {
56			jQuery(this).children('.accordion-head').addClass('clicked');
57		}
58	});
59	
60	jQuery(document).on('click', '.accordion-content a', function(e) {
61		e.stopPropagation();
62	});
63	
64	var windowWidth = jQuery(window).width();
65	if(windowWidth <= 1608) {
66		jQuery('.site-header').addClass('mobile');
67	} else {
68		jQuery('.site-header').removeClass('mobile');
69	}
70	
71	// Open Primary Nav on click of the Hamburger on mobile
72	jQuery(document).on('click', '#hamburger', function() {
73		if(jQuery('#hamburger').hasClass('open')) {
74			jQuery('#hamburger').removeClass('open');
75			jQuery('.menu-primary-nav-container').removeClass('clicked');
76		} else {
77			jQuery('#hamburger').addClass('open');
78			jQuery('.menu-primary-nav-container').addClass('clicked');
79		}
80	});
81	
82	// don't navigate to the parent page unless its menu is already opened
83	jQuery('.menu-item-has-children').on('click', function() {
84		if(jQuery(this).hasClass('clicked')) {
85			jQuery(this).removeClass('clicked');
86		} else {
87			jQuery(this).addClass('clicked');
88		}
89	});
90	
91	jQuery('.menu-item-has-children').each( function() {
92    jQuery(this).find('a').first().on('click', function(e) {
93      if(jQuery(this).parent('li').hasClass('clicked')) {
94        // do nothing
95      } else {
96        e.preventDefault();
97      }
98    });
99	});
100	
101	jQuery('.sub-menu li').on('click', function(e) {
102		e.stopPropagation();
103	}); 
104	
105	jQuery('header.site-header #site-branding .menu-primary-nav-container ul#menu-primary-nav li.login').on('click', function() {
106		tracking_click('Login Header Clicked', {
107			category: 'Header',
108			label: 'Login',
109			source_brand: 'ResourceMFG',
110		});
111	});
112	
113	jQuery('header.site-header #site-branding .menu-primary-nav-container ul#menu-primary-nav li.apply-now').on('click', function() {
114		tracking_click('Apply Now Header Clicked', {
115			category: 'Header',
116			label: 'Login',
117			source_brand: 'ResourceMFG',
118		});
119	});
120	
121	jQuery('#popmake-3899 button.pum-close').on('click', function() {
122		jQuery('header.site-header').animate({'padding-top':0}, 200);
123		jQuery('#popmake-3899').addClass('shrink');
124	});
125	
126	jQuery('#popmake-123 button.pum-close').on('click', function() {
127		jQuery('footer.site-footer').animate({'padding-bottom':0}, 200);
128	});
129	
130});
131
132jQuery(window).on('scroll', function() {
133	var scroll = jQuery(window).scrollTop();
134	// Scroll > 30 is for when there is no notification banner
135	if(scroll > 84) {
136		jQuery('header.site-header').addClass('shrink');
137		jQuery('#popmake-3899').addClass('shrink');
138	} else {
139		if(jQuery('header.site-header').hasClass('shrink')) {
140			jQuery('header.site-header').removeClass('shrink');
141			jQuery('#popmake-3899').removeClass('shrink');	
142		}
143	}
144});
145
146jQuery(window).on('resize', function() {
147	// Offset top of page-banner to height of header
148	setTimeout(function() {
149		var headerHeight = jQuery('header.site-header').height();
150		var popupHeight = jQuery('#popmake-3899').outerHeight();
151		var mainOffset = Math.ceil(headerHeight + popupHeight);
152		jQuery('main').css('margin-top', mainOffset);
153	}, 250);
154	
155	//Offset top of header by height of admin bar
156	setTimeout(function() {
157		if(jQuery('body').hasClass('admin-bar')) { 
158			var adminBarHeight = jQuery('#wpadminbar').height();
159			jQuery('header.site-header').css('top', adminBarHeight);
160		}
161	}, 250);
162	
163	// Offset top of header by height of popup
164	setTimeout(function() {
165		var popupHeight = jQuery('#popmake-3899').outerHeight();
166		jQuery('header.site-header').css('padding-top', popupHeight);
167	}, 250);
168	
169	// Offset footer padding bottom by height of Cookies banner
170	setTimeout(function() {
171		var cookieBannerHeight = jQuery('#popmake-123').outerHeight();
172		if(cookieBannerHeight > 0) {
173			jQuery('footer').css('padding-bottom', cookieBannerHeight);
174		}
175	}, 250);
176	
177	var windowWidth = jQuery(window).width();
178	if(windowWidth <= 1608) {
179		jQuery('.site-header').addClass('mobile');
180	} else {
181		jQuery('.site-header').removeClass('mobile');
182	}
183});
184
185function setSegmentData() {
186	let url = window.location.href;
187	if(url.includes('?')) {
188    let analytic_4 = { 'Actions Google Analytic 4': { 'client_id': gaGlobal.vid } };
189		const queryString = window.location.search;
190		const urlParams = new URLSearchParams(queryString);
191		var searchCity = urlParams.get('_city');
192		var searchState = urlParams.get('_state');
193		var searchTitle = urlParams.get('_title');
194
195    let searchParams = { 
196      category: 'Job Posting',
197      label: 'Job Searched',
198      source_brand: 'ResourceMFG',
199    };
200    if ( searchCity ) searchParams.city = searchCity;
201    if ( searchState ) searchParams.state = searchState;
202    if ( searchTitle ) searchParams.job_title = searchTitle;
203    window.analytics.track( 'Search Jobs Clicked', searchParams, { integrations: analytic_4 });
204	} 
205}
206
207/*
208function setSegmentData() {
209	let url = window.location.href;
210	if(url.includes('?')) {
211		const queryString = window.location.search;
212		const urlParams = new URLSearchParams(queryString);
213		var searchCity = urlParams.get('_city');
214		var searchState = urlParams.get('_state');
215		var searchTitle = urlParams.get('_title');
216
217		if(searchCity && searchState && searchTitle) {
218			window.analytics.track('Search Jobs Clicked', {
219				category: 'Job Posting',
220				city: searchCity,
221				job_title: searchTitle,
222				state: searchState,
223				label: 'Job Searched',
224				source_brand: 'ResourceMFG',
225			});    
226		} else if(searchCity && searchState) {
227			window.analytics.track('Search Jobs Clicked', {
228				category: 'Job Posting',
229				city: searchCity,
230				state: searchState,
231				label: 'Job Searched',
232				source_brand: 'ResourceMFG',
233			}); 
234		} else if(searchCity && searchTitle) {
235			window.analytics.track('Search Jobs Clicked', {
236				category: 'Job Posting',
237				city: searchCity,
238				job_title: searchTitle,
239				label: 'Job Searched',
240				source_brand: 'ResourceMFG',
241			}); 
242		} else if(searchState && searchTitle) {
243			window.analytics.track('Search Jobs Clicked', {
244				category: 'Job Posting',
245				job_title: searchTitle,
246				state: searchState,
247				label: 'Job Searched',
248				source_brand: 'ResourceMFG',
249			}); 
250		} else if(searchTitle) {
251			window.analytics.track('Search Jobs Clicked', {
252				category: 'Job Posting',
253				job_title: searchTitle,
254				label: 'Job Searched',
255				source_brand: 'ResourceMFG',
256			}); 
257		} else if(searchCity) {
258			window.analytics.track('Search Jobs Clicked', {
259				category: 'Job Posting',
260				city: searchCity,
261				label: 'Job Searched',
262				source_brand: 'ResourceMFG',
263			}); 
264		} else if(searchState) {
265			window.analytics.track('Search Jobs Clicked', {
266				category: 'Job Posting',
267				state: searchState,
268				label: 'Job Searched',
269				source_brand: 'ResourceMFG',
270			}); 
271		} 
272	} 
273}
274*/
275
276function getCookie(name) {
277    // Split cookie string and get all individual name=value pairs in an array
278    var cookieArr = document.cookie.split(";");
279
280    // Loop through the array elements
281    for(var i = 0; i < cookieArr.length; i++) {
282        var cookiePair = cookieArr[i].split("=");
283
284        /* Removing whitespace at the beginning of the cookie name
285        and compare it with the given string */
286        if(name == cookiePair[0].trim()) {
287            // Decode the cookie value and return
288            return decodeURIComponent(cookiePair[1]);
289        }
290    }
291
292    // Return null if not found
293    return null;
294}
295
296
297/**
298 * apply.resourcemfg link behavior:  
299 *  
300 *  - On session creation, check href for any of the target parameters and add
301 *    them to the session.
302 *  - On clicking an applicable link, set any explicit target parameters in the
303 *    link as the user's session parameters, then build the link href's parameters
304 *    out of the session parameters and redirect the user.
305 */
306
307jQuery(document).ready( function() {
308  initApplySession(); // initialize apply parameters in session
309});
310document.addEventListener('facetwp-loaded', function() { initApplySession(); });
311
312function initApplySession()
313{
314  let utm_source = 'www.resourcemfg.com';
315  if ( ! sessionStorage.getItem( 'utm_source' ) )
316  {
317    sessionStorage.setItem( 'utm_source', 'resourcemfg.com' );
318    //sessionStorage.setItem( 'utm_referrer', Document.referrer );
319    sessionStorage.setItem( 'utm_medium', null );
320    sessionStorage.setItem( 'utm_campaign', null );
321    sessionStorage.setItem( 'agency', null );
322  }
323
324  // Since this item sometimes takes longer to be added or only appears after
325  // an action, set it every time.
326  sessionStorage.setItem( 'anonymousID', getCookie( 'ajs_anonymous_id' ) );
327
328  // If the current URL has parameters, override the session data.
329  let params = new URL( window.location ).searchParams;
330  
331  if ( params.has( 'utm_source' ) ) 
332    sessionStorage.setItem( 'utm_source', params.get( 'utm_source' ) );
333  if ( params.has( 'utm_medium' ) ) 
334    sessionStorage.setItem( 'utm_medium', params.get( 'utm_medium' ) );
335  if ( params.has( 'utm_campaign' ) ) 
336    sessionStorage.setItem( 'utm_campaign', params.get( 'utm_campaign' ) );
337  if ( params.has( 'agency' ) ) 
338    sessionStorage.setItem( 'agency', params.get( 'agency' ) );
339//  if ( Document.referrer === undefined ) 
340//    sessionStorage.setItem( 'utm_referrer', null );
341}
342
343// TODO: For efficiency, make this apply to a classed link instead.
344jQuery(document).on( 'click', 'a', function(e) 
345  {
346    let link = jQuery(this);
347    let regex_url = 'apply\.resourcemfg';
348    let link_href = jQuery(this).attr('href');
349    if ( link_href && link_href.match( regex_url ) )
350    {
351      e.preventDefault();
352
353      let url = new URL( link_href );
354
355      let applyParams = [ 'utm_source', 'utm_medium',
356        'utm_campaign', 'agency', 'anonymousID' ];
357
358      // Use the link's search parameters.  Process the list of expected parameters,
359      // and where any are missing, use the session data.  
360      let params = url.searchParams;
361
362      applyParams.forEach( (param) => {
363        // Where the link has its own parameters, if session param is null, set it to the link value.
364        if ( params.has( param ))
365        {
366          console.log( 'param ' + param + ' found - testing for existing session data' );
367          const sessionParam = sessionStorage.getItem( param );
368          if ( ! sessionParam || sessionParam == 'null' )
369          {
370            console.log( 'session value for ' + param + ' null, setting with link parameter' );
371            sessionStorage.setItem( param, params.get( param ) );
372          }
373          else
374          {
375            console.log( 'session value for ' + param + ' found, ignoring' );
376            params.set( param, sessionStorage.getItem( param ) );
377          }
378        }
379
380        // Where it does not, append the current session value for the parameter. 
381        else
382          params.append( param, sessionStorage.getItem( param ) );
383      });
384
385      let current = new URL( window.location ).searchParams;
386      current.forEach( (value, param) => {
387        if ( ! params.has( param ) )
388          params.append( param, value );
389      });
390
391      url.search = params;
392      console.log( url.toString() );
393
394      document.location.href = url.toString();
395    }
396  }
397);
398
399function tracking_click( title, args )
400{
401  gtag('get', 'G-H2KHVX0B89', 'client_id', (client_id) => {
402    window.analytics.track( title, args, 
403      { integrations: { 'Actions Google Analytic 4': { 'client_id': client_id }}}
404    );
405  })
406}
407
408

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.