<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">/* global jQuery:false */
/* global AMULI_STORAGE:false */

(function() {
	"use strict";

	jQuery( document ).on(

		'action.ready_amuli', function() {


			// Change display mode
			//--------------------------------
			jQuery( '.woocommerce,.woocommerce-page' ).on(
				'click', '.amuli_shop_mode_buttons a', function(e) {
					var mode = jQuery( this ).hasClass( 'woocommerce_thumbs' ) ? 'thumbs' : 'list';
					amuli_set_cookie( 'amuli_shop_mode', mode, 365 * 24 * 60 * 60 * 1000 );   // 1 year
					jQuery( this ).siblings( 'input' ).val( mode ).parents( 'form' ).get( 0 ).submit();
					e.preventDefault();
					return false;
				}
			);


			// Add buttons to quantity
			//--------------------------------

			// On first run
			if (jQuery( '.woocommerce div.quantity .q_inc,.woocommerce-page div.quantity .q_inc' ).length === 0) {
				var woocomerce_inc_dec = '&lt;span class="q_inc"&gt;&lt;/span&gt;&lt;span class="q_dec"&gt;&lt;/span&gt;';
				jQuery( '.woocommerce div.quantity,.woocommerce-page div.quantity' ).append( woocomerce_inc_dec );
				jQuery( '.woocommerce div.quantity,.woocommerce-page div.quantity' ).on(
					'click', '&gt;span', function(e) {
						amuli_woocomerce_inc_dec_click( jQuery( this ) );
						e.preventDefault();
						return false;
					}
				);
			}
			// After the cart is updated
			jQuery( document.body ).on(
				'updated_wc_div', function() {
					if (jQuery( '.woocommerce div.quantity .q_inc,.woocommerce-page div.quantity .q_inc' ).length === 0) {
						jQuery( '.woocommerce div.quantity,.woocommerce-page div.quantity' ).append( woocomerce_inc_dec );
						jQuery( '.woocommerce div.quantity,.woocommerce-page div.quantity' ).on(
							'click', '&gt;span', function(e) {
								amuli_woocomerce_inc_dec_click( jQuery( this ) );
								e.preventDefault();
								return false;
							}
						);
					}
				}
			);

			// Inc/Dec quantity on buttons inc/dec
			function amuli_woocomerce_inc_dec_click(button) {
				var f = button.siblings( 'input' );
				if (button.hasClass( 'q_inc' )) {
					f.val( ( f.val() == '' ? 0 : parseInt( f.val(), 10 ) ) + 1 ).trigger( 'change' );
				} else {
					f.val( Math.max( 0, ( f.val() == '' ? 0 : parseInt( f.val(), 10 ) ) - 1 ) ).trigger( 'change' );
				}
			}


			// Decorate YITH Compare &amp; Add to wishlist
			//----------------------------------------------

			// Move 'Compare' before 'Wishlist' and convert 'Wishlist' to the button (if 'Compare' is a button)
			var wishlist = jQuery( '.woocommerce .product .summary .yith-wcwl-add-to-wishlist' ).eq( 0 );
			if (wishlist.length &gt; 0) {
				var compare = jQuery( '.woocommerce .product .summary .compare' ).eq( 0 );
				if ( compare.length &gt; 0 ) {
					compare.insertBefore( wishlist );
					if ( compare.hasClass( 'button' ) ) {
						wishlist.find( '.add_to_wishlist' ).addClass( 'button' );
					}
				}
			}

			// Remove class 'button' from links 'Compare' and 'Add to Wishlist' in the 'Related products' on the single product page
			jQuery( '.single-product ul.products li.product .post_data .yith_buttons_wrap a' ).removeClass( 'button' );

			// Wrap inner text in the links 'Compare' and 'Add to Wishlist' to the span
			jQuery( 'ul.products li.product .post_data .yith_buttons_wrap a' ).wrapInner( '&lt;span class="tooltip"&gt;&lt;/span&gt;' );

			// Wrap inner text in the link 'Compare' after click
			jQuery( 'ul.products li.product .post_data .yith_buttons_wrap .compare' ).on('click', function(e) {
				var bt = jQuery(this), atts = 10;
				setTimeout(trx_addons_add_tooltip_to_compare, 500);
				function trx_addons_add_tooltip_to_compare() {
					if (bt.hasClass('added') &amp;&amp; bt.find('.tooltip').length === 0) {
						bt.wrapInner( '&lt;span class="tooltip"&gt;&lt;/span&gt;' );
					} else if (atts-- &gt; 0) {
						setTimeout(trx_addons_add_tooltip_to_compare, 500);
					}
				}
			});
			// Wrap inner text in the link 'Add to Wishlist' after click
			jQuery( 'ul.products li.product.add-to-wishlist-before_image .post_data .yith_buttons_wrap .add_to_wishlist' ).on('click', function(e) {
				var atts = 30,
					wrap = jQuery(this).parents('.yith_buttons_wrap');
				setTimeout(trx_addons_add_tooltip_to_wishlist, 250);
				function trx_addons_add_tooltip_to_wishlist() {
					var bt = wrap.find('.yith-wcwl-add-to-wishlist a');
					if (bt.find('.tooltip').length === 0) {
						bt.wrapInner( '&lt;span class="tooltip"&gt;&lt;/span&gt;' );
					} else if (atts-- &gt; 0) {
						setTimeout(trx_addons_add_tooltip_to_wishlist, 250);
					}
				}
			});
			// Change spinner image in the 'Add to Wishlist'
			var img = jQuery( 'ul.products li.product .yith_buttons_wrap .yith-wcwl-add-button &gt; img' );
			if ( img.length &gt; 0 ) {
				img.each( function() {
					var src = jQuery(this).attr('src');
					if ( src != undefined &amp;&amp; src.indexOf('wpspin_light') &gt; 0) {
						jQuery(this).attr('src', src.replace('wpspin_light', 'ajax-loader'));
					}
				});
			}


			// Wrap new select (created dynamically) with .select_container
			//-------------------------------------------------------------------------
			jQuery( 'select#calc_shipping_country:not(.inited)' ).addClass( 'inited' ).on(
				'change', function() {
					setTimeout(
						function() {
							var state = jQuery( 'select#calc_shipping_state' );
							if (state.length == 1 &amp;&amp; ! state.parent().hasClass( 'select_container' )) {
								state.wrap( '&lt;div class="select_container"&gt;&lt;/div&gt;' );
							}
						}, 10
					);
				}
			);
			jQuery( document.body ).on(
				'wc_fragments_refreshed updated_shipping_method update_checkout', function() {
					jQuery( 'div.cart_totals select' ).each(
						function() {
							if ( ! jQuery( this ).parent().hasClass( 'select_container' )) {
								jQuery( this ).wrap( '&lt;div class="select_container"&gt;&lt;/div&gt;' );
							}
						}
					);
				}
			);


			// Add hover classes to the buttons created dynamically
			//-------------------------------------------------------------------------
			jQuery( document.body ).on(
				'wc_fragments_refreshed update_checkout update_cart', function() {
					jQuery( document ).trigger( 'action.init_hidden_elements', [ jQuery('.woocommerce') ] );
				}
			);


			// Add stretch behaviour to WooC tabs area
			//-------------------------------------------------------------------------
			jQuery( document ).on(
				'action.prepare_stretch_width', function() {
					if ( jQuery( 'body' ).hasClass( 'single_product_layout_stretched' ) &amp;&amp; jQuery( 'body' ).hasClass( 'sidebar_hide' ) ) {
						jQuery( '.single-product .woocommerce-tabs' ).wrap( '&lt;div class="trx-stretch-width"&gt;&lt;/div&gt;' );
					}
				}
			);


			// Update cart
			//-------------------------------------------------------------------------
			jQuery( document.body ).on(
				'updated_wc_div', function() {
					"use strict";
					if (jQuery( 'table.cart' ).length &gt; 0) {
						amuli_woocommerce_update_cart( 'update' );
					}
				}
			);

			// Generate 'scroll' event after the cart is filled
			jQuery( document.body ).on(
				'wc_fragment_refresh', function() {
					jQuery( window ).trigger( 'scroll' );
				}
			);

			// Check device and update cart if need
			if (jQuery( 'table.cart' ).length &gt; 0) {
				amuli_woocommerce_update_cart( 'init' );
			}

			// Resize action
			jQuery( window ).resize(
				function() {
					"use strict";
					if (jQuery( 'table.cart' ).length &gt; 0) {
						amuli_woocommerce_update_cart( 'resize' );
					}
				}
			);

			// Update cart display
			function amuli_woocommerce_update_cart(status){
				"use strict";
				setTimeout(
					function() {
						var w = window.innerWidth;
						if (w == undefined) {
							w = jQuery( window ).width() + (jQuery( window ).height() &lt; jQuery( document ).height() || jQuery( window ).scrollTop() &gt; 0 ? 16 : 0);
						}

						if (AMULI_STORAGE['mobile_layout_width'] &gt;= w) {
							if (status == 'resize' &amp;&amp; jQuery( 'table.cart .mobile_cell' ).length &gt; 0) {
								return false;
							} else {
								var tbl = jQuery( 'table.cart' );
								if ( tbl.length &gt; 0 ) {
									tbl.find( 'thead tr .product-quantity, thead tr .product-subtotal, thead tr .product-thumbnail' ).hide();
									if ( tbl.hasClass( 'wishlist_table' ) ) {
										tbl.find( 'thead tr .product-remove, thead tr .product-stock-status' ).hide();
										tbl.find( 'tfoot tr td' ).each(function() {
											jQuery( this ).data( 'colspan', jQuery( this ).attr( 'colspan' ) ).attr( 'colspan', 3 );
										});
									}
									tbl.find( '.cart_item,[id*="yith-wcwl-row-"]' ).each(
										function(){
											jQuery( this ).prepend( '&lt;td class="mobile_cell" colspan="3"&gt;&lt;table width="100%"&gt;&lt;tr class="first_row"&gt;&lt;/tr&gt;&lt;tr class="second_row"&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;' );
											jQuery( this ).find( '.first_row' ).append( jQuery( this ).find( '.product-thumbnail, .product-name, .product-price' ) );
											jQuery( this ).find( '.second_row' ).append( jQuery( this ).find( '.product-remove, .product-quantity, .product-subtotal, .product-stock-status, .product-add-to-cart' ) );
										}
									);
									if ( ! tbl.hasClass( 'inited' )) {
										tbl.addClass( 'inited' );
									}
								}
							}
						}

						if (AMULI_STORAGE['mobile_layout_width'] &lt; w &amp;&amp; status == 'resize' &amp;&amp; jQuery( 'table.cart .mobile_cell' ).length &gt; 0) {
							var tbl = jQuery( 'table.cart' );
							if ( tbl.length &gt; 0 ) {
								tbl.find( 'thead tr .product-quantity, thead tr .product-subtotal, thead tr .product-thumbnail' ).show();
								if ( tbl.hasClass( 'wishlist_table' ) ) {
									tbl.find( 'thead tr .product-remove, thead tr .product-stock-status' ).show();
									tbl.find( 'tfoot tr td' ).each(function() {
										jQuery( this ).attr( 'colspan', jQuery( this ).data( 'colspan' ) );
									});
								}
								tbl.find( '.cart_item,[id*="yith-wcwl-row-"]' ).each(
									function(){
										jQuery( this ).find( '.first_row td, .second_row td' ).prependTo( jQuery( this ) );
										jQuery( this ).find( '.product-remove' ).prependTo( jQuery( this ) );
										jQuery( this ).find( 'td.mobile_cell' ).remove();
									}
								);
							}
						}

					}, 10
				);
			}

			// 'Load more' and 'Infinite scroll' on the products page
			jQuery( '.woocommerce-load-more' ).on(
				'click', function(e) {
					if (AMULI_STORAGE['load_more_link_busy']) {
						return;
					}
					AMULI_STORAGE['load_more_link_busy'] = true;
					var more                               = jQuery( this );
					var page                               = Number( more.data( 'page' ) );
					var max_page                           = Number( more.data( 'max-page' ) );
					if (page &gt;= max_page) {
						more.parent().hide();
						return;
					}
					more.parent().addClass( 'loading' );

					var link     = more.parent().next( '.woocommerce-pagination' ).find( '.next' ).attr( 'href' ).replace( /\/page\/[0-9]+/, '/page/' + ( page + 1 ) );
					var products = more.parent().prev( '.products' );

					jQuery.get(	link ).done(
						function(response) {
							// Get new posts and append to the .products
							var posts_container = jQuery( response ).find('.list_products &gt; .products');
							if ( posts_container.length == 0 ) {
								posts_container = jQuery( response ).find('ul.products');
							}
							if ( posts_container.length &gt; 0 ) {
								products.append( posts_container.find( '&gt; li' ) );
								more.data( 'page', page + 1 ).parent().removeClass( 'loading' );
								// Trigger actions to init new elements
								AMULI_STORAGE['init_all_mediaelements'] = true;
								jQuery( document ).trigger( 'action.init_hidden_elements', [products] );
							}
							if (page + 1 &gt;= max_page) {
								more.parent().hide();
							} else {
								AMULI_STORAGE['load_more_link_busy'] = false;
							}
							// Fire 'window.scroll' after clearing busy state
							jQuery( window ).trigger( 'scroll' );

							jQuery(document).trigger('action.got_ajax_response', {
								action: 'woocommerce_ajax_get_posts',
								result: response,
								products: products
							});
						}
					);
					e.preventDefault();
					return false;					
				}
			);

			// Infinite scroll on the products page
			jQuery( document ).on(
				'action.scroll_amuli', function(e) {
					if (AMULI_STORAGE['load_more_link_busy']) {
						return;
					}
					var inf = jQuery( '.woocommerce-links-infinite' );
					if (inf.length == 0) {
						return;
					}
					var container = jQuery( '.list_products &gt; .products' ).eq( 0 );
					if (container.offset().top + container.height() &lt; jQuery( window ).scrollTop() + jQuery( window ).height() * 1.5) {
						inf.find( 'a' ).trigger( 'click' );
					}
				}
			);
		}
	);
})();
</pre></body></html>