PageSourceSearch

https://quartermasterfoods.com/themes/parallax/js/parallax.js

js quartermasterfoods.com collected 2026-09-29 17:07:08 UTC 4,047 bytes, 145 lines download raw bytes

1(function ($) {
2	'use strict'; // Start of use strict
3
4	console.log('loaded parallax.js');
5
6	// Set permanent widths for navbar at load
7	const navbarWidth = $('.navbar').width();
8	const navmenuWidth = $('.navbar-nav').width();
9
10	// Smooth scrolling using jQuery easing
11	$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
12		if (
13			location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') &&
14			location.hostname == this.hostname
15		) {
16			var target = $(this.hash);
17			target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
18			if (target.length) {
19				$('html, body').animate(
20					{
21						scrollTop: target.offset().top - 48,
22					},
23					1000,
24					'easeInOutExpo'
25				);
26				return false;
27			}
28		}
29	});
30
31	// Closes responsive menu when a scroll trigger link is clicked
32	$('.js-scroll-trigger').on('click', function () {
33		$('.navbar-collapse').collapse('hide');
34	});
35
36	// Activate scrollspy to add active class to navbar items on scroll
37	$('body').scrollspy({
38		target: '#top-nav',
39		offset: 54,
40	});
41
42	// Collapse the navbar when page is scrolled
43	document.addEventListener('scroll', function (e) {
44		// Only do this on the index page
45		if (doesNavbarFitScreen() && window.location.pathname === '/') {
46			if ($('#top-nav').offset().top > 100) {
47				addCollapseClass();
48			} else {
49				removeCollapseClass();
50			}
51		}
52	});
53
54	window.addEventListener(
55		'resize',
56		function () {
57			setCollapseClass();
58		},
59		true
60	);
61
62	// Set staticly
63	setCollapseClass();
64
65	/*
66If a member has added too many pages, automatically collapse the menu into the hamburger button
67 */
68
69	// Force the expanded menu because the collapsed one will not overflow the page width
70	function doesNavbarFitScreen() {
71		return navbarWidth > navmenuWidth + 100;
72	}
73
74	function setCollapseClass() {
75		if (window.location.pathname === '/') {
76			if (doesNavbarFitScreen()) {
77				removeCollapseClass();
78			} else {
79				addCollapseClass();
80			}
81		} else {
82			addCollapseClass();
83		}
84	}
85
86	function addCollapseClass() {
87		if ($('.navbar').hasClass('navbar-expand-md')) {
88			$('.navbar').removeClass('navbar-expand-md');
89		}
90		if (!$('#top-nav').hasClass('navbar-shrink')) {
91			$('#top-nav').addClass('navbar-shrink');
92		}
93	}
94	function removeCollapseClass() {
95		if (!$('.navbar').hasClass('navbar-expand-md')) {
96			$('.navbar').addClass('navbar-expand-md');
97		}
98		if ($('#top-nav').hasClass('navbar-shrink')) {
99			$('#top-nav').removeClass('navbar-shrink');
100		}
101	}
102
103	// Handle the newsletter signup form
104	$('#newsletter-signup-submit').on('submit', function () {
105		const language = $('#newsletter-signup-language').val();
106
107		// Check if the email address is valid
108		if ($('#newsletter-signup-email').val() === '') {
109			if (language === 'en') {
110				alert('You must enter an email address');
111			} else if (language === 'fr') {
112				alert('Vous devez entrer une adresse e-mail');
113			}
114			$('#newsletter-signup-email').focus();
115			return false;
116		}
117		var re =
118			/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
119		if (!re.test(String($('#newsletter-signup-email').val()).toLowerCase())) {
120			if (language === 'en') {
121				alert('The email address you entered was not valid');
122			} else if (language === 'fr') {
123				alert("L'adresse e-mail que vous avez saisie n'était pas valide");
124			}
125			$('#newsletter-signup-email');
126			return false;
127		}
128
129		// Check if the first and last name are valid
130		if ($('#newsletter-signup-firstname').val() === '' || $('#newsletter-signup-lastname').val() === '') {
131			if (language === 'en') {
132				alert('You must enter a first and last name');
133			} else if (language === 'fr') {
134				alert('Vous devez entrer un prénom et un nom de famille');
135			}
136			$('#newsletter-signup-firstname').focus();
137			return false;
138		}
139	});
140
141	$('#language_switch').on('click', function () {
142		document.cookie = 'lang=' + $(this).data('lang') + ';path=/';
143		window.location.reload();
144	});
145})(jQuery); // End of use strict

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.