PageSourceSearch

https://manufacturelaurentides.com/wp-content/plugins/thegem-eleme…?ver=7b8c999ed2f60c057def06930650b7fb

js manufacturelaurentides.com collected 2026-10-09 02:59:13 UTC 32,925 bytes, 1,033 lines download raw bytes

1(function ($) {
2
3	'use strict';
4
5	let $body, $header, $wrapper, $navigate, menuLockedTimeout;
6
7	const pageOffset = $('#page').offset();
8	const pageWidth = $('#page').width();
9
10	const _helpers = {
11		setMobMenuDefaultLeftPosition: (wrap, elem) => {
12			let item = wrap.getBoundingClientRect();
13			let itemLeftPosition = item.x + pageXOffset;
14
15			$(elem).css({
16				left: -itemLeftPosition
17			});
18		},
19		setMobMenuDefaultMaxHeight: (elem) => {
20			let headerHeight = $wrapper.outerHeight(),
21				windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
22			$(elem).css({
23				maxHeight: windowHeight - headerHeight
24			});
25		},
26		getScrollY: () => {
27			return window.pageYOffset || document.documentElement.scrollTop;
28		},
29		setBodyLocked: (elem) => {
30			$body.data('scroll-position', _helpers.getScrollY());
31			clearTimeout(menuLockedTimeout);
32			$body.addClass('menu-scroll-locked');
33
34			let isNoStickyItem = $(elem).closest("#site-header").length;
35			if (isNoStickyItem){
36				$body.addClass('is-no-sticky');
37			} else {
38				$body.removeClass('is-no-sticky');
39			}
40		},
41		unsetBodyLocked: () => {
42			menuLockedTimeout = setTimeout(function () {
43				$body.removeClass('menu-scroll-locked is-no-sticky');
44			}, 1000);
45
46			if ($body.data('scroll-position')) {
47				window.scrollTo(0, $body.data('scroll-position'))
48			}
49		},
50		isMobMenuSlidingInit: ($item) => {
51			let result = false;
52			if ($item.hasClass('mobile-view')) {
53				result = true;
54			}
55
56			return result;
57		},
58		isResponsiveMenuVisible: (elem) => {
59			return elem.parents('.thegem-te-menu').find('.menu-toggle:not(.hamburger-toggle)').is(':visible');
60		},
61		isBody: (elem) => {
62			return (/^(?:body|html)$/i).test(elem.tagName);
63		},
64		getScroll: () => {
65			return {
66				x: window.pageXOffset || document.documentElement.scrollLeft,
67				y: window.pageYOffset || document.documentElement.scrollTop
68			};
69		},
70		getScrolls: (elem) => {
71			let element = elem.parentNode, position = {x: 0, y: 0};
72			while (element && !_helpers.isBody(element)) {
73				position.x += element.scrollLeft;
74				position.y += element.scrollTop;
75				element = element.parentNode;
76			}
77			return position;
78		},
79		styleString: (elem, style) => {
80			return $(elem).css(style);
81		},
82		styleNumber: (elem, style) => {
83			return parseInt(_helpers.styleString(elem, style)) || 0;
84		},
85		topBorder: (elem) => {
86			return _helpers.styleNumber(elem, 'border-top-width');
87		},
88		leftBorder: (elem) => {
89			return _helpers.styleNumber(elem, 'border-left-width');
90		},
91		getOffset: (elem) => {
92			if (elem.getBoundingClientRect && window.gemBrowser.platform.name != 'ios') {
93				let bound = elem.getBoundingClientRect(),
94					html = elem.ownerDocument.documentElement,
95					htmlScroll = _helpers.getScroll(html),
96					elemScrolls = _helpers.getScrolls(elem),
97					isFixed = (_helpers.styleString(elem, 'position') == 'fixed');
98				return {
99					x: bound.left + elemScrolls.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,
100					y: bound.top + elemScrolls.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop
101				};
102			}
103
104			let element = elem, position = {x: 0, y: 0};
105			if (_helpers.isBody(elem)) return position;
106
107			while (element && !_helpers.isBody(element)) {
108				position.x += element.offsetLeft;
109				position.y += element.offsetTop;
110
111				if (window.gemBrowser.name == 'firefox') {
112					if (!borderBox(element)) {
113						position.x += _helpers.leftBorder(element);
114						position.y += _helpers.topBorder(element);
115					}
116					let parent = element.parentNode;
117					if (parent && _helpers.styleString(parent, 'overflow') != 'visible') {
118						position.x += _helpers.leftBorder(parent);
119						position.y += _helpers.topBorder(parent);
120					}
121				} else if (element != elem && window.gemBrowser.name == 'safari') {
122					position.x += _helpers.leftBorder(element);
123					position.y += _helpers.topBorder(element);
124				}
125
126				element = element.offsetParent;
127			}
128			if (window.gemBrowser.name == 'firefox' && !borderBox(elem)) {
129				position.x -= _helpers.leftBorder(elem);
130				position.y -= _helpers.topBorder(elem);
131			}
132			return position;
133		},
134		setTranslateValues: (elem) => {
135			if (!elem.length) return;
136			$('.mobile-menu-slide-wrapper', elem).css('transform', '');
137			elem.css('transform', '').css('margin-left', '').css('margin-top', '');
138			const style = window.getComputedStyle(elem[0]);
139			const matrix = style['transform'] || style.webkitTransform || style.mozTransform;
140			let x = 0, y = 0;
141
142			// No transform property. Simply return 0 values.
143			if (matrix === 'none' || typeof matrix === 'undefined') {
144				return;
145			}
146
147			// Can either be 2d or 3d transform
148			const matrixType = matrix.includes('3d') ? '3d' : '2d';
149			const matrixValues = matrix.match(/matrix.*\((.+)\)/)[1].split(', ');
150
151			// 2d matrices have 6 values
152			// Last 2 values are X and Y.
153			// 2d matrices does not have Z value.
154			if (matrixType === '2d') {
155				x = matrixValues[4];
156				y = matrixValues[5];
157			}
158
159			// 3d matrices have 16 values
160			// The 13th, 14th, and 15th values are X, Y, and Z
161			if (matrixType === '3d') {
162				x = matrixValues[12];
163				y = matrixValues[13];
164			}
165
166			elem.css('transform', 'none').css('margin-left', x + 'px').css('margin-top', y + 'px');
167		}
168	};
169
170	const menuScripts = {
171		init: () => {
172			$body = $('body');
173			$header = $('#site-header');
174			$wrapper = $('.thegem-template-header');
175			$navigate = $('.thegem-te-menu > nav');
176
177			menuScripts.setLayoutView();
178			menuScripts.onResize();
179			menuScripts.menuAbsoluteTranslate();
180			menuScripts.menuDefault();
181			menuScripts.menuOverlay();
182			menuScripts.menuHamburger();
183			menuScripts.mobMenuDefault();
184			menuScripts.mobMenuSliding();
185			menuScripts.menuMegaMenu();
186			menuScripts.menuMegaMenuTemplate();
187
188			$navigate.addClass('inited');
189		},
190
191		setLayoutView: () => {
192			let viewportWidth = window.innerWidth;
193			document.documentElement.style.setProperty('--scrollbar-width', -(window.innerWidth - document.body.clientWidth) + "px");
194
195			$navigate.each(function (i, nav) {
196				const tabletLandscapeMaxWidth = $(nav).data("desktop-breakpoint");
197				const tabletLandscapeMinWidth = $(nav).data("tablet-breakpoint");
198				const tabletPortraitMaxWidth = $(nav).data("tablet-breakpoint") - 1;
199				const tabletPortraitMinWidth = $(nav).data("mobile-breakpoint");
200
201				if ($(this).data("tablet-landscape") === 'default' && viewportWidth >= tabletLandscapeMinWidth && viewportWidth <= tabletLandscapeMaxWidth) {
202					$(this).removeClass('mobile-view').addClass('desktop-view');
203				} else if ($(this).data("tablet-portrait") === 'default' && viewportWidth >= tabletPortraitMinWidth && viewportWidth <= tabletPortraitMaxWidth) {
204					$(this).removeClass('mobile-view').addClass('desktop-view');
205				} else if (viewportWidth <= tabletLandscapeMaxWidth) {
206					$(this).removeClass('desktop-view').addClass('mobile-view');
207				} else {
208					$(this).removeClass('mobile-view').addClass('desktop-view');
209				}
210
211				if ($('.menu-id-'+$(this).attr('id')).length) {
212					if ($(this).hasClass('desktop-view')) {
213						$('.menu-id-'+$(this).attr('id')).removeClass('mobile-view').addClass('desktop-view');
214					} else {
215						$('.menu-id-'+$(this).attr('id')).removeClass('desktop-view').addClass('mobile-view');
216					}
217				}
218			});
219		},
220
221		menuDefault: () => {
222			let $menu = $('.thegem-te-menu__default');
223
224			$('.nav-menu > li:not(.megamenu-template-enable)', $menu).hover(function () {
225				let $items = $(this).find('ul');
226
227				let getLevelULByMenu = (item) => {
228					let parentUL = $(item).parent('li').parent('ul');
229					let level = 0;
230
231					while (!parentUL.is('.nav-menu')) {
232						parentUL = parentUL.parent('li').parent('ul');
233						level++;
234					}
235
236					return level;
237				};
238
239				let offset = $header.offset().top + $header.outerHeight() - $(this).offset().top - $(this).outerHeight();
240				// $item.css('top', 'calc(100% + ' + offset + 'px)');
241
242				$items.removeClass('invert');
243
244				if (!$(this).hasClass('megamenu-enable')) {
245					$items.css({top: ''});
246				}
247
248				if ($(this).hasClass('megamenu-enable') ||
249					$(this).closest('.header-layout-overlay').length ||
250					$(this).closest('.mobile-menu-layout-overlay').length && _helpers.isResponsiveMenuVisible($(this))) {
251					return;
252				}
253
254				$items.each(function () {
255					let $item = $(this), self = this, $parentList = $item.parent().closest('ul');
256
257					let itemOffset = $item.offset(),
258						itemOffsetLeft = itemOffset.left;
259
260					let leftItemTranslate = 0;
261					if ($item.css('transform')) {
262						leftItemTranslate = parseInt(getComputedStyle(this).transform.split(',')[4]);
263						let levelUL = getLevelULByMenu(self);
264						if (levelUL > 0) {
265							leftItemTranslate = leftItemTranslate * levelUL;
266						}
267					}
268					if (isNaN(leftItemTranslate)) leftItemTranslate = 0;
269
270					if ($parentList.hasClass('invert')) {
271						if ($parentList.offset().left - $item.outerWidth() > pageOffset.left) {
272							$item.addClass('invert');
273						}
274					} else {
275						if (itemOffsetLeft - leftItemTranslate - pageOffset.left + $item.outerWidth() > pageWidth) {
276							$item.addClass('invert');
277						}
278					}
279				});
280			});
281		},
282
283		menuOverlay: () => {
284			let $menus = $('.thegem-te-menu__overlay, .thegem-te-menu-mobile__overlay');
285
286			$menus.each(function (i, el) {
287				let $menuItem = $(el);
288				let $menuWrap = $('.overlay-menu-wrapper', $menuItem);
289				let $overlay = $('.overlay-menu-back', $menuItem);
290				let $toggle = $('.overlay-toggle', $menuItem);
291
292				// Toggle overlay menu
293				$menuItem.on('click', '.overlay-toggle', function (e) {
294					e.preventDefault();
295
296					if ($overlay.hasClass('active')) {
297						_helpers.unsetBodyLocked();
298						$overlay.removeClass('active');
299						$menuItem.addClass('close');
300						$menuItem.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function (e) {
301							$menuItem.removeClass('overlay-active close');
302							$menuWrap.removeClass('active');
303						});
304					} else {
305						_helpers.setBodyLocked(this);
306						$menuWrap.addClass('active');
307						$overlay.addClass('active');
308						$menuItem.off('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend');
309						$menuItem.addClass('overlay-active').removeClass('close');
310					}
311				});
312
313				// Close overlay menu ESC click
314				$(document).on('keydown', function (event) {
315					if (event.keyCode === 27 && $overlay.hasClass('active')) {
316						$toggle.click();
317					}
318				});
319
320				// Close overlay menu overlay click
321				$overlay.on('click', function (e) {
322					$toggle.click();
323				});
324
325				$menuWrap.on('click', function (e) {
326					let $notClick = $menuWrap.find('li');
327					if ($notClick.has(e.target).length === 0) {
328						//$toggle.click();
329					}
330				});
331
332				// Toggle overlay menu list
333				$('.menu-item-parent-toggle', $menuWrap).on('click', function (e) {
334					e.preventDefault();
335					e.stopPropagation();
336
337					let $itemLink = $(this);
338					let $item = $itemLink.closest('li');
339
340					if ($item.hasClass('menu-item-parent') && ($item.closest('ul').hasClass('nav-menu') || $item.parent().closest('li').hasClass('menu-overlay-item-open'))) {
341						e.preventDefault();
342
343						if ($item.hasClass('menu-overlay-item-open')) {
344							$(' > ul, .menu-overlay-item-open > ul', $item).each(function () {
345								$(this).css({height: $(this).outerHeight() + 'px'});
346							});
347
348							setTimeout(function () {
349								$(' > ul, .menu-overlay-item-open > ul', $item).css({height: ''});
350								$('.menu-overlay-item-open', $item).add($item).removeClass('menu-overlay-item-open');
351							}, 50);
352						} else {
353							let $oldActive = $('.nav-menu .menu-overlay-item-open').not($item.parents());
354							$('> ul', $oldActive).not($item.parents()).each(function () {
355								$(this).css({height: $(this).outerHeight() + 'px'});
356							});
357							setTimeout(function () {
358								$('> ul', $oldActive).not($item.parents()).css({height: ''});
359								$oldActive.removeClass('menu-overlay-item-open');
360							}, 50);
361
362							$('> ul', $item).css({height: 'auto'});
363							let itemHeight = $('> ul', $item).outerHeight();
364							$('> ul', $item).css({height: ''});
365							setTimeout(function () {
366								$('> ul', $item).css({height: itemHeight + 'px'});
367								$item.addClass('menu-overlay-item-open');
368								$('> ul', $item).one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function () {
369									$('> ul', $item).css({height: 'auto'});
370								});
371							}, 50);
372						}
373					}
374				});
375
376				$(document).on('click', '.menu-item.mobile-collapsible > a', function(e) {
377					if (!_helpers.isResponsiveMenuVisible($menuItem)) {
378						return;
379					}
380
381					if($(this).next('.menu-item-parent-toggle').length) {
382						e.preventDefault();
383						$(this).next('.menu-item-parent-toggle').trigger('click');
384					}
385				});
386
387				// Toggle search widget
388				$('.menu-item-type-search-widget', $menuWrap).on('click', 'a', function(e) {
389					e.preventDefault();
390					if ($(this).closest('.menu-item-fullscreen-search-mobile').length) return;
391
392					if($(this).closest('.overlay-menu-wrapper.active').length) {
393						let $primaryMenu = $('.nav-menu');
394						$primaryMenu.addClass('overlay-search-form-show animated-minisearch');
395						$('.sf-input', $primaryMenu).focus();
396
397						setTimeout(function() {
398							$(document).on('click.menu-item-search-close', 'body', function(e) {
399								if(!$(e.target).is('.menu-item-type-search-widget .minisearch *')) {
400									let $primaryMenu = $('.nav-menu');
401
402									if ($primaryMenu.hasClass('animated-minisearch')) {
403										$primaryMenu.removeClass('animated-minisearch');
404
405										setTimeout(function() {
406											$primaryMenu.removeClass('overlay-search-form-show');
407											$(document).off('click.menu-item-search-close');
408										}, 700);
409
410									} else {
411										$primaryMenu.removeClass('overlay-search-form-show');
412										$(document).off('click.menu-item-search-close');
413									}
414								}
415							});
416						}, 500);
417					} else {
418						$('.menu-item-type-search-widget').toggleClass('active');
419					}
420				});
421
422			});
423		},
424
425		menuHamburger: () => {
426			let $menus = $('.thegem-te-menu__hamburger');
427
428			$menus.each(function (i, el) {
429				let $menuItem = $(el);
430				let $overlay = $('.hamburger-menu-back', $menuItem);
431				let $toggle = $('.hamburger-toggle', $menuItem);
432
433				// Toggle hamburger menu
434				$menuItem.on('click', '.hamburger-toggle', function (e) {
435					e.preventDefault();
436
437					if ($overlay.hasClass('active')) {
438						_helpers.unsetBodyLocked();
439						$menuItem.removeClass('hamburger-active');
440						$overlay.removeClass('active');
441					} else {
442						_helpers.setBodyLocked(this);
443						$menuItem.addClass('hamburger-active');
444						$overlay.addClass('active');
445					}
446				});
447
448				$(document).on('keydown', function (event) {
449					if (event.keyCode === 27 && $overlay.hasClass('active')) {
450						$toggle.click();
451					}
452				});
453
454				$overlay.on('click', function () {
455					$toggle.click();
456				});
457			});
458		},
459
460		mobMenuDefault: () => {
461			//dl-menu support for css animations and transitions
462			let supportsTransitions = () => {
463				return getSupportedTransition() != '';
464			}
465			let getSupportedTransition = () => {
466				let b = document.body || document.documentElement,
467					s = b.style,
468					p = 'transition';
469
470				if (typeof s[p] == 'string') {
471					return p;
472				}
473
474				// Tests for vendor specific prop
475				let v = ['Moz', 'webkit', 'Webkit', 'Khtml', 'O', 'ms'];
476				p = p.charAt(0).toUpperCase() + p.substr(1);
477
478				for (let i = 0; i < v.length; i++) {
479					if (typeof s[v[i] + p] == 'string') {
480						return true;
481					}
482				}
483
484				return '';
485			}
486			let supportsAnimations = () => {
487				return getSupportedAnimation() != '';
488			}
489			let getSupportedAnimation = () => {
490				let t, el = document.createElement("fakeelement");
491
492				let animations = {
493					"animation": "animationend",
494					"OAnimation": "oAnimationEnd",
495					"MozAnimation": "animationend",
496					"WebkitAnimation": "webkitAnimationEnd",
497					'msAnimation': 'MSAnimationEnd'
498				};
499
500				for (t in animations) {
501					if (el.style[t] !== undefined) {
502						return t;
503					}
504				}
505				return '';
506			}
507			window.supportedTransition = getSupportedTransition();
508			window.supportsTransitions = supportsTransitions();
509			window.supportedAnimation = getSupportedAnimation();
510			window.supportsAnimations = supportsAnimations();
511
512			let $menus = $('.thegem-te-menu-mobile__default');
513			$menus.each(function (i, el) {
514				//dl-menu init
515				let $menuItem = $(el);
516				$menuItem.find('.sub-menu').addClass('dl-submenu');
517
518				$menuItem.dlmenu({
519					animationClasses: {
520						classin: 'dl-animate-in',
521						classout: 'dl-animate-out'
522					},
523					backLabel: thegem_menu_data.backLabel,
524					showCurrentLabel: thegem_menu_data.showCurrentLabel
525				});
526
527				// close menu after click not parent item
528				$('li:not(.menu-item-has-children):not(.dl-back)', $menuItem).on('click', 'a', function (e) {
529					if (typeof $.fn.dlmenu === 'function') {
530						$menuItem.dlmenu('closeMenu');
531					}
532				});
533
534				//dl-menu navmenu/submenu set maxHeight && left position
535				let navMenu = $menuItem.find('ul').not('.menu-item-type-template ul');
536				_helpers.setMobMenuDefaultMaxHeight(navMenu);
537				_helpers.setMobMenuDefaultLeftPosition(el, navMenu);
538
539				//dl-menu resize
540				$(window).on('resize', function (e) {
541					setTimeout(function () {
542						_helpers.setMobMenuDefaultMaxHeight(navMenu);
543						_helpers.setMobMenuDefaultLeftPosition(el, navMenu);
544					}, 1000);
545				});
546			});
547		},
548
549		mobMenuSliding: () => {
550			let $menus = $('.thegem-te-menu-mobile__slide-horizontal, .thegem-te-menu-mobile__slide-vertical');
551			window.isMobMenuSliding = _helpers.isMobMenuSlidingInit($menus);
552
553			$menus.each(function (i, el) {
554				let $menuItem = $(el);
555				let $menuWrap = $('.mobile-menu-slide-wrapper', $menuItem);
556				let $menuClose = $('.mobile-menu-slide-close', $menuItem);
557				let $overlay = $('.mobile-menu-slide-back', $menuItem);
558				let $toggle = $('.dl-trigger', $menuItem);
559
560				$menuItem.on('click', '.dl-trigger', function (e) {
561					e.preventDefault();
562
563					//$header.removeClass('hidden');
564					//$header.toggleClass('menu-slide-opened');
565
566					if ($overlay.hasClass('active')) {
567						$overlay.removeClass('active');
568					} else {
569						$overlay.addClass('active');
570					}
571
572					$menuWrap.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function (e) {
573						$menuWrap.removeClass('animation');
574					});
575					$menuWrap.addClass('animation').toggleClass('opened');
576
577					if ($menuWrap.hasClass('opened')) {
578						_helpers.setBodyLocked(this);
579					} else {
580						_helpers.unsetBodyLocked();
581					}
582				});
583
584				$('li.menu-item-current', $menuItem).each(function () {
585					let $self = $(this);
586					$self.addClass('opened');
587					$('> ul', $self).show();
588				});
589
590				$menuClose.on('click', function () {
591					$toggle.click();
592				});
593
594				$overlay.on('click', function () {
595					$toggle.click();
596				});
597
598				$('.menu-item-parent-toggle', $menuWrap).on('click', function (e) {
599					e.preventDefault();
600
601					if (!window.isMobMenuSliding) return;
602
603					let self = this;
604					$(this).closest('li').toggleClass('opened');
605					$(this).siblings('ul').slideToggle(200, function () {
606						if (!$(self).closest('li').hasClass('opened')) {
607							$(self).siblings('ul').find('li').removeClass('opened');
608							$(self).siblings('ul').css('display', '');
609							$(self).siblings('ul').find('ul').css('display', '');
610						}
611					});
612				});
613
614				$(document).on('click', '.menu-item.mobile-collapsible > a', function(e) {
615					if (!_helpers.isResponsiveMenuVisible($menuItem)) {
616						return;
617					}
618
619					if($(this).next('.menu-item-parent-toggle').length) {
620						e.preventDefault();
621						$(this).next('.menu-item-parent-toggle').trigger('click');
622					}
623				});
624
625				$('.menu-item-parent-toggle', $menuWrap).on('keydown', function(e) {
626					if (e.which === 13) {
627						e.preventDefault();
628						$(this).trigger('click');
629					}
630				});
631
632				// Close overlay menu ESC click
633				$(document).on('keydown', function (event) {
634					if (event.keyCode === 27 && $overlay.hasClass('active')) {
635						$toggle.click();
636					}
637				});
638
639			});
640		},
641
642		onResize: () => {
643			let resizeTimer;
644			$(window).on('resize', function (e) {
645				clearTimeout(resizeTimer);
646
647				resizeTimer = setTimeout(function () {
648					menuScripts.setLayoutView();
649					menuScripts.menuAbsoluteTranslate();
650
651					let $menuSliding = $('.thegem-te-menu-mobile__slide-horizontal, .thegem-te-menu-mobile__slide-vertical');
652					window.isMobMenuSliding = _helpers.isMobMenuSlidingInit($menuSliding);
653				}, 250);
654			});
655		},
656
657		menuMegaMenu: () => {
658			let $megaMenuItems = $('.thegem-te-menu .nav-menu > li.megamenu-enable');
659
660			$megaMenuItems.each(function () {
661				if ($(this).parents('.thegem-te-menu > nav').hasClass("thegem-te-menu__overlay")) {
662					$(this).removeClass('megamenu-enable');
663					return;
664				}
665				menuScripts.fixMegaMenuPosition($(this));
666				let $item = $('> ul', $(this));
667				if ($item.length == 0) return;
668				$item.addClass('megamenu-item-inited');
669
670				$(this).hover(
671					function () {
672						menuScripts.fixMegaMenuPosition($(this));
673					},
674					function () {
675					}
676				);
677			});
678		},
679
680		fixMegaMenuPosition: (elem, containerWidthCallback) => {
681
682			let isMenuVertical = false;
683			let isMenuPerspective = false;
684			let isMenuHamburger = elem.parents('.thegem-te-menu > nav').hasClass("thegem-te-menu__hamburger");
685
686			if (!$('.megamenu-inited', elem).length && _helpers.isResponsiveMenuVisible(elem)) {
687				return false;
688			}
689
690			let $item = $('> ul', elem);
691			if ($item.length == 0) return;
692			let self = $item.get(0);
693
694			$item.addClass('megamenu-item-inited');
695
696			let default_item_css = {
697				width: 'auto',
698				height: 'auto'
699			};
700
701			if (!isMenuVertical && !isMenuHamburger && !isMenuPerspective) {
702				default_item_css.left = 0;
703			}
704
705			$item
706				.removeClass('megamenu-masonry-inited megamenu-fullwidth')
707				.css(default_item_css);
708
709			$(' > li', $item).css({
710				left: 0,
711				top: 0
712			}).each(function () {
713				let old_width = $(this).data('old-width') || -1;
714				if (old_width != -1) {
715					$(this).width(old_width).data('old-width', -1);
716				}
717			});
718
719			if (_helpers.isResponsiveMenuVisible(elem)) {
720				return;
721			}
722
723			let $container = $item.closest('.elementor-widget-wrap, .e-con-inner, .e-con'),
724				container_width,
725				container_padding_left,
726				container_padding_right,
727				parent_width;
728			if (containerWidthCallback !== undefined) {
729				container_width = containerWidthCallback();
730			} else if (isMenuVertical) {
731				container_width = window.gemOptions.clientWidth - $('#site-header-wrapper').outerWidth();
732			} else if (isMenuPerspective) {
733				container_width = window.gemOptions.clientWidth - $('#primary-navigation').outerWidth();
734			} else if (isMenuHamburger) {
735				container_width = window.gemOptions.clientWidth - $('.thegem-te-menu .nav-menu').outerWidth();
736			} else {
737				container_width = $container.width();
738				container_padding_left = parseInt($container.css('padding-left'));
739				container_padding_right = parseInt($container.css('padding-right'));
740				parent_width = $item.parent().outerWidth();
741			}
742
743			let megamenu_width = $item.outerWidth();
744
745			if (megamenu_width > container_width) {
746				megamenu_width = container_width;
747				let new_megamenu_width = container_width - parseInt($item.css('padding-left')) - parseInt($item.css('padding-right')) - parseInt($item.css('border-left')) - parseInt($item.css('border-right'));
748				let columns = $item.data('megamenu-columns') || 4;
749				let margin = 0;
750				$(' > li.menu-item', $item).each(function (index) {
751					if (index < columns) {
752						margin += parseInt($(this).css('margin-left'));
753					}
754				});
755				let column_width = parseFloat(new_megamenu_width - margin) / columns;
756				let column_width_int = parseInt(column_width);
757				$(' > li', $item).each(function () {
758					$(this).data('old-width', $(this).width()).css('width', column_width_int);
759				});
760				let columns_dif = (column_width - column_width_int) * columns;
761				$(' > li.megamenu-first-element', $item).css('width', column_width_int + columns_dif);
762				$item.addClass('megamenu-fullwidth').width(new_megamenu_width);
763			}
764
765			if (!isMenuVertical && !isMenuHamburger && !isMenuPerspective && containerWidthCallback === undefined) {
766				let left = 0;
767				if (megamenu_width > parent_width) {
768					left = -(megamenu_width - parent_width) / 2;
769				}
770
771				let container_offset = _helpers.getOffset($container[0]);
772				let megamenu_offset = _helpers.getOffset(self);
773
774				if ((megamenu_offset.x - container_offset.x - container_padding_left + left) < 0) {
775					left = -(megamenu_offset.x - container_offset.x - container_padding_left);
776				}
777
778				if ((megamenu_offset.x + megamenu_width + left) > (container_offset.x + $container.outerWidth() - container_padding_right)) {
779					left -= (megamenu_offset.x + megamenu_width + left) - (container_offset.x + $container.outerWidth() - container_padding_right);
780				}
781
782				$item.css('left', left).css('left');
783			}
784
785			if ($item.hasClass('megamenu-masonry')) {
786				let positions = {},
787					max_bottom = 0;
788
789				if (!$item.hasClass('megamenu-fullwidth')) {
790					$item.width($item.width() - 1);
791				}
792				let new_row_height = $('.megamenu-new-row', $item).outerHeight() + parseInt($('.megamenu-new-row', $item).css('margin-bottom'));
793
794				$('> li.menu-item', $item).each(function () {
795					let pos = $(this).position(),
796						top_position;
797					if (positions[pos.left] != null && positions[pos.left] != undefined) {
798						top_position = positions[pos.left];
799					} else {
800						top_position = pos.top;
801					}
802					positions[pos.left] = top_position + $(this).outerHeight() + new_row_height + parseInt($(this).css('margin-bottom'));
803					if (positions[pos.left] > max_bottom)
804						max_bottom = positions[pos.left];
805					$(this).css({
806						left: pos.left,
807						top: top_position
808					})
809				});
810
811				$item.height(max_bottom - new_row_height - parseInt($item.css('padding-top')));
812				$item.addClass('megamenu-masonry-inited');
813			}
814
815			if ($item.hasClass('megamenu-empty-right')) {
816				let mega_width = $item.width();
817				let max_rights = {
818					columns: [],
819					position: -1
820				};
821
822				$('> li.menu-item', $item).removeClass('megamenu-no-right-border').each(function () {
823					let pos = $(this).position();
824					let column_right_position = pos.left + $(this).width();
825
826					if (column_right_position > max_rights.position) {
827						max_rights.position = column_right_position;
828						max_rights.columns = [];
829					}
830
831					if (column_right_position == max_rights.position) {
832						max_rights.columns.push($(this));
833					}
834				});
835
836				if (max_rights.columns.length && max_rights.position >= (mega_width - 7)) {
837					max_rights.columns.forEach(function ($li) {
838						$li.addClass('megamenu-no-right-border');
839					});
840				}
841			}
842
843			if (isMenuVertical || isMenuHamburger || isMenuPerspective) {
844				let clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
845					itemOffset = $item.offset(),
846					itemHeight = $item.outerHeight(),
847					scrollTop = $(window).scrollTop();
848
849				if (itemOffset.top - scrollTop + itemHeight > clientHeight) {
850					$item.css({
851						top: clientHeight - itemOffset.top + scrollTop - itemHeight - 20
852					});
853				}
854			}
855
856			$item.addClass('megamenu-inited');
857		},
858
859		menuMegaMenuTemplate: () => {
860			let $megaMenuItems = $('.thegem-te-menu .nav-menu > li.megamenu-template-enable');
861
862			$megaMenuItems.each(function () {
863				if ($(this).parents('.thegem-te-menu > nav').hasClass("thegem-te-menu__overlay")) {
864					$(this).removeClass('megamenu-template-enable');
865					$(this).find('.megamenu-template').remove();
866					return;
867				}
868
869				let $item = $('.megamenu-template', $(this));
870				if ($item.length == 0) return;
871				menuScripts.fixMegaMenuTemplatePosition($(this));
872
873				if ($item.data('template')) {
874					let templateID = $item.data('template');
875					$.ajax({
876						url: thegem_menu_data.ajax_url,
877						data: {
878							'action': 'get_megamenu_template',
879							'id': templateID
880						},
881						dataType: 'json',
882						method: 'POST',
883						success: function (response) {
884							if (response.status === 'success') {
885								$item.html(response.data);
886							}
887						},
888						error: function () {
889							console.log('loading megamenu template ajax error');
890						}
891					});
892				}
893				$item.addClass('megamenu-template-item-inited');
894
895				$(this).hover(
896					function () {
897						menuScripts.fixMegaMenuTemplatePosition($(this));
898					},
899					function () {
900					}
901				);
902			});
903		},
904
905		fixMegaMenuTemplatePosition: (elem, containerWidthCallback) => {
906
907			let isMenuVertical = false;
908			let isMenuPerspective = false;
909			let isMenuHamburger = elem.parents('.thegem-te-menu > nav').hasClass("thegem-te-menu__hamburger");
910
911			if (!$('.megamenu-template-inited', elem).length && _helpers.isResponsiveMenuVisible(elem)) {
912				return false;
913			}
914
915			let $item = $('.megamenu-template', elem);
916			if ($item.length == 0) return;
917			let self = $item.get(0);
918
919			$item.addClass('megamenu-template-item-inited');
920			let isWidth100 = $item.hasClass("template-width-fullwidth");
921
922			let default_item_css = {
923			// 	width: 'auto',
924			// 	height: 'auto'
925			};
926
927			if (!isMenuVertical && !isMenuHamburger && !isMenuPerspective) {
928				default_item_css.left = 0;
929			}
930
931			$item.css(default_item_css);
932
933			if (_helpers.isResponsiveMenuVisible(elem)) {
934				return;
935			}
936
937			let $container = $item.closest('.elementor-widget-wrap, .e-con-inner, .e-con'),
938				container_width,
939				container_padding_left,
940				container_padding_right,
941				parent_width;
942			if (containerWidthCallback !== undefined) {
943				container_width = containerWidthCallback();
944			} else if (isMenuVertical) {
945				container_width = window.gemOptions.clientWidth - $('#site-header-wrapper').outerWidth();
946			} else if (isMenuPerspective) {
947				container_width = window.gemOptions.clientWidth - $('#primary-navigation').outerWidth();
948			} else if (isMenuHamburger) {
949				container_width = window.gemOptions.clientWidth - $('.thegem-te-menu .nav-menu').outerWidth();
950			} else {
951				container_width = $container.width();
952				container_padding_left = parseFloat($container.css('padding-left'));
953				container_padding_right = parseFloat($container.css('padding-right'));
954				parent_width = $item.parent().outerWidth();
955			}
956
957			let megamenu_width = $item.outerWidth();
958
959			if (isWidth100 || megamenu_width > document.body.clientWidth) {
960				$item.css('width', document.body.clientWidth);
961			} else if ($item.hasClass("template-width-boxed") && !isMenuVertical && !isMenuHamburger && !isMenuPerspective) {
962				$item.css('width', container_width);
963			}
964			megamenu_width = $item.outerWidth();
965
966			if (!isMenuVertical && !isMenuHamburger && !isMenuPerspective && containerWidthCallback === undefined) {
967				let left = 0;
968
969				let container_offset = _helpers.getOffset($container[0]);
970				let megamenu_offset = _helpers.getOffset(self);
971
972				if (isWidth100) {
973					left = -megamenu_offset.x;
974				} else {
975					if (megamenu_width > container_width) {
976						left = container_offset.x - megamenu_offset.x - (megamenu_width - container_width)/2;
977					} else if (megamenu_width === container_width) {
978						left = container_offset.x - megamenu_offset.x + container_padding_left;
979					} else {
980
981						if (megamenu_width > parent_width) {
982							left = -(megamenu_width - parent_width) / 2;
983						}
984
985						if ((megamenu_offset.x - container_offset.x - container_padding_left + left) < 0) {
986							left = -(megamenu_offset.x - container_offset.x - container_padding_left);
987						}
988
989						if ((megamenu_offset.x + megamenu_width + left) > (container_offset.x + $container.outerWidth() - container_padding_right)) {
990							left -= (megamenu_offset.x + megamenu_width + left) - (container_offset.x + $container.outerWidth() - container_padding_right);
991						}
992					}
993				}
994
995				$item.css('left', left).css('left');
996			}
997
998			if (isMenuVertical || isMenuHamburger || isMenuPerspective) {
999				if (megamenu_width > container_width) {
1000					$item.css('width', container_width);
1001				}
1002				let clientHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight,
1003					itemOffset = $item.offset(),
1004					itemHeight = $item.outerHeight(),
1005					scrollTop = $(window).scrollTop();
1006
1007				if (itemOffset.top - scrollTop + itemHeight > clientHeight) {
1008					$item.css({
1009						top: clientHeight - itemOffset.top + scrollTop - itemHeight - 20
1010					});
1011				}
1012			}
1013
1014			$item.addClass('megamenu-template-inited');
1015		},
1016
1017		menuAbsoluteTranslate: () => {
1018			$navigate.each(function (i, el){
1019				let $menuWidget = $(this).parents('.elementor-widget');
1020				_helpers.setTranslateValues($menuWidget);
1021			});
1022		},
1023	};
1024
1025	$.fn.initMenuScripts = function () {
1026		menuScripts.init();
1027	};
1028
1029	// Run the function
1030	$(function () {
1031		$().initMenuScripts();
1032	});
1033})(jQuery);

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.