PageSourceSearch

https://academiadelaindustria.com/wp-content/plugins/thegem-elemen…/elements/cart/js/cart.js?ver=7.0.6

js academiadelaindustria.com collected 2026-10-04 18:47:02 UTC 4,765 bytes, 184 lines download raw bytes

1(function ($) {
2
3	'use strict';
4
5	const $body = $('body');
6	const $cart = $('.thegem-te-cart');
7	const $cartWidget = $('.thegem-te-cart').parents('.elementor-widget');
8
9	const _helpers = {
10		getScrollY : () => {
11			return window.pageYOffset || document.documentElement.scrollTop;
12		},
13		setBodyLocked: (el) => {
14			$body.data('scroll-position', _helpers.getScrollY());
15			$body.addClass('cart-scroll-locked');
16
17			let isNoStickyItem = $(el).closest("#site-header").length;
18			if (isNoStickyItem){
19				$body.addClass('is-no-sticky');
20			} else {
21				$body.removeClass('is-no-sticky');
22			}
23		},
24		unsetBodyLocked: () => {
25			setTimeout(function (){
26				$body.removeClass('cart-scroll-locked is-no-sticky');
27			}, 1000);
28
29			if ($body.data('scroll-position')) {
30				window.scrollTo(0, $body.data('scroll-position'))
31			}
32		},
33		isMobileCart: () => {
34			let result = false;
35			if ($cart.hasClass('mobile-view')) {
36				result = true;
37			}
38
39			return result;
40		},
41		setTranslateValues: (elem) => {
42			if (!elem.length) return;
43			elem.css('transform', '').css('margin-left', '').css('margin-top', '');
44			const style = window.getComputedStyle(elem[0]);
45			const matrix = style['transform'] || style.webkitTransform || style.mozTransform;
46			let x = 0, y = 0;
47
48			// No transform property. Simply return 0 values.
49			if (matrix === 'none' || typeof matrix === 'undefined') {
50				return;
51			}
52
53			// Can either be 2d or 3d transform
54			const matrixType = matrix.includes('3d') ? '3d' : '2d';
55			const matrixValues = matrix.match(/matrix.*\((.+)\)/)[1].split(', ');
56
57			// 2d matrices have 6 values
58			// Last 2 values are X and Y.
59			// 2d matrices does not have Z value.
60			if (matrixType === '2d') {
61				x = matrixValues[4];
62				y = matrixValues[5];
63			}
64
65			// 3d matrices have 16 values
66			// The 13th, 14th, and 15th values are X, Y, and Z
67			if (matrixType === '3d') {
68				x = matrixValues[12];
69				y = matrixValues[13];
70			}
71
72			elem.css('transform', 'none').css('margin-left', x + 'px').css('margin-top', y + 'px');
73		}
74	};
75
76	const cartScripts = {
77		init: () => {
78			cartScripts.setLayoutView();
79			cartScripts.invert();
80			cartScripts.mobileCart();
81			cartScripts.onResize();
82
83			_helpers.setTranslateValues($cartWidget);
84
85			$(window).on('resize', function (e) {
86				setTimeout(function () {
87					_helpers.setTranslateValues($cartWidget);
88				}, 250);
89			});
90		},
91
92		setLayoutView: () => {
93			let viewportWidth = $(window).width();
94
95			$cart.each(function (i, el) {
96				if (viewportWidth < 992) {
97					$(this).removeClass('desktop-view').addClass('mobile-view');
98				} else {
99					$(this).removeClass('mobile-view').addClass('desktop-view');
100				}
101			});
102		},
103
104		invert: () => {
105			let $items = $('.minicart', $cart);
106			$items.removeClass('invert');
107
108			$items.each(function(i, el) {
109				let clientRect = el.getBoundingClientRect();
110				let itemWidth = $(el).width();
111				let itemLeftPosition = clientRect.x + pageXOffset;
112
113				if ($(window).width() - itemLeftPosition > itemWidth) {
114					$(el).removeClass('invert');
115				} else {
116					$(el).addClass('invert');
117				}
118			});
119		},
120
121		mobileCart: () => {
122			window.isMobileCart = _helpers.isMobileCart();
123
124			$cart.each(function (i, el) {
125				let $item = $(el);
126				let $minicart = $('.minicart', $item);
127				let $overlay = $('.mobile-minicart-overlay', $item);
128
129				$item.off('click touchend', '.menu-item-cart > a')
130				if (!window.isMobileCart) return;
131
132				$item.on('click touchend', '.menu-item-cart > a', function(e) {
133					e.preventDefault();
134
135					_helpers.setBodyLocked(this);
136					$overlay.addClass('active');
137					$minicart.addClass('active');
138				});
139
140				$(document).on('click touchend', '.mobile-cart-header-close, .mobile-minicart-overlay, .thegem-popup-notification-sidebar .close', function(e) {
141					e.preventDefault();
142
143					_helpers.unsetBodyLocked();
144					$overlay.removeClass('active');
145					$minicart.removeClass('active');
146				});
147
148				$(document).on('click touchend', '.thegem-popup-notification-sidebar', function(e) {
149					const wrap = $('.thegem-popup-notification-sidebar .notification-sidebar');
150					if (!wrap.is(e.target) && wrap.has(e.target).length === 0) {
151						_helpers.unsetBodyLocked();
152						$overlay.removeClass('active');
153						$minicart.removeClass('active');
154					}
155				});
156
157			});
158		},
159
160		onResize: () => {
161			let resizeTimer;
162			$(window).on('resize', function(e) {
163				clearTimeout(resizeTimer);
164
165				resizeTimer = setTimeout(function() {
166					cartScripts.setLayoutView();
167					cartScripts.invert();
168					cartScripts.mobileCart();
169				}, 250);
170			});
171		},
172	}
173
174	$.fn.initCartScripts = function () {
175		cartScripts.init();
176	};
177
178	// Run the function
179	$(function () {
180		if (!$('body').hasClass('elementor-editor-active')) {
181			$().initCartScripts();
182		}
183	});
184})(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.