PageSourceSearch

https://joyceszetormt.com/js/custom.260305032814.js

js joyceszetormt.com collected 2026-10-08 10:20:19 UTC 11,404 bytes, 410 lines download raw bytes

1/* JS for preset "Menu V2" */
2(function() {
3	$(function() {
4		$('.menu-wrapper').each(function() {
5			initMenu($(this))
6		});
7	});
8
9	// Make :active pseudo classes work on iOS
10	document.addEventListener("touchstart", function() {}, false);
11
12	const initMenu = function($menuWrapper) {
13		const $body = $('body');
14		const $menu = $('.ed-menu', $menuWrapper);
15		const $menuLinks = $('a', $menu);
16		const $menuTrigger = $('.menu-trigger', $menuWrapper);
17		const $banner = $('.banner').first();
18
19		const smoothScrollOffset = 20;
20		
21		// Set aria attributes
22		$menuTrigger.attr({
23				'aria-expanded': 'false',
24				'aria-controls': $menu.attr('id'),
25		});
26
27		toggleClassOnClick($body.add($menu), $menuTrigger, null, 'open open-menu'); // Keep open on $menu for backward compatibility
28		activateSmoothScroll($menuLinks.add($('.scroll a')), smoothScrollOffset);
29		addClassOnVisibleLinkTargets($menuLinks, 'active', 2 / 3);
30		handleSticky($menuWrapper, 'sticky', $banner);
31	};
32
33	/**
34	 * Observe element's height changes and reload the initMenu() function
35	 *
36	 * @param {HTMLElement} elm Element to observe
37	 * @param {function} callback to call when elmement's height changed
38	 */
39	const observeHeightChange = function(elm, callback) {
40		if (!('ResizeObserver' in window) || elm == null) return;
41
42		const ro = new ResizeObserver(callback);
43		ro.observe(elm);
44	}
45
46	/**
47	 * Toggles class on a target when a trigger is clicked
48	 * 
49	 * @param {jQuery} $target The target to apply the CSS class to
50	 * @param {jQuery} $trigger The Trigger
51	 * @param {jQuery} $closeTrigger Optional close trigger
52	 * @param {string} cssClass CSS Class to toggle on the target
53	 */
54	const toggleClassOnClick = function($target, $trigger, $closeTrigger, cssClass) {
55
56		// Reset in case class "open" was saved accidentally
57		$target.removeClass(cssClass);
58		$trigger.removeClass(cssClass).attr('aria-expanded', 'false');
59
60		// Click on trigger toggles class "open"
61		$trigger.off('.toggle').on('click.toggle', function() {
62			const isExpanded = $(this).attr('aria-expanded') === 'true';
63			const $menu = $target.filter('.ed-menu');
64			$(this).toggleClass(cssClass).attr('aria-expanded', !isExpanded);
65			$target.toggleClass(cssClass);
66
67			// Set focus to menu on open
68			if (!isExpanded) {
69				$menu.attr('tabindex', '0');
70				const focusMenu = () => {
71					$menu.focus();
72					$menu.off('transitionend', focusMenu);
73				};
74				$menu.on('transitionend', focusMenu);
75			}
76
77			$menu[0].addEventListener(
78				'blur',
79				function() {
80					$menu[0].removeAttribute('tabindex');
81				}, {
82					once: true
83				}
84			);
85		});
86
87		// Close target when link inside is clicked
88		$target.find('a').click(function() {
89			$target.removeClass(cssClass);
90			$trigger.removeClass(cssClass).attr('aria-expanded', 'false');
91		});
92
93		if (!$closeTrigger || !$closeTrigger.length) {
94			return;
95		}
96
97		$closeTrigger.click(function() {
98			$target.removeClass(cssClass);
99			$trigger.removeClass(cssClass).attr('aria-expanded', 'false');
100		});
101	};
102
103	/**
104	 * Smooth scroll to link targets
105	 * 
106	 * @param {jQuery} $scrollLinks The links
107	 * @param {jQuery} scrollOffset Offset to subtract from the scroll target position (e.g. for fixed positioned elements like a menu)
108	 */
109	const activateSmoothScroll = function($scrollLinks, scrollOffset) {
110		if (typeof scrollOffset === 'undefined') {
111			scrollOffset = 0;
112		}
113
114		const determineTarget = function($trigger, hash) {
115			if (hash == '#!next') {
116				return $trigger.closest('.ed-element').next();
117			}
118			// Prevent invalid selectors
119			try {
120				return $(hash);
121			} catch (e) {
122				return $();
123			}
124		}
125
126		$scrollLinks.click(function(e) {
127			const $target = determineTarget($(this), this.hash);
128			if (!$target.length) return;
129			e.preventDefault();
130
131			viewport.scrollTo($target, 'top', 500, 0);
132
133		});
134	};
135
136	/**
137	 * We are using the fill property on an element to pass user's choices from CSS to JavaScript
138	 * 
139	 * @param {jQuery} $element
140	 */
141	const getStickyMode = function($element) {
142		const fillValue = getComputedStyle($element[0]).fill;
143
144		return fillValue === 'rgb(255, 0, 0)' ?
145			'sticky_banner' :
146			fillValue === 'rgb(0, 255, 0)' ?
147			'sticky_menu' :
148			fillValue === 'rgb(0, 0, 255)' ?
149			'sticky_instant' :
150			fillValue === 'rgb(255, 255, 255)' ?
151			'sticky_reverse' :
152			'sticky_none';
153	};
154
155	/**
156	 * Adds a class to an element when not currently visible
157	 * 
158	 * @param {jQuery} $element The element to handle stickyness for
159	 * @param {string} cssClass The actual CSS class to be applied to the element when it's above a certain scroll position
160	 * @param {jQuery} $banner A banner to reference the scroll position to
161	 */
162	const handleSticky = function($element, cssClass, $banner) {
163		let triggerPos = 0,
164			offset = 0;
165		let menuWrapperHeight = $element.outerHeight();
166		let mode;
167		let prevScroll = 0;
168		$element.removeClass(cssClass);
169		
170		const toggleSpacer = function(toggle) {
171			document.body.style.setProperty('--spacer-height', toggle ? menuWrapperHeight + 'px' : '');
172		};
173
174		const handleScroll = function() {
175			if (!$element.length || mode === 'sticky_none') return;
176			//if (!$element.length || mode === 'sticky_none' || mode === 'sticky_instant') return;
177
178			const isReverse = mode === 'sticky_reverse',
179				curScroll = viewport.getScrollTop();
180
181			if (triggerPos <= curScroll && (!isReverse || prevScroll > curScroll)) {
182				$element.addClass(cssClass);
183				toggleSpacer(true);
184			} else {
185				$element.removeClass(cssClass);
186				toggleSpacer(false);
187			}
188
189			prevScroll = curScroll;
190		};
191		
192		const updateOffset = function() {
193			mode = getStickyMode($element);
194			menuWrapperHeight = $element.outerHeight();
195			if (!$element.hasClass(cssClass)) {
196				offset = $element.offset().top;
197			}
198			if (mode === 'sticky_banner' && !$banner.length) {
199				mode = 'sticky_menu';
200			}
201			if (mode === 'sticky_banner') {
202				triggerPos = $banner.offset().top + ($banner.length ? $banner.outerHeight() : $element.outerHeight());
203			}
204			if (mode === 'sticky_menu' || mode === 'sticky_reverse') {
205				triggerPos = offset + $element.outerHeight();
206			}
207			if (mode === 'sticky_instant') {
208				triggerPos = offset;
209			}
210			
211			handleScroll();
212		}
213		
214		viewport.observe('resize', updateOffset);
215		viewport.observe('animation.end', updateOffset);
216		observeHeightChange($element[0], updateOffset);
217		updateOffset();
218		
219		viewport.observe('scroll', handleScroll);
220		handleScroll();
221	};
222
223	/**
224	 * Adds a class to links whose target is currently inside the viewport
225	 * 
226	 * @param {jQuery} $links Link(s) to be observed
227	 * @param {string} cssClass CSS Class to be applied
228	 * @param {float} sectionViewportRatio Ratio by which the target should be within the viewport
229	 */
230	const addClassOnVisibleLinkTargets = function($links, cssClass, sectionViewportRatio) {
231		if (typeof sectionViewportRatio === 'undefined') {
232			sectionViewportRatio = 1 / 2;
233		}
234
235		const menuTargets = [];
236		const activeLink = $links.filter('.active');
237
238		const links = $links.filter(function() {
239			// Prevent invalid selectors
240			let $target;
241			try {
242				$target = $(this.hash);
243			} catch (e) {
244				return false;
245			}
246			if (!this.hash || !$target.length) {
247				return false;
248			}
249
250			// Cache offset position to improve performance (update on resize)		
251			const updateOffset = function() {
252				$target.data('offset', $target.offset().top);
253			};
254
255			viewport.observe('resize', updateOffset);
256			viewport.observe('animation.end', updateOffset);
257			updateOffset();
258
259			menuTargets.push($target);
260			return true;
261		});
262
263		// No hash links found, so don't handle it at all
264		if (!links.length) {
265			return;
266		}
267
268		const checkVisibility = function() {
269			$links.removeClass('active');
270
271			// Check section position reversely
272			for (let i = menuTargets.length - 1; i >= 0; i--) {
273				const desiredScrollPosition = menuTargets[i].data('offset') - viewport.getHeight() * (1 - sectionViewportRatio);
274				if (viewport.getScrollTop() >= desiredScrollPosition && menuTargets[i][0].offsetParent !== null) {
275					links.eq(i).addClass(cssClass);
276					return;
277				}
278			}
279
280			// Fallback to originally active item
281			activeLink.addClass(cssClass);
282		};
283
284		viewport.observe('scroll', checkVisibility);
285		checkVisibility();
286	};
287})();
288/* End JS for preset "Menu V2" */
289
290/* JS for preset "Counter V2" */
291$(function() {
292	EasingFunctions = {
293		// no easing, no acceleration
294		linear: function(t) {
295			return t
296		},
297		// accelerating from zero velocity
298		easeInQuad: function(t) {
299			return t * t
300		},
301		// decelerating to zero velocity
302		easeOutQuad: function(t) {
303			return t * (2 - t)
304		},
305		// acceleration until halfway, then deceleration
306		easeInOutQuad: function(t) {
307			return t < .5 ? 2 * t * t : -1 + (4 - 2 * t) * t
308		},
309		// accelerating from zero velocity 
310		easeInCubic: function(t) {
311			return t * t * t
312		},
313		// decelerating to zero velocity 
314		easeOutCubic: function(t) {
315			return (--t) * t * t + 1
316		},
317		// acceleration until halfway, then deceleration 
318		easeInOutCubic: function(t) {
319			return t < .5 ? 4 * t * t * t : (t - 1) * (2 * t - 2) * (2 * t - 2) + 1
320		},
321		// accelerating from zero velocity 
322		easeInQuart: function(t) {
323			return t * t * t * t
324		},
325		// decelerating to zero velocity 
326		easeOutQuart: function(t) {
327			return 1 - (--t) * t * t * t
328		},
329		// acceleration until halfway, then deceleration
330		easeInOutQuart: function(t) {
331			return t < .5 ? 8 * t * t * t * t : 1 - 8 * (--t) * t * t * t
332		},
333		// accelerating from zero velocity
334		easeInQuint: function(t) {
335			return t * t * t * t * t
336		},
337		// decelerating to zero velocity
338		easeOutQuint: function(t) {
339			return 1 + (--t) * t * t * t * t
340		},
341		// acceleration until halfway, then deceleration 
342		easeInOutQuint: function(t) {
343			return t < .5 ? 16 * t * t * t * t * t : 1 + 16 * (--t) * t * t * t * t
344		}
345	}
346    
347	$('[data-count]').each(function() {
348		var $target = $(this);
349		var offset = 0;
350		
351		var duration = 2000;
352		var interval = Math.floor(duration / 60);
353		var steps = Math.ceil(duration / interval);
354		var max = $target.data('count');
355		
356		var run = false, handle;
357		
358		// Cache offset position to improve performance (update on resize)		
359		var updateOffset = function() {
360			offset = $target.offset().top + $target.height()/2;
361		};
362		viewport.observe('resize', updateOffset);
363		viewport.observe('animation.end', updateOffset);
364		updateOffset();
365		
366		var resetCounter = function() {
367		    $target.html('0');
368		    run = false;
369		};
370		
371		var finishCounter = function() {
372		    $target.html(max);
373			window.clearInterval(handle);
374		};
375
376		var startCounter = function() {
377			if (run) return;
378
379			run = true;
380			var i = 0;
381			handle = window.setInterval(function() {
382                var newCount = Math.round(max * EasingFunctions.easeOutCubic(++i / steps));
383                if (newCount >= max) {
384                    return finishCounter();
385                }
386				$target.html(newCount);
387			}, interval);
388		};
389		
390		var checkVisiblity = function() {
391		    var t = viewport.getScrollTop();
392		    var h = viewport.getHeight();
393		    if (t < offset && offset < t+h) {
394				!run && startCounter();
395			} else {
396			    run && resetCounter();
397			}
398		};
399		
400		viewport.observe('scroll', checkVisiblity);
401		checkVisiblity();
402	});
403});
404/* End JS for preset "Counter V2" */
405
406/* JS for preset "Marquee V2" */
407$(function() {
408   $('.marquee-wrap').attr('data-items', $('.marquee-wrap > .inner').children().length);
409});
410/* End JS for preset "Marquee V2" */

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.