PageSourceSearch

https://www.marset.com/wp-content/themes/marset/js/fly-cart.js?ver=6.2.219

js marset.com collected 2026-10-01 14:40:33 UTC 2,868 bytes, 110 lines download raw bytes

1(function ($) {
2	'use strict';
3
4	$(document).ready(function () {
5
6	var $cart = $('#marset-cart');
7	var $body = $('body');
8
9	function openCart() {
10		$cart.addClass('is-open');
11		$body.addClass('marset-cart-open');
12	}
13
14	function closeCart() {
15		$cart.removeClass('is-open');
16		$body.removeClass('marset-cart-open');
17	}
18
19	function isDesktop() {
20		return $(window).width() > 1200;
21	}
22
23	// Open on cart icon click (skip if already on cart/checkout page)
24	$body.on('click', 'li.carrito > a', function (e) {
25		e.preventDefault();
26		if ($body.hasClass('woocommerce-cart') || $body.hasClass('woocommerce-checkout')) return;
27		if (isDesktop()) {
28			openCart();
29		} else {
30			window.location.href = marset_cart.cart_url;
31		}
32	});
33
34	// Close on X button
35	$body.on('click', '.marset-cart-close', function () {
36		closeCart();
37	});
38
39	// Close on overlay click
40	$body.on('click', '.marset-cart-overlay', function () {
41		closeCart();
42	});
43
44	// Close on ESC key
45	$(document).on('keyup', function (e) {
46		if (e.key === 'Escape') closeCart();
47	});
48
49	// Open on FAB click
50	$body.on('click', '#marset-cart-fab', function () {
51		openCart();
52	});
53
54	function shakeFab() {
55		var $fab = $( '#marset-cart-fab' );
56		$fab.removeClass( 'marset-cart-fab--shake' );
57		// reflow trick to restart animation
58		void $fab[0].offsetWidth;
59		$fab.addClass( 'marset-cart-fab--shake' );
60	}
61
62	// Auto-open + shake after adding product to cart (desktop only)
63	$body.on('added_to_cart', function () {
64		shakeFab();
65		if (isDesktop()) openCart();
66	});
67
68	// Remove item via AJAX
69	$body.on('click', '.marset-cart-item-remove', function (e) {
70		e.preventDefault();
71		var $item = $(this).closest('.marset-cart-item');
72		var cartItemKey = $(this).data('key');
73
74		$item.css('opacity', '0.4');
75
76		$.ajax({
77			url: marset_cart.ajax_url,
78			type: 'POST',
79			data: {
80				action: 'marset_remove_from_cart',
81				cart_item_key: cartItemKey,
82				nonce: marset_cart.nonce,
83			},
84			success: function (response) {
85				$item.remove();
86				if ( response.success && response.data && response.data.fragments ) {
87					var fragments = response.data.fragments;
88					var isEmpty = $( '.marset-cart-mid .marset-cart-item' ).length === 0;
89					if ( isEmpty && fragments['.marset-cart-inner'] ) {
90						$( '.marset-cart-inner' ).replaceWith( fragments['.marset-cart-inner'] );
91					} else if ( fragments['.marset-cart-bot'] ) {
92						$( '.marset-cart-bot' ).replaceWith( fragments['.marset-cart-bot'] );
93					}
94					if ( fragments['span.cart-items-count.count'] ) {
95						$( 'span.cart-items-count.count' ).replaceWith( fragments['span.cart-items-count.count'] );
96					}
97					if ( fragments['.marset-cart-fab-count'] ) {
98						$( '.marset-cart-fab-count' ).replaceWith( fragments['.marset-cart-fab-count'] );
99					}
100				}
101			},
102			error: function () {
103				$item.css('opacity', '1');
104			},
105		});
106	});
107
108	}); // end document.ready
109
110})(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.