PageSourceSearch

https://electriccityroasting.com/wp-content/themes/porto/js/woocommerce-theme.js?ver=7.7.0

js electriccityroasting.com collected 2026-09-26 12:10:51 UTC 109,337 bytes, 2,904 lines download raw bytes

1( function() {
2	'use strict';
3	// Compatibility with YITH WISHLIST PRO
4	if ( typeof yith_wcwl_l10n != 'undefined' ) {
5		yith_wcwl_l10n.enable_tooltip = false;
6	}
7	// Hide Tooltip before adding to wishlist
8	jQuery( document ).on( 'yith_wcwl_add_to_wishlist_data yith_woocompare_product_added', function( e, $el ) {
9		if ( $el.length ) {
10			$el.tooltip( 'dispose' );
11		}
12		if ( $el.$initiator ) {
13			$el.$initiator.tooltip( 'dispose' );
14		}
15	} );
16	jQuery( document ).on( 'click', 'a.compare.added', function( e ) {
17		jQuery( this ).tooltip( 'dispose' );
18	});
19	// Theme Functions
20	function portoCalcSliderButtonsPosition( $parent, padding ) {
21		var $buttons = $parent.find( '.show-nav-title .owl-nav' );
22		if ( $buttons.length ) {
23			if ( window.theme.rtl ) {
24				$buttons.css( 'left', padding );
25			} else {
26				$buttons.css( 'right', padding );
27			}
28			if ( $buttons.closest( '.porto-products' ).length && $buttons.closest( '.porto-products' ).parent().children( '.products-slider-title' ).length ) {
29				var $title = $buttons.closest( '.porto-products' ).parent().children( '.products-slider-title' ), newMT = $title.offset().top - $parent.offset().top - parseInt( $title.css( 'padding-top' ), 10 ) - parseInt( $title.css( 'line-height' ), 10 ) / 2 + $buttons.children().outerHeight() - parseInt( $buttons.children().css( 'margin-top' ), 10 );
30				$buttons.css( 'margin-top', newMT );
31			}
32		}
33	}
34
35	// Woocommerce Products Slider
36	if ( typeof jQuery.fn.owlCarousel == 'function' ) {
37		( function( theme, $ ) {
38
39			theme = theme || {};
40
41			var instanceName = '__wooProductsSlider';
42
43			var WooProductsSlider = function( $el, opts ) {
44				return this.initialize( $el, opts );
45			};
46
47			WooProductsSlider.defaults = {
48				rtl: theme.rtl,
49				autoplay: theme.slider_autoplay == '1' ? true : false,
50				autoplayTimeout: theme.slider_speed ? theme.slider_speed : 5000,
51				loop: theme.slider_loop,
52				nav: false,
53				navText: ["", ""],
54				dots: false,
55				autoplayHoverPause: true,
56				items: 1,
57				responsive: {},
58				autoHeight: true,
59				lazyLoad: true
60			};
61
62			WooProductsSlider.prototype = {
63				initialize: function( $el, opts ) {
64					if ( $el.data( instanceName ) ) {
65						return this;
66					}
67
68					this.$el = $el;
69
70					this
71						.setData()
72						.setOptions( opts )
73						.build();
74
75					return this;
76				},
77
78				setData: function() {
79					this.$el.data( instanceName, true );
80
81					return this;
82				},
83
84				setOptions: function( opts ) {
85					this.options = $.extend( true, {}, WooProductsSlider.defaults, opts, {
86						wrapper: this.$el
87					} );
88
89					return this;
90				},
91
92				calcOwlHeight: function( $el ) {
93					var h = 0;
94					$el.find( '.owl-item.active' ).each( function() {
95						if ( h < $( this ).height() )
96							h = $( this ).height();
97					} );
98					$el.find( '.owl-stage-outer' ).height( h );
99				},
100
101				build: function() {
102					var self = this,
103						$el = this.options.wrapper,
104						lg = this.options.lg,
105						md = this.options.md,
106						xs = this.options.xs,
107						ls = this.options.ls,
108						$slider_wrapper = $el.closest( '.slider-wrapper' ),
109						single = this.options.single,
110						dots = this.options.dots,
111						nav = this.options.nav,
112						responsive = {},
113						items,
114						// scrollwidth = 0 not using getscrollbarwidth
115						scrollWidth = 0,
116						count = $el.find( '> *' ).length,
117						w_xs = 576 - scrollWidth,
118						w_md = 768 - scrollWidth,
119						w_xl = theme.screen_xl - scrollWidth,
120						w_sl = theme.screen_xxl - scrollWidth;
121
122					if ( $el.find( '.product-col' ).get( 0 ) ) {
123						portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) );
124					}
125
126					if ( single ) {
127						items = 1;
128					} else {
129						items = lg ? lg : 1;
130						if ( this.options.xl ) {
131							responsive[w_sl] = { items: this.options.xl, loop: ( this.options.loop && count > this.options.xl ) ? true : false };
132						}
133						responsive[w_xl] = { items: items, loop: ( this.options.loop && count > items ) ? true : false };
134						if ( md ) responsive[w_md] = { items: md, loop: ( this.options.loop && count > md ) ? true : false };
135						if ( xs ) responsive[w_xs] = { items: xs, loop: ( this.options.loop && count > xs ) ? true : false };
136						if ( ls ) responsive[0] = { items: ls, loop: ( this.options.loop && count > ls ) ? true : false };
137					}
138
139					this.options = $.extend( true, {}, this.options, {
140						loop: ( this.options.loop && count > items ) ? true : false,
141						items: items,
142						responsive: responsive,
143						onRefresh: function() {
144							if ( $el.find( '.product-col' ).get( 0 ) ) {
145								portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) );
146							}
147						},
148						onInitialized: function() {
149							if ( $el.find( '.product-col' ).get( 0 ) ) {
150								portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) );
151							}
152							//$el.find('.cloned .porto-lazyload:not(.lazy-load-loaded)').themePluginLazyLoad();
153
154							if ( $el.find( '.owl-item.cloned' ).length ) {
155								setTimeout( function() {
156									if ( $.fn.themePluginLazyLoad ) {
157										var ins = $el.find( '.owl-item.cloned .porto-lazyload:not(.lazy-load-loaded)' ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } );
158										if ( ins && ins.loadAndDestroy ) {
159											ins.loadAndDestroy();
160										}
161									}
162								}, 100 );
163							}
164						},
165						touchDrag: ( count == 1 ) ? false : true,
166						mouseDrag: ( count == 1 ) ? false : true
167					} );
168
169					// Auto Height Fixes
170					if ( this.options.autoHeight ) {
171						var thisobj = this;
172						$( window ).on( 'resize', function() {
173							thisobj.calcOwlHeight( $el );
174						} );
175
176						if ( theme.isLoaded ) {
177							setTimeout( function() {
178								thisobj.calcOwlHeight( $el );
179							}, 100 );
180						} else {
181							$( window ).on( 'load', function() {
182								thisobj.calcOwlHeight( $el );
183							} );
184						}
185					}
186
187					if ( $el.hasClass( 'has-ccols-spacing' ) ) {
188						$el.removeClass( 'has-ccols-spacing' );
189					}
190					$el.owlCarousel( this.options );
191
192					return this;
193				}
194			};
195
196			// expose to scope
197			$.extend( theme, {
198				WooProductsSlider: WooProductsSlider
199			} );
200
201			// jquery plugin
202			$.fn.themeWooProductsSlider = function( opts ) {
203				return this.map( function() {
204					var $this = $( this );
205
206					if ( $this.data( instanceName ) ) {
207						return $this;
208					} else {
209						return new theme.WooProductsSlider( $this, opts );
210					}
211
212				} );
213			}
214
215		} ).apply( this, [window.theme, jQuery] );
216	}
217
218	// Woocommerce Add to Cart, View Cart Events
219	( function( theme, $ ) {
220
221		var $supports_html5_storage;
222		try {
223			$supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null );
224
225			window.sessionStorage.setItem( 'wc', 'test' );
226			window.sessionStorage.removeItem( 'wc' );
227		} catch ( err ) {
228			$supports_html5_storage = false;
229		}
230
231		var setCartCreationTimestamp = function() {
232			if ( $supports_html5_storage ) {
233				sessionStorage.setItem( 'wc_cart_created', ( new Date() ).getTime() );
234			}
235		};
236
237		var setCartHash = function( cart_hash ) {
238			if ( $supports_html5_storage && wc_cart_fragments_params ) {
239				localStorage.setItem( wc_cart_fragments_params.cart_hash_key, cart_hash );
240				sessionStorage.setItem( wc_cart_fragments_params.cart_hash_key, cart_hash );
241			}
242		};
243
244		var initAjaxRemoveCartItem = function() {
245			$( document ).off( 'click', '.widget_shopping_cart .remove-product, .shop_table.cart .remove-product, .shop_table.review-order .remove-product' ).on( 'click', '.widget_shopping_cart .remove-product, .shop_table.cart .remove-product, .shop_table.review-order .remove-product', function( e ) {
246				e.preventDefault();
247				var $this = $( this );
248				var cart_id = $this.data( "cart_id" );
249				var product_id = $this.data( "product_id" );
250				var is_checkout = false;
251				$this.closest( 'li' ).find( '.ajax-loading' ).show();
252
253				if ( 'undefined' == typeof cart_id ) {
254					is_checkout = true;
255					cart_id = $this.closest( '.cart_item' ).data( 'key' );
256				}
257				$.ajax( {
258					type: 'POST',
259					dataType: 'json',
260					url: theme.ajax_url,
261					data: {
262						action: "porto_cart_item_remove",
263						nonce: js_porto_vars.porto_nonce,
264						cart_id: cart_id
265					},
266					success: function( response ) {
267						updateCartFragment( response );
268						$( document.body ).trigger( 'wc_fragments_refreshed' );
269						var this_page = window.location.toString(),
270							item_count = $( response.fragments['div.widget_shopping_cart_content'] ).find( '.mini_cart_item' ).length;
271
272						this_page = this_page.replace( 'add-to-cart', 'added-to-cart' );
273						$( '.viewcart-' + product_id ).removeClass( 'added' );
274						$( '.porto_cart_item_' + cart_id ).remove();
275
276						// Block widgets and fragments
277						if ( item_count == 0 && ( $( 'body' ).hasClass( 'woocommerce-cart' ) || $( 'body' ).hasClass( 'woocommerce-checkout' ) ) ) {
278							$( '.page-content' ).fadeTo( 400, 0.8 ).block( {
279								message: null,
280								overlayCSS: {
281									opacity: 0.2
282								}
283							} );
284						} else {
285							$( 'form.woocommerce-cart-form, #order_review, .updating, .cart_totals' ).fadeTo( 400, 0.8 ).block( {
286								message: null,
287								overlayCSS: {
288									opacity: 0.2
289								}
290							} );
291						}
292
293						// Unblock
294						$( '.widget_shopping_cart, .updating' ).stop( true ).css( 'opacity', '1' ).unblock();
295
296						// Cart page elements
297						if ( item_count == 0 && ( $( 'body' ).hasClass( 'woocommerce-cart' ) || $( 'body' ).hasClass( 'woocommerce-checkout' ) ) ) {
298							$( '.page-content' ).load( this_page + ' .page-content:eq(0) > *', function() {
299								$( '.page-content' ).stop( true ).css( 'opacity', '1' ).unblock();
300							} );
301						} else {
302							$( 'form.woocommerce-cart-form' ).load( this_page + ' form.woocommerce-cart-form:eq(0) > *', function() {
303								$( 'form.woocommerce-cart-form' ).stop( true ).css( 'opacity', '1' ).unblock();
304							} );
305
306							$( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function() {
307								$( '.cart_totals' ).stop( true ).css( 'opacity', '1' ).unblock();
308							} );
309
310							// Checkout page elements
311							$( '#order_review' ).load( this_page + ' #order_review:eq(0) > *', function() {
312								$( '#order_review' ).stop( true ).css( 'opacity', '1' ).unblock();
313							} );
314						}
315					}
316				} );
317
318				return false;
319			} );
320		};
321
322		var refreshCartFragment = function() {
323			initAjaxRemoveCartItem();
324			if ( $.cookie( 'woocommerce_items_in_cart' ) > 0 ) {
325				$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show();
326			} else {
327				$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide();
328			}
329		};
330
331		var updateCartFragment = function( data ) {
332			if ( data && data.fragments ) {
333				var fragments = data.fragments,
334					cart_hash = data.cart_hash;
335
336				$.each( fragments, function( key, value ) {
337					$( key ).replaceWith( value );
338				} );
339				if ( typeof wc_cart_fragments_params === 'undefined' ) {
340					return;
341				}
342				/* Storage Handling */
343				if ( $supports_html5_storage ) {
344					var prev_cart_hash = sessionStorage.getItem( 'wc_cart_hash' );
345
346					if ( prev_cart_hash === null || prev_cart_hash === undefined || prev_cart_hash === '' ) {
347						setCartCreationTimestamp();
348					}
349					sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( fragments ) );
350					setCartHash( cart_hash );
351				}
352			}
353		};
354
355		$( function() {
356
357			refreshCartFragment();
358
359			// add ajax cart loading
360			$( document ).on( 'click', '.add_to_cart_button', function( e ) {
361				var $this = $( this );
362				if ( typeof theme.noAjaxCart == 'undefined' ) {
363					theme.noAjaxCart = ! $( '#wc-add-to-cart-js' ).length;
364				}
365				if ( $this.is( '.product_type_simple' ) ) {
366					if ( 'SPAN' == $this.prop( 'tagName' ) && ( theme.noAjaxCart || ! $this.attr( 'data-product_id' ) ) ) {
367						window.location.href = $this.attr( 'href' );
368					}
369					if ( $this.attr( 'data-product_id' ) ) {
370						$this.addClass( 'product-adding' );
371					}
372					// add to cart notifaction style 2, 3
373					if ( $.fn.tooltip ) {
374						$this.tooltip( 'hide' );
375					}
376					if ( $this.hasClass( 'viewcart-style-2' ) || $this.hasClass( 'viewcart-style-3' ) ) {
377						if ( $this.closest( '.porto-hotspot' ).length == 0 && $this.closest( '.menu-block' ).length == 0 ) {
378							$( 'body' ).append( '<div id="loading-mask"><div class="background-overlay"></div></div>' );
379						}
380						if ( !$( this ).closest( '.product' ).find( '.loader-container' ).length ) {
381							$( this ).closest( '.product' ).find( '.product-image' ).append( '<div class="loader-container"><div class="loader"><i class="porto-ajax-loader"></i></div></div>' );
382						}
383						$( this ).closest( '.product' ).find( '.loader-container' ).show();
384					}
385				} else if ( 'SPAN' == $this.prop( 'tagName' ) ) {
386					window.location.href = $this.attr( 'href' );
387				}
388			} );
389
390			$( document.body ).on( 'added_to_cart', function() {
391				$( 'ul.products li.product .added_to_cart, .porto-tb-item .added_to_cart' ).remove();
392				initAjaxRemoveCartItem();
393			} );
394
395			$( document.body ).on( 'wc_cart_button_updated', function() {
396				$( 'ul.products li.product .added_to_cart, .porto-tb-item .added_to_cart' ).remove();
397			} );
398
399			$( document.body ).on( 'wc_fragments_refreshed wc_fragments_loaded', function() {
400				refreshCartFragment();
401			} );
402
403			$( document ).on( 'click', '.product-image .viewcart, .after-loading-success-message .viewcart', function( e ) {
404				if ( wc_add_to_cart_params.cart_url ) {
405					window.location.href = wc_add_to_cart_params.cart_url;
406				}
407				e.preventDefault();
408			} );
409			var porto_product_add_cart_timer = null;
410			$( document ).on( 'added_to_cart', 'body', function( event ) {
411				var $mc_item = $( '#mini-cart .cart-items' );
412				if ( $mc_item.length ) {
413					$mc_item.addClass( 'count-updating' );
414					setTimeout( function() {
415						$mc_item.removeClass( 'count-updating' );
416					}, 1000 );
417				}
418
419				//add to cart notifaction style 2,3
420				$( 'body #loading-mask' ).remove();
421
422				$( '.add_to_cart_button.product-adding' ).each( function() {
423					var $link = $( this );
424					$link.removeClass( 'product-adding' );
425					if ( $( '.woocommerce-wishlist.woocommerce-page' ).length ) { //wishlist page
426						return;
427					}
428					if ( $link.hasClass( 'viewcart-style-1' ) ) {
429						$link.closest( '.product' ).find( '.viewcart' ).addClass( 'added' );
430						$( '.minicart-offcanvas' ).addClass( 'minicart-opened' );
431					} else {
432						$link.closest( '.product' ).find( '.loader-container' ).hide();
433						if ( $link.closest( 'li.outofstock' ).length ) {
434							return;
435						}
436						var $msg;
437						if ( $link.hasClass( 'viewcart-style-2' ) ) {
438							$msg = $( '.after-loading-success-message .success-message-container' ).eq( 0 );
439							$msg.find( '.product-name' ).text( $link.closest( '.product' ).find( '.woocommerce-loop-product__title, .product-loop-title, .post-title a' ).text() );
440						} else {
441							$msg = $( '.after-loading-success-message .success-message-container' ).last().clone().removeClass( 'd-none' );
442							$msg.find( '.product-name' ).empty().append( $link.closest( '.product' ).find( '.product-loop-title, .post-title a' ).clone() );
443						}
444						$msg.find( '.msg-box img' ).remove();
445						if ( $link.closest( '.product' ).find( '.product-image img' ).length ) {
446							var $img = $link.closest( '.product' ).find( '.product-image img' ).eq( 0 );
447							$( '<img />' ).attr( 'src', $img.data( 'oi' ) ? $img.data( 'oi' ) : $img.attr( 'src' ) ).appendTo( $msg.find( '.msg-box' ) ).attr( 'alt', $msg.find( '.msg .product-name' ).text() );
448						} else if ( typeof js_porto_vars.wc_placeholder_img != 'undefined' ) {
449							$( '<img />' ).attr( 'src', js_porto_vars.wc_placeholder_img ).appendTo( $msg.find( '.msg-box' ) ).attr( 'alt', $msg.find( '.msg .product-name' ).text() );
450						}
451						$( '.after-loading-success-message' ).eq( 0 ).stop().show();
452
453						if ( $link.hasClass( 'viewcart-style-2' ) ) {
454							if ( porto_product_add_cart_timer ) {
455								clearTimeout( porto_product_add_cart_timer );
456							}
457							porto_product_add_cart_timer = setTimeout( function() { $( '.after-loading-success-message' ).eq( 0 ).hide(); }, 4000 );
458						} else {
459							$msg.prependTo( '.after-loading-success-message' );
460							theme.requestTimeout( function() {
461								$msg.addClass( 'active' );
462							}, 50 );
463							setTimeout( function() { $msg.find( '.mfp-close' ).trigger( 'click' ); }, 5000 );
464						}
465					}
466				} );
467			} );
468
469			$( '.after-loading-success-message .continue_shopping' ).on( 'click', function() {
470				$( '.after-loading-success-message' ).eq( 0 ).fadeOut( 200 );
471			} );
472			$( '.after-loading-success-message' ).on( 'click', '.mfp-close', function() {
473				var $obj = $( this ).closest( '.success-message-container' );
474				$obj.removeClass( 'active' );
475				theme.requestTimeout( function() {
476					$obj.slideUp( 300, function() {
477						$obj.remove();
478					} );
479				}, 350 );
480			} );
481
482			$( document.body ).on( 'click', '.variations_form .variations .filter-item-list .filter-color, .variations_form .variations .filter-item-list .filter-item', function( e ) {
483				e.preventDefault();
484				var $this = $( this ),
485					$selector = $this.closest( 'ul' ).siblings( 'select' );
486				if ( !$selector.length || $this.hasClass( 'disabled' ) ) {
487					return;
488				}
489				var $li_obj = $this.closest( 'li' );
490				if ( $li_obj.hasClass( 'active' ) ) {
491					$li_obj.removeClass( 'active' );
492					$selector.val( '' );
493				} else {
494					$li_obj.addClass( 'active' ).siblings().removeClass( 'active' );
495					$selector.val( $this.data( 'value' ) );
496				}
497				$selector.trigger( 'change.wc-variation-form' );
498			} );
499
500
501			$( document.body ).on( 'click', '.porto-general-swatch .filter-color, .porto-general-swatch .filter-item', function( e ) {
502				e.preventDefault();
503				var $this = $( this ),
504					$swatch_li = $this.parent();
505
506				var $product = $( this ).closest( '.product, .product-col' );
507				var $product_img;
508				if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder
509					$product_img = $product.find( '.porto-tb-featured-image img' ).eq( 0 );
510				} else if ( $product.hasClass( 'product-col' ) ) { // product legacy loop
511					$product_img = $product.find( 'div.product-image .inner img:first-child' );
512				}
513
514				var srcOrig    = $product_img.data( 'original-src' ),
515				srcsetOrig = $product_img.data( 'original-srcset '),
516				sizesOrig  = $product_img.data( 'original-sizes' );
517				if ( typeof srcOrig == 'undefined' ) {
518					$product_img.data( 'original-src', $product_img.attr( 'src' ) );
519					if ( typeof srcsetOrig == 'undefined' && $product_img.attr( 'srcset' ) ) {
520						$product_img.data( 'original-srcset', $product_img.attr( 'srcset' ) );
521					}
522		
523					if ( typeof sizesOrig == 'undefined' && $product_img.attr( 'sizes' ) ) {
524						$product_img.data( 'original-sizes', $product_img.attr( 'sizes' ) );
525					}
526				}
527
528				var image_src = '',
529					image_srcset = '',
530					image_sizes = '';
531
532				if ( $this.parent().hasClass( 'active' ) ) {
533					$swatch_li.removeClass( 'active' );
534				} else { // active
535					$this.closest( 'ul' ).find( 'li' ).removeClass( 'active' );
536					$swatch_li.addClass( 'active' );
537					if ( $swatch_li.data( 'image-src' ) ) {
538						image_src = $swatch_li.data( 'image-src' );
539						image_srcset = $swatch_li.data( 'image-srcset' );
540						image_sizes = $swatch_li.data( 'image-sizes' );
541					}
542				}
543				if ( ! image_src ) {
544					var $active_swatch = $this.closest( '.porto-general-swatch' ).find( 'li.active' );
545					if ( $active_swatch.length && $active_swatch.data( 'image-src' ) ) {
546						image_src = $active_swatch.data( 'image-src' );
547						image_srcset = $active_swatch.data( 'image-srcset' );
548						image_sizes = $active_swatch.data( 'image-sizes' );
549					} else {
550						if ( $product_img.data('original-src' ) ) {
551							image_src = $product_img.data('original-src' );
552						}
553			
554						if ( $product_img.data( 'original-srcset' ) ) {
555							image_srcset = $product_img.data( 'original-srcset' );
556						}
557			
558						if ( $product_img.data( 'original-sizes' ) ) {
559							image_sizes = $product_img.data( 'original-sizes' );
560						}
561					}
562				}
563				if ( image_src ) {
564					$product_img.attr( 'src', image_src ).attr( 'srcset', image_srcset ).attr( 'image_sizes', image_sizes );
565					var $image_slider = $product.find( '.owl-carousel' );
566
567					if ( $image_slider.length ) {
568						$image_slider.trigger( 'to.owl.carousel', [0, 300, true] );
569					}
570				}
571			});
572
573
574			$( document ).on( 'wc_variation_form', '.variations_form', function() {
575				$( this ).addClass( 'vf_init' );
576				if ( $( this ).find( '.filter-item-list' ).length < 1 ) {
577					return;
578				}
579				$( this ).find( '.variations select' ).trigger( 'focusin' );
580			} );
581			$( document ).on( 'updated_wc_div', function() {
582				if ( $.fn.themePluginLazyLoad ) {
583					$( '.woocommerce-cart-form .porto-lazyload' ).themePluginLazyLoad();
584				}
585			} );
586			$( document ).on( 'found_variation reset_data', '.variations_form', function( e, args ) {
587				// attribute description
588				var $this = $( this );
589				if ( $this.find( '.product-attr-description' ).length ) {
590					if ( typeof args == 'undefined' ) {
591						$this.find( '.product-attr-description' ).removeClass( 'active' );
592					} else {
593						$this.find( '.product-attr-description' ).addClass( 'active' );
594						$this.find( '.product-attr-description .attr-desc' ).removeClass( 'active' );
595						$this.find( '.variations select' ).each( function() {
596							var $obj = $( this );
597							$this.find( '.product-attr-description .attr-desc[data-attrid="' + $obj.val() + '"]' ).addClass( 'active' );
598						} );
599					}
600				}
601
602				if ( $this.find( ".filter-item-list" ).length < 1 ) {
603					return;
604				}
605				$this.find( ".filter-item-list" ).each( function() {
606					if ( $( this ).next( "select" ).length < 1 ) {
607						return;
608					}
609					var selector = $( this ).next( "select" ),
610						//html = '',
611						$list = $( this );
612					$list.find( 'li.active' ).removeClass( 'active' );
613					$list.find( '.filter-color, .filter-item' ).removeClass( 'enabled' ).removeClass( 'disabled' );
614					selector.children( "option" ).each( function() {
615						/*var isColor = typeof $(this).data('color') != 'undefined' ? true : false,
616							isImage = typeof $(this).data('image') != 'undefined' ? true : false,
617						spanClass = isColor ? "filter-color" : ( isImage ? "filter-item filter-image" : "filter-item" );*/
618						if ( !$( this ).val() ) {
619							return;
620						}
621						$list.find( '[data-value="' + $( this ).val().replace(/"/g, '\\\"') + '"]' ).addClass( 'enabled' );
622						if ( $( this ).val() == selector.val() ) {
623							$list.find( '[data-value="' + $( this ).val().replace(/"/g, '\\\"') + '"]' ).parent().addClass( 'active' );
624						}
625						/*html += '<li';
626						if ($(this).val() == selector.val()) {
627							html += ' class="active"';
628						}
629						html += '><a href="#" data-value="'+ escape( $(this).val() ) +'" class="' + spanClass + '"';
630						if (isColor) {
631							html += ' style="background-color: #' + escape( $(this).data('color').replace('#','') ) + '"';
632						}
633						if (isImage) {
634							html += ' style="background-image:url(' + $(this).data('image') + ')"';
635						}
636						html += '>';
637						if (!isColor) {
638							html += $(this).text();
639						}
640						html += '</a></li>';*/
641					} );
642					$list.find( '.filter-color:not(.enabled), .filter-item:not(.enabled)' ).addClass( 'disabled' );
643					//$(this).html(html);
644				} );
645			} );
646
647			// daily sale
648			$( document ).on( 'found_variation reset_data', '.variations_form', function( e, obj ) {
649				var $wrapper = $( this ).closest( '.product' ),
650					$timer = $wrapper.find( '.sale-product-daily-deal.for-some-variations' );
651				if ( !$timer.length ) {
652					$timer = $wrapper.find( '.porto-product-sale-timer' ).eq( 0 );
653					if ( !$timer.length ) {
654						return;
655					}
656				}
657				if ( obj && obj.is_purchasable && typeof obj.porto_date_on_sale_to != 'undefined' && obj.porto_date_on_sale_to ) {
658					var saleTimer = $timer.find( '.porto_countdown-dateAndTime' );
659					if ( saleTimer.data( 'terminal-date' ) != obj.porto_date_on_sale_to ) {
660						var newDate = new Date( obj.porto_date_on_sale_to );
661						saleTimer.porto_countdown( 'option', { until: newDate } );
662						saleTimer.data( 'terminal-date', obj.porto_date_on_sale_to );
663					}
664					$timer.slideDown();
665				} else {
666					if ( $timer.is( ':hidden' ) ) {
667						$timer.hide();
668					} else {
669						$timer.slideUp();
670					}
671				}
672			} );
673
674			$( 'body' ).on( 'click', '.product-attr-description > a', function( e ) {
675				e.preventDefault();
676				$( this ).next().stop().slideToggle( 400 );
677			} );
678
679			// if product was already added to cart, show check icon in add to cart button and view cart button in single product page
680			if ( $( document.body ).hasClass( 'single-product' ) ) {
681				$( document ).on( 'woocommerce_variation_has_changed', '.variations_form', function( e, variation ) {
682					$( document.body ).removeClass( 'single-add-to-cart' );
683				} );
684				$( document ).on( 'found_variation', '.variations_form', function( e, variation ) {
685					try {
686						var cart_items = JSON.parse( sessionStorage.getItem( wc_cart_fragments_params.fragment_name ) );
687						if ( cart_items['div.widget_shopping_cart_content'] ) {
688							var cart_item = $( cart_items['div.widget_shopping_cart_content'] ).find( '.porto-variation-' + variation.variation_id );
689							if ( cart_item.length ) {
690								theme.requestFrame( function() {
691									$( document.body ).addClass( 'single-add-to-cart' );
692								} );
693							}
694						}
695					} catch ( e ) {
696					}
697				} );
698			}
699
700			// Mini Cart Quantity on Cart Popup or Offcanvas
701			var timeout;
702
703			$( document ).on( 'change input', '.cart_list .quantity .qty, .woocommerce-checkout-review-order-table .quantity .qty', function() {
704				var input = $(this);
705				var itemID = '';
706				var qtyVal = input.val();
707				var maxValue = input.attr( 'max' );
708				var is_checkout = false;
709	
710				clearTimeout( timeout );
711	
712				if ( parseInt( qtyVal ) > parseInt( maxValue ) ) {
713					qtyVal = maxValue;
714				}
715				if ( input.closest( '.cart_list' ).length ) {
716					itemID = input.parents( '.woocommerce-mini-cart-item' ).data( 'key' );
717				} else {
718					is_checkout = true;
719					itemID = input.closest( '.cart_item' ).data( 'key' );
720				}
721				timeout = setTimeout( function() {
722					if ( ! is_checkout ) {
723						input.parents( '.mini_cart_item' ).find( '.ajax-loading' ).show();
724					}
725					$.ajax( {
726						url     : theme.ajax_url,
727						data    : {
728							action : 'porto_update_cart_item',
729							item_id: itemID,
730							qty    : qtyVal
731						},
732						success : function( data ) {
733							if ( data && data.fragments ) {
734								updateCartFragment( data );
735								$( document.body ).trigger( 'wc_fragments_refreshed' );
736							}
737							if ( is_checkout ) {
738								input.closest( 'form.checkout' ).trigger( 'update' );
739							} else {
740								input.parents( '.mini_cart_item' ).find( '.ajax-loading' ).hide();
741							}
742						},
743						dataType: 'json',
744						method  : 'GET'
745					} );
746				}, 500 );
747			} );
748
749			if ( $( 'form.woocommerce-cart-form button.update-button-hidden' ).length > 0 ) {
750				$( document ).on( 'change input', 'form.woocommerce-cart-form .product-quantity input', function () {
751					var $form = $( this ).closest( 'form' ),
752						$updateBtn = $form.find( '.update-button-hidden' );
753
754					$updateBtn.removeAttr( 'disabled' );
755					$updateBtn.click();
756				} );
757			}
758
759			// fix dummy yith ajax requests on first load
760			if ( 'undefined' !== typeof yith_wcwl_l10n && yith_wcwl_l10n.reload_on_found_variation && $('.products-container .variations_form').length ) {
761				var porto_update_reload_wishlist_fn = function() {
762					yith_wcwl_l10n.reload_on_found_variation = true;
763					if ( $(this).closest( '.products-container' ).length ) {
764						yith_wcwl_l10n.reload_on_found_variation = false;
765					}
766				};
767				$('.products-container').one( 'woocommerce_variation_has_changed woocommerce_variation_select_change', '.variations_form', function() {
768					yith_wcwl_l10n.reload_on_found_variation = true;
769					$( document ).off( 'update_variation_values', '.variations_form', porto_update_reload_wishlist_fn );
770				} );
771				$( document ).on( 'update_variation_values', '.variations_form', porto_update_reload_wishlist_fn );
772			}
773		} );
774
775	} ).apply( this, [window.theme, jQuery] );
776
777
778	// Woocommerce Product Image Slider
779	( function( theme, $ ) {
780
781		theme = theme || {};
782
783		var duration = 300,
784			flag = false;
785
786		$.extend( theme, {
787
788			WooProductImageSlider: {
789
790				defaults: {
791					elements: '.product-image-slider'
792				},
793
794				initialize: function( $elements ) {
795
796					this.$elements = ( $elements || $( this.defaults.elements ) );
797					if ( !this.$elements.length && !$( '.product-images-block' ).length ) {
798						return this;
799					}
800					// if ( theme.isMobile() ) {
801					// 	let $zoom = this.$elements.siblings( '.zoom' );
802					// 	if ( $zoom.length ) {
803					// 		this.$elements.off( 'click' ).on( 'click', function() {
804					// 			$zoom.trigger( 'click' );
805					// 		} );
806					// 	}
807					// }
808/*
809					if ( !$.fn.owlCarousel ) {
810
811						this.$elements.each(function(){
812							var links = [],
813								$this = $( this );
814							if ( theme.product_image_popup ) {
815								var i = 0;
816								$this.find( 'img' ).each( function() {
817									var slide = {};
818
819									slide.src = $( this ).attr( 'href' );
820									slide.title = $( this ).attr( 'alt' );
821									slide.w = parseInt( $( this ).attr( 'data-large_image_width' ) );
822									slide.h = parseInt( $( this ).attr( 'data-large_image_height' ) );
823									
824									links[i] = slide;
825									i++;
826								} );
827							}
828
829							$this.data( 'links', links );
830
831							if ( theme.product_image_popup ) {
832								var $zoom_buttons = $this.siblings( '.zoom' );
833								$zoom_buttons.off( 'click' ).on( 'click', function( e ) {
834									if ( ! $this.data( 'links' ).length ) {
835										return;
836									}
837									e.preventDefault();
838									if ( typeof PhotoSwipe == 'undefined' ) {
839										return;
840									}
841									var options = $.extend( {
842										index: 0,
843										addCaptionHTMLFn: function( item, captionEl ) {
844											if ( ! item.title ) {
845												captionEl.children[0].textContent = '';
846												return false;
847											}
848											captionEl.children[0].textContent = item.title;
849											return true;
850										}
851									}, wc_single_product_params.photoswipe_options );
852
853									// Initializes and opens PhotoSwipe.
854									var photoswipe = new PhotoSwipe( $( '.pswp' )[0], PhotoSwipeUI_Default, $this.data( 'links' ), options );
855									photoswipe.init();
856
857								} );
858							}
859						});
860						return false;
861					}
862*/
863
864					this.build();
865
866					return this;
867				},
868
869				build: function() {
870					var self = this,
871						thumbs_count = theme.product_thumbs_count;
872
873					if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) {
874						var zoomConfig = {
875							responsive: true,
876							zoomWindowFadeIn: 200,
877							zoomWindowFadeOut: 100,
878							zoomType: js_porto_vars.zoom_type,
879							cursor: 'grab'
880						};
881
882						if ( js_porto_vars.zoom_type == 'lens' ) {
883							zoomConfig.scrollZoom = js_porto_vars.zoom_scroll;
884							zoomConfig.lensSize = js_porto_vars.zoom_lens_size;
885							zoomConfig.lensShape = js_porto_vars.zoom_lens_shape;
886							zoomConfig.containLensZoom = js_porto_vars.zoom_contain_lens;
887							zoomConfig.lensBorderSize = js_porto_vars.zoom_lens_border;
888							zoomConfig.borderColour = js_porto_vars.zoom_border_color;
889						}
890
891						if ( js_porto_vars.zoom_type == 'inner' ) {
892							zoomConfig.borderSize = 0;
893						} else {
894							zoomConfig.borderSize = js_porto_vars.zoom_border;
895						}
896						zoomConfig.zoomActivation = 'dbltouch';
897
898						if ( !self.$elements.length ) {
899							var $images_grid = $( '.product-images-block' );
900							if ( $images_grid.length ) {
901								self.initZoom( $images_grid, zoomConfig );
902							}
903						}
904					}
905
906					self.$elements.each( function() {
907						var $this = $( this ),
908							$product = $this.closest( '.product' );
909						if ( !$product.length ) {
910							$product = $this.closest( '.product_layout, .product-layout-image' ).eq( 0 );
911						}
912						var $thumbs_slider = $product.find( '.product-thumbs-slider' ),
913							$thumbs = $product.find( '.product-thumbnails-inner' ),
914							$thumbs_vertical_slider = $product.find( '.product-thumbs-vertical-slider' ),
915							currentSlide = 0,
916							count = $this.find( '> *' ).length;
917
918						$this.find( '> *:first-child' ).imagesLoaded( function() {
919
920							var links = [];
921							if ( theme.product_image_popup ) {
922								var i = 0;
923								$this.find( 'img' ).each( function() {
924									var slide = {}, _imageItem = $( this );
925									if ( _imageItem.closest( '.vd-image' ).length ) {
926										return;
927									}
928									slide.src = _imageItem.attr( 'href' );
929									slide.title = _imageItem.attr( 'alt' );
930									slide.w = parseInt( _imageItem.attr( 'data-large_image_width' ) );
931									slide.h = parseInt( _imageItem.attr( 'data-large_image_height' ) );
932									
933									links[i] = slide;
934									i++;
935								} );
936							}
937
938							if ( $.fn.owlCarousel ) {
939								$thumbs_slider.removeClass( 'has-ccols-spacing' );
940								$thumbs_slider.owlCarousel( {
941									rtl: theme.rtl,
942									loop: false,
943									autoplay: false,
944									items: thumbs_count,
945									nav: false,
946									navText: ["", ""],
947									dots: false,
948									rewind: true,
949									margin: 8,
950									stagePadding: 1,
951									lazyLoad: true,
952									onInitialized: function() {
953										self.selectThumb( null, $thumbs_slider, 0 );
954										if ( $thumbs_slider.find( '.owl-item' ).length >= thumbs_count )
955											$thumbs_slider.append( '<div class="thumb-nav"><div class="thumb-prev"></div><div class="thumb-next"></div></div>' );
956									}
957								} ).on( 'click', '.owl-item', function() {
958									self.selectThumb( $this, $thumbs_slider, $( this ).index() );
959								} );
960								if ( $thumbs_vertical_slider.length > 0 && typeof $.fn.slick == 'function' ) {
961									var slickOptions = {
962										dots: false,
963										vertical: true,
964										slidesToShow: thumbs_count,
965										slidesToScroll: 1,
966										infinite: false,
967									}
968									if ( thumbs_count >= 5 ) {
969										slickOptions['responsive'] = [
970											{
971												breakpoint: 992,
972												settings: {
973													slidesToShow: 4,
974												}
975											},
976											{
977												breakpoint: 768,
978												settings: {
979													slidesToShow: 3,
980												}
981											}
982										]
983									}
984									$thumbs_vertical_slider.slick( slickOptions ).on( 'click', '.slick-slide', function() {
985										self.selectVerticalSliderThumb( $this, $thumbs_vertical_slider, $( this ).data( 'slick-index' ) );
986									} );
987									$( '.product-layout-transparent .product-image-slider' ).on( 'resized.owl.carousel', function() {
988										$( window ).trigger( 'resize.slick' );
989									} );
990
991									self.selectVerticalSliderThumb( null, $thumbs_vertical_slider, 0 );
992									if ( $thumbs_vertical_slider.find( '.porto-lazyload' ).length ) {
993										theme.requestTimeout( function() {
994											$thumbs_vertical_slider.find( '.slick-cloned .porto-lazyload:not(.lazy-load-loaded)' ).each( function() {
995												$( this ).attr( 'src', $( this ).data( 'oi' ) ).removeAttr( 'data-oi' ).addClass( 'lazy-load-loaded' );
996											} );
997										}, 100 );
998									}
999								}
1000
1001								self.selectVerticalThumb( null, $thumbs, 0 );
1002								$thumbs.off( 'click', '.img-thumbnail' ).on( 'click', '.img-thumbnail', function() {
1003									self.selectVerticalThumb( $this, $thumbs, $( this ).index() );
1004								} );
1005
1006								$thumbs_slider.off( 'click', '.thumb-prev' ).on( 'click', '.thumb-prev', function( e ) {
1007									var currentThumb = $thumbs_slider.data( 'currentThumb' );
1008									self.selectThumb( $this, $thumbs_slider, --currentThumb );
1009								} );
1010								$thumbs_slider.off( 'click', '.thumb-next' ).on( 'click', '.thumb-next', function( e ) {
1011									var currentThumb = $thumbs_slider.data( 'currentThumb' );
1012									self.selectThumb( $this, $thumbs_slider, ++currentThumb );
1013								} );
1014
1015								var itemsCount = typeof $this.data( 'items' ) != 'undefined' ? $this.data( 'items' ) : 1,
1016									itemsResponsive = typeof $this.data( 'responsive' ) != 'undefined' ? $this.data( 'responsive' ) : {},
1017									centerItem = typeof $this.data( 'centeritem' ) != 'undefined' ? true : false,
1018									margin = typeof $this.data( 'margin' ) != 'undefined' ? $this.data( 'margin' ) : 0,
1019									loop = ( count > 1 ) ? ( typeof $this.data( 'loop' ) != 'undefined' ? $this.data( 'loop' ) : true ) : false;
1020								for ( var itemCount in itemsResponsive ) {
1021									itemsResponsive[itemCount] = { items: itemsResponsive[itemCount] };
1022								}
1023								$this.removeClass( 'has-ccols-spacing' );
1024								$this.owlCarousel( {
1025									rtl: theme.rtl,
1026									loop: loop,
1027									autoplay: false,
1028									items: itemsCount,
1029									margin: margin,
1030									responsive: itemsResponsive,
1031									autoHeight: true,
1032									nav: true,
1033									navText: ["", ""],
1034									dots: false,
1035									rewind: true,
1036									lazyLoad: true,
1037									center: centerItem,
1038									onInitialized: function() {
1039										if ( $this.find( '.owl-item.cloned' ).length ) {
1040											setTimeout( function() {
1041												if ( $.fn.themePluginLazyLoad ) {
1042													var ins = $this.find( '.owl-item.cloned .porto-lazyload:not(.lazy-load-loaded)' ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } );
1043													if ( ins && ins.loadAndDestroy ) {
1044														ins.loadAndDestroy();
1045													}
1046												}
1047											}, 100 );
1048										}
1049										//$this.find('.cloned .porto-lazyload:not(.lazy-load-loaded)').themePluginLazyLoad();
1050											self.initZoom( $this, zoomConfig );
1051									},
1052									onTranslate: function( event ) {
1053										currentSlide = event.item.index - $this.find( '.cloned' ).length / 2;
1054										currentSlide = ( currentSlide + event.item.count ) % event.item.count;
1055										self.selectThumb( null, $thumbs_slider, currentSlide );
1056										self.selectVerticalThumb( null, $thumbs, currentSlide );
1057										self.selectVerticalSliderThumb( null, $thumbs_vertical_slider, currentSlide );
1058
1059										/*var $obj = event.relatedTarget.items(currentSlide).find('img.owl-lazy:not(.owl-lazy-loaded)');
1060										if ($obj.length) {
1061											var src = $obj.attr('href'),
1062												elevateZoom = $obj.data('elevateZoom'),
1063												smallImage = $obj.data('src') ? $obj.data('src') : $obj.attr('src');
1064											if (typeof elevateZoom != 'undefined') {
1065												elevateZoom.swaptheimage(smallImage, src);
1066											}
1067										}*/
1068									},
1069									onRefreshed: function() {
1070										if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) {
1071											$this.find( 'img' ).each( function() {
1072												var $this = $( this ),
1073													src = typeof $this.attr( 'href' ) != 'undefined' ? $this.attr( 'href' ) : ( $this.data( 'oi' ) ? $this.data( 'oi' ) : $this.attr( 'src' ) ),
1074													elevateZoom = $this.data( 'elevateZoom' ),
1075													smallImage = $this.data( 'src' ) ? $this.data( 'src' ) : ( $this.data( 'oi' ) ? $this.data( 'oi' ) : $this.attr( 'src' ) );
1076												if ( typeof elevateZoom != 'undefined' ) {
1077													elevateZoom.startZoom();
1078													elevateZoom.swaptheimage( smallImage, src );
1079												} else if ( $.fn.elevateZoom ) {
1080													zoomConfig.zoomContainer = $this.parent();
1081													if ( ! $this.closest( '.vd-image' ).length ) {
1082														$this.elevateZoom( zoomConfig );
1083													}
1084												}
1085											} );
1086										}
1087									}
1088								} );
1089							} else {
1090								self.initZoom( $this, zoomConfig );
1091							}
1092
1093							$this.data( 'links', links );
1094
1095							if ( theme.product_image_popup ) {
1096								var $zoom_buttons = $this.siblings( '.zoom' );
1097								$zoom_buttons.off( 'click' ).on( 'click', function( e ) {
1098									if ( ! $this.data( 'links' ).length ) {
1099										return;
1100									}
1101									e.preventDefault();
1102									if ( typeof PhotoSwipe == 'undefined' ) {
1103										return;
1104									}
1105									var options = $.extend( {
1106										index: currentSlide ? currentSlide : 0,
1107										addCaptionHTMLFn: function( item, captionEl ) {
1108											if ( ! item.title ) {
1109												captionEl.children[0].textContent = '';
1110												return false;
1111											}
1112											captionEl.children[0].textContent = item.title;
1113											return true;
1114										}
1115									}, wc_single_product_params.photoswipe_options );
1116
1117									// Initializes and opens PhotoSwipe.
1118									var photoswipe = new PhotoSwipe( $( '.pswp' )[0], PhotoSwipeUI_Default, $this.data( 'links' ), options );
1119									photoswipe.init();
1120
1121								} );
1122							}
1123
1124						} );
1125					} );
1126
1127					return self;
1128				},
1129
1130				selectThumb: function( $image_slider, $thumbs_slider, index ) {
1131					if ( flag || !$thumbs_slider.length ) return;
1132
1133					flag = true;
1134					var len = $thumbs_slider.find( '.owl-item' ).length,
1135						actives = [],
1136						i = 0;
1137
1138					index = ( index + len ) % len;
1139					if ( $image_slider ) {
1140						$image_slider.trigger( 'to.owl.carousel', [index, duration, true] );
1141					}
1142					$thumbs_slider.find( '.owl-item' ).removeClass( 'selected' );
1143					$thumbs_slider.find( '.owl-item:eq(' + index + ')' ).addClass( 'selected' );
1144					$thumbs_slider.data( 'currentThumb', index );
1145					$thumbs_slider.find( '.owl-item.active' ).each( function() {
1146						actives[i++] = $( this ).index();
1147					} );
1148					if ( $.inArray( index, actives ) == -1 ) {
1149						if ( Math.abs( index - actives[0] ) > Math.abs( index - actives[actives.length - 1] ) ) {
1150							$thumbs_slider.trigger( 'to.owl.carousel', [( index - actives.length + 1 ) % len, duration, true] );
1151						} else {
1152							$thumbs_slider.trigger( 'to.owl.carousel', [index % len, duration, true] );
1153						}
1154					}
1155					flag = false;
1156				},
1157
1158				selectVerticalSliderThumb: function( $image_slider, $thumbs_vertical_slider, index ) {
1159					if ( flag || !$thumbs_vertical_slider.length ) return;
1160					flag = true;
1161					if ( 'undefined' == typeof $thumbs_vertical_slider[0].slick ) {
1162						return;
1163					}
1164					var len = $thumbs_vertical_slider[0].slick.slideCount,
1165						actives = [],
1166						i = 0;
1167					index = ( index + len ) % len;
1168					if ( $image_slider ) {
1169						$image_slider.trigger( 'to.owl.carousel', [index, duration, true] );
1170					}
1171					$thumbs_vertical_slider.find( '.slick-slide' ).removeClass( 'selected' );
1172					$thumbs_vertical_slider.find( '.slick-slide:eq(' + index + ')' ).addClass( 'selected' );
1173					$thumbs_vertical_slider.data( 'currentThumb', index );
1174					$thumbs_vertical_slider.find( '.slick-slide.slick-active' ).each( function() {
1175						actives[i++] = $( this ).index();
1176					} );
1177					if ( $.inArray( index, actives ) == -1 ) {
1178						if ( Math.abs( index - actives[0] ) > Math.abs( index - actives[actives.length - 1] ) ) {
1179							$thumbs_vertical_slider.get( 0 ).slick.goTo( ( index - actives.length + 1 ) % len, false );
1180						} else {
1181							$thumbs_vertical_slider.get( 0 ).slick.goTo( index % len, false );
1182						}
1183					}
1184					flag = false;
1185				},
1186
1187				selectVerticalThumb: function( $image_slider, $thumbs, index ) {
1188					if ( flag || !$thumbs.length ) return;
1189					flag = true;
1190					var len = $thumbs.find( '.img-thumbnail' ).length,
1191						i = 0;
1192
1193					index = ( index + len ) % len;
1194					if ( $image_slider ) {
1195						$image_slider.trigger( 'to.owl.carousel', [index, duration, true] );
1196					}
1197					$thumbs.find( '.img-thumbnail' ).removeClass( 'selected' );
1198					$thumbs.find( '.img-thumbnail:eq(' + index + ')' ).addClass( 'selected' );
1199					$thumbs.data( 'currentThumb', index );
1200					flag = false;
1201				},
1202
1203				initZoom: function( $this, zoomConfig ) {
1204					if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) {
1205						$this.find( 'img' ).each( function() {
1206							var $this = $( this );
1207							zoomConfig.zoomContainer = $this.parent();
1208							if ( $.fn.elevateZoom ) {
1209								if ( ! $this.closest( '.vd-image' ).length ) {
1210									$this.elevateZoom( zoomConfig );
1211								}
1212							} else {
1213								setTimeout( function() {
1214									if ( $.fn.elevateZoom ) {
1215										if ( ! $this.closest( '.vd-image' ).length ) {
1216											$this.elevateZoom( zoomConfig );
1217										}
1218									}
1219								}, 1000 );
1220							}
1221						} );
1222					}
1223				}
1224			}
1225
1226		} );
1227
1228	} ).apply( this, [window.theme, jQuery] );
1229
1230
1231	// Woocommerce Quick View
1232	( function( theme, $ ) {
1233
1234		theme = theme || {};
1235
1236		$.extend( theme, {
1237
1238			WooQuickView: {
1239
1240				initialize: function() {
1241
1242					this.events();
1243
1244					return this;
1245				},
1246
1247				events: function() {
1248					var self = this;
1249
1250					$( document ).on( 'click', '.quickview', function( e ) {
1251						e.preventDefault();
1252
1253						if ( !$.fn.elevateZoom && !$( '#porto-script-jquery-elevatezoom' ).length ) {
1254							var js = document.createElement( 'script' );
1255							js.id = 'porto-script-jquery-elevatezoom';
1256							$( js ).appendTo( 'body' ).attr( 'src', js_porto_vars.ajax_loader_url.replace( '/images/[email protected]', '/js/libs/jquery.elevatezoom.min.js' ) );
1257						}
1258
1259						var $this = $( this ),
1260							pid = $this.attr( 'data-id' );
1261
1262						function init_quick_view_window() {
1263
1264							var args = {
1265								href: theme.ajax_url,
1266								ajax: {
1267									data: {
1268										action: 'porto_product_quickview',
1269										variation_flag: typeof wc_add_to_cart_variation_params !== 'undefined',
1270										pid: pid,
1271										nonce: js_porto_vars.porto_nonce
1272									}
1273								},
1274								type: 'ajax',
1275								helpers: {
1276									overlay: {
1277										locked: true,
1278										fixed: true
1279									}
1280								},
1281								tpl: {
1282									error: '<p class="fancybox-error">' + theme.request_error + '</p>',
1283									closeBtn: '<a title="' + js_porto_vars.popup_close + '" class="fancybox-item fancybox-close" href="javascript:;"></a>',
1284									next: '<a title="' + js_porto_vars.popup_next + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
1285									prev: '<a title="' + js_porto_vars.popup_prev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
1286								},
1287								autoSize: true,
1288								autoWidth: true,
1289								afterShow: function( flag ) {
1290									theme.requestTimeout( function() {
1291										var $quickviewEl = $( '.quickview-wrap-' + pid );
1292										i
1292f ( $quickviewEl.length == 0 && $( '.woocommerce-wishlist' ).length ) { // if select variation on wishlist page
1293											$quickviewEl = $( '.quickview-wrap' );
1294										}
1295										if ( typeof flag == 'undefined' || flag ) {
1296											porto_woocommerce_init();
1297										}
1298										theme.WooProductImageSlider.initialize( $quickviewEl.find( '.product-image-slider' ) );
1299
1300										// compatibility issue with Yith WooCommerce Booking form
1301										if ( $( document.body ).hasClass( 'yith-booking' ) ) {
1302											$( document ).trigger( 'yith-wcbk-init-booking-form' );
1303										}
1304
1305										// Variation Form
1306										var form_variation = $quickviewEl.find( 'form.variations_form' );
1307										if ( form_variation.length > 0 ) {
1308											form_variation.wc_variation_form();
1309										}
1310
1311										// Enqueue Countdown, Countdown-loader
1312										if ( $( '.quickview-wrap-' + pid + ' .porto_countdown' ).length && ! theme.isFirstLoad && typeof $.fn.porto_countdown == 'undefined' ) {
1313											theme.isFirstLoad = true;
1314											var scripts = ['countdown.min.js', 'countdown-loader.min.js'];
1315											for ( let index = 0; index < scripts.length; index++ ) {
1316												if ( !document.getElementById( scripts[index] ) ) {
1317													var wf, script;
1318													wf = document.createElement( 'script' );
1319													script = document.scripts[0];
1320													wf.id = scripts[index];
1321													wf.src = js_porto_vars.func_url + 'shortcodes/assets/js/' + scripts[index];
1322													script.parentNode.insertBefore( wf, script );
1323												}
1324											}
1325										}
1326										$( document.body ).trigger( 'porto_init_countdown', [$quickviewEl] );
1327
1328										// Ajax load at the first by Yith Wishlist Plugin
1329										if ( ( 'undefined' !== typeof yith_wcwl_l10n ) && yith_wcwl_l10n.enable_ajax_loading ) {
1330											if ( $( '.fancybox-opened .wishlist-fragment' ).length ) {
1331												var options = {},
1332													$product = $( '.fancybox-opened .wishlist-fragment' ),
1333													id = $product.attr( 'class' ).split( ' ' ).filter( ( val ) => {
1334														return val.length && val !== 'exists';
1335													} ).join( yith_wcwl_l10n.fragments_index_glue );
1336												options[id] = $product.data( 'fragment-options' );
1337
1338												if ( !options ) {
1339													return;
1340												}
1341
1342												var ajaxData = {
1343													action: yith_wcwl_l10n.actions.load_fragments,
1344													context: 'frontend',
1345													fragments: options
1346												};
1347
1348												if ( typeof yith_wcwl_l10n.nonce != 'undefined' ) {
1349													ajaxData.nonce = yith_wcwl_l10n.nonce.load_fragments_nonce;
1350												}
1351
1352												$.ajax( {
1353													ajaxData,
1354													method: 'post',
1355													success: function( data ) {
1356														if ( typeof data.fragments !== 'undefined' ) {
1357															$.each( data.fragments, function( i, v ) {
1358																var itemSelector = '.' + i.split( yith_wcwl_l10n.fragments_index_glue ).filter( ( val ) => { return val.length && val !== 'exists' && val !== 'with-count'; } ).join( '.' ),
1359																	toReplace = $( itemSelector );
1360
1361																// find replace tempalte
1362																var replaceWith = $( v ).filter( itemSelector );
1363
1364																if ( !replaceWith.length ) {
1365																	replaceWith = $( v ).find( itemSelector );
1366																}
1367
1368																if ( toReplace.length && replaceWith.length ) {
1369																	toReplace.replaceWith( replaceWith );
1370																}
1371															} );
1372														}
1373													},
1374													url: yith_wcwl_l10n.ajax_url
1375												} );
1376											}
1377										}
1378										// Compatibility with Woo Variation Gallery
1379										$( document ).trigger( 'woo_variation_gallery_init' );
1380									}, 200 );
1381								},
1382								onUpdate: function() {
1383									theme.requestTimeout( function() {
1384										var $quickviewEl = $( '.quickview-wrap-' + pid );
1385										if ( $quickviewEl.length == 0 && $( '.woocommerce-wishlist' ).length ) { // if select variation on wishlist page
1386											$quickviewEl = $( '.quickview-wrap' );
1387										}
1388										if ( js_porto_vars.use_skeleton_screen.indexOf( 'quickview' ) == -1 || !js_porto_vars.quickview_skeleton ) {
1389											porto_woocommerce_init();
1390										}
1391										var $slider = $quickviewEl.find( '.product-image-slider' );
1392										if ( typeof $slider.data( 'owl.carousel' ) != 'undefined' && typeof $slider.data( 'owl.carousel' )._invalidated != 'undefined' )
1393											$slider.data( 'owl.carousel' )._invalidated.width = true;
1394										$slider.trigger( 'refresh.owl.carousel' );
1395										$( document.body ).trigger( 'porto_init_countdown', [$quickviewEl] );
1396									}, 300 );
1397								}
1398							};
1399							if ( js_porto_vars.use_skeleton_screen.indexOf( 'quickview' ) != -1 && js_porto_vars.quickview_skeleton ) {
1400								delete args['href'];
1401								delete args['ajax'];
1402								args['type'] = 'inline';
1403								$.fancybox.open(
1404									js_porto_vars.quickview_skeleton,
1405									args
1406								);
1407								$.ajax( {
1408									url: theme.ajax_url,
1409									type: 'post',
1410									dataType: 'html',
1411									data: {
1412										action: 'porto_product_quickview',
1413										variation_flag: typeof wc_add_to_cart_variation_params !== 'undefined',
1414										pid: pid,
1415										nonce: js_porto_vars.porto_nonce
1416									},
1417									success: function( res ) {
1418										var $res = $( res );
1419										$res.imagesLoaded( function() {
1420											$( '.skeleton-body.product' ).replaceWith( $res );
1421											theme.WooQtyField.initialize();
1422											$( window ).trigger( 'resize' );
1423											args['afterShow'].call( false );
1424										} );
1425									}
1426								} );
1427							} else {
1428								if ( typeof $.fancybox == 'function' ) {
1429								$.fancybox( args );
1430								} else if ( typeof $.fancybox == 'object' && $.fancybox.version && 0 === $.fancybox.version.indexOf( '3' ) ) {
1431									args['src'] = args['href'];
1432									args['ajax']['settings'] = {
1433										data: args['ajax']['data']
1434									};
1435									$.fancybox.open( args );
1436								}
1437							}
1438						}
1439
1440						if ( $.fn.fancybox ) {
1441							init_quick_view_window();
1442						} else if ( !$( '#porto-script-jquery-fancybox' ).length ) {
1443							var js1 = document.createElement( 'script' );
1444							js1.id = 'porto-script-jquery-fancybox';
1445							$( js1 ).appendTo( 'body' ).on( 'load', function() {
1446								init_quick_view_window();
1447							} ).attr( 'src', js_porto_vars.ajax_loader_url.replace( '/images/[email protected]', '/js/libs/jquery.fancybox.min.js' ) );
1448						}
1449
1450						return false;
1451					} );
1452
1453					// ajax add to cart on quickview
1454					if ( typeof wc_add_to_cart_params != 'undefined' ) {
1455						$( document.body ).on( 'click', '.single-product .single_add_to_cart_button:not(.disabled, .wpcbn-btn)', function( e ) {
1456							if ( $( this ).closest( '.single-product' ).hasClass( 'product-type-external' ) || $( this ).closest( '.single-product' ).hasClass( 'product-type-grouped' ) ) {
1457								return true;
1458							}
1459							if ( $( this ).hasClass( 'readmore' ) ) {
1460								return true;
1461							}
1462							e.preventDefault();
1463
1464							var $button = $( this ),
1465								product_id = $button.val(),
1466								variation_id = $button.closest( 'form' ).find( 'input[name="variation_id"]' ).val(),
1467								quantity = $button.closest( 'form' ).find( 'input[name="quantity"]' ).val();
1468							if ( $button.hasClass( 'loading' ) ) {
1469								return false;
1470							}
1471							$button.removeClass( 'added' );
1472							$button.addClass( 'loading' );
1473							$button.parent().addClass( 'porto-ajax-loading' );
1474							if ( !$button.siblings( '.porto-loading-icon' ).length ) {
1475								let $last = $button.siblings( 'button:last-of-type' );
1476								$( '<span class="porto-loading-icon"></span>' ).insertAfter( $last.length ? $last : $button );
1477							}
1478
1479							var data = {
1480								action: 'porto_add_to_cart',
1481								product_id: variation_id ? variation_id : product_id,
1482								quantity: quantity
1483							};
1484							if ( variation_id ) {
1485								var $variations = $button.closest( 'form' ).find( '.variations select' );
1486								if ( $variations.length ) {
1487									$variations.each( function() {
1488										var name = $( this ).data( 'attribute_name' ),
1489											val = $( this ).val();
1490										if ( name && val ) {
1491											data[name] = val;
1492										}
1493									} );
1494								}
1495							}
1496
1497							// Trigger event.
1498							$( document.body ).trigger( 'adding_to_cart', [$button, data] );
1499
1500							$.ajax( {
1501								type: 'POST',
1502								url: theme.ajax_url,
1503								data: data,
1504								dataType: 'json',
1505								success: function( response ) {
1506									$button.parent().removeClass( 'porto-ajax-loading' );
1507									if ( !response ) {
1508										return;
1509									}
1510									if ( response.error && response.product_url ) {
1511										window.location = response.product_url;
1512										return;
1513									}
1514									// Redirect to cart option
1515									if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) {
1516										window.location = wc_add_to_cart_params.cart_url;
1517										return;
1518									}
1519
1520									// Trigger event.
1521									$( document.body ).trigger( 'added_to_cart', [response.fragments, response.cart_hash, $button] );
1522								}
1523							} );
1524						} );
1525					}
1526
1527					return self;
1528				}
1529			}
1530
1531		} );
1532
1533	} ).apply( this, [window.theme, jQuery] );
1534
1535
1536	// Woocommerce Qty Field
1537	( function( theme, $ ) {
1538
1539		theme = theme || {};
1540
1541		$.extend( theme, {
1542
1543			WooQtyField: {
1544
1545				initialize: function() {
1546
1547					this.build()
1548						.events();
1549
1550					return this;
1551				},
1552
1553				qty_handler: function() {
1554					var $obj = $( this );
1555					if ( $obj.closest( '.quantity' ).next( '.add_to_cart_button[data-quantity]' ).length ) {
1556						var count = $obj.val();
1557						if ( count ) {
1558							$obj.closest( '.quantity' ).next( '.add_to_cart_button[data-quantity]' ).attr( 'data-quantity', count );
1559						}
1560					}
1561				},
1562
1563				build: function() {
1564					var self = this;
1565
1566					// Quantity buttons
1567					$( 'div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)' ).addClass( 'buttons_added' ).append( '<button type="button" value="+" class="plus">+</button>' ).prepend( '<button type="button" value="-" class="minus">-</button>' );
1568
1569					// Target quantity inputs on product pages
1570					$( 'input.qty:not(.product-quantity input.qty)' ).each( function() {
1571						var min = parseFloat( $( this ).attr( 'min' ) );
1572
1573						if ( min && min > 0 && parseFloat( $( this ).val() ) < min ) {
1574							$( this ).val( min );
1575						}
1576					} );
1577
1578					$( 'input.qty:not(.product-quantity input.qty)' ).off( 'change', self.qty_handler ).on( 'change', self.qty_handler );
1579
1580					$( document ).off( 'click', '.quantity .plus, .quantity .minus' ).on( 'click', '.quantity .plus, .quantity .minus', function() {
1581
1582						// Get values
1583						var $qty = $( this ).closest( '.quantity' ).find( '.qty' ),
1584							currentVal = parseFloat( $qty.val() ),
1585							max = parseFloat( $qty.attr( 'max' ) ),
1586							min = parseFloat( $qty.attr( 'min' ) ),
1587							step = $qty.attr( 'step' );
1588
1589						// Format values
1590						if ( !currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0;
1591						if ( max === '' || max === 'NaN' ) max = '';
1592						if ( min === '' || min === 'NaN' ) min = 0;
1593						if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) === 'NaN' ) step = 1;
1594
1595						// Change the value
1596						if ( $( this ).is( '.plus' ) ) {
1597
1598							if ( max && ( max == currentVal || currentVal > max ) ) {
1599								$qty.val( max );
1600							} else {
1601								$qty.val( currentVal + parseFloat( step ) );
1602							}
1603
1604						} else {
1605
1606							if ( min && ( min == currentVal || currentVal < min ) ) {
1607								$qty.val( min );
1608							} else if ( currentVal > 0 ) {
1609								$qty.val( currentVal - parseFloat( step ) );
1610							}
1611
1612						}
1613
1614						// Trigger change event
1615						$qty.trigger( 'change' );
1616					} );
1617
1618					return self;
1619				},
1620
1621				events: function() {
1622					var self = this;
1623
1624					$( document ).ajaxComplete( function( event, xhr, options ) {
1625						self.build();
1626					} );
1627
1628					return self;
1629				}
1630			}
1631
1632		} );
1633
1634	} ).apply( this, [window.theme, jQuery] );
1635
1636
1637	// Woocommerce Variation Form
1638	( function( theme, $ ) {
1639
1640		theme = theme || {};
1641
1642		var duration = 300;
1643
1644		$.extend( theme, {
1645
1646			WooVariationForm: {
1647
1648				initialize: function() {
1649
1650					this.init().events();
1651
1652					return this;
1653				},
1654
1655				init: function() {
1656					$( '.variations_form' ).each( function() {
1657						var $variation_form = $( this ),
1658							$reset_variations = $variation_form.find( '.reset_variations' );
1659
1660						if ( $reset_variations.css( 'visibility' ) == 'hidden' )
1661							$reset_variations.hide();
1662					} );
1663					return this;
1664				},
1665
1666				events: function() {
1667					var self = this;
1668
1669					$( document ).on( 'check_variations', '.variations_form', function( event, exclude, focus ) {
1670						var $variation_form = $( this ),
1671							$reset_variations = $variation_form.find( '.reset_variations' );
1672
1673						if ( $reset_variations.css( 'visibility' ) == 'hidden' )
1674							$reset_variations.hide();
1675					} );
1676
1677					$( document ).on( 'reset_image', '.variations_form', function( event ) {
1678						var $product = $( this ).closest( '.product, .product-col' ),
1679							$product_img = $product.find( 'div.product-images .woocommerce-main-image' );
1680						if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder
1681							$product_img = $product.find( '.porto-tb-featured-image img' ).eq( 0 );
1682						} else if ( $product.hasClass( 'product-col' ) ) { // shop pages
1683							$product_img = $product.find( 'div.product-image .inner img:first-child' );
1684						}
1685						var o_src = $product_img.attr( 'data-o_src' ),
1686							o_title = $product_img.attr( 'data-o_title' ),
1687							o_href = $product_img.attr( 'data-o_href' ),
1688							$thumb_img = $product.find( '.woocommerce-main-thumb' ),
1689							o_thumb_src = $thumb_img.attr( 'data-o_src' );
1690
1691						var $image_slider = $product.find( '.product-image-slider' ),
1692							$thumbs_slider = $product.find( '.product-thumbs-slider' ),
1693							links;
1694
1695						if ( $image_slider.length ) {
1696							$image_slider.trigger( 'to.owl.carousel', [0, duration, true] );
1697							links = $image_slider.data( 'links' );
1698						}
1699						if ( $thumbs_slider.length ) {
1700							$thumbs_slider.trigger( 'to.owl.carousel', [0, duration, true] );
1701							$thumbs_slider.find( '.owl-item:eq(0)' ).trigger( 'click' );
1702						}
1703
1704						if ( o_src ) {
1705							$product_img
1706								.attr( 'src', o_src )
1707								.attr( 'srcset', '' )
1708								.attr( 'alt', o_title )
1709								.attr( 'href', o_href );
1710
1711							$product_img.each( function() {
1712								var elevateZoom = $( this ).data( 'elevateZoom' );
1713								if ( typeof elevateZoom != 'undefined' ) {
1714									elevateZoom.swaptheimage( $( this ).attr( 'src' ), $( this ).attr( 'src' ) );
1715								}
1716							} );
1717
1718							if ( theme.product_image_popup && typeof links != 'undefined' ) {
1719								links[0].src = o_href;
1720								links[0].title = o_title;
1721							}
1722						}
1723						if ( o_thumb_src ) {
1724							$thumb_img.attr( 'src', o_thumb_src );
1725						}
1726					} );
1727
1728					$( document ).on( 'found_variation', '.variations_form', function( event, variation ) {
1729
1730						if ( typeof variation == 'undefined' ) {
1731							return;
1732						}
1733
1734						var $product = $( this ).closest( '.product, .product-col' ),
1735							$image_slider = $product.find( '.product-image-slider' ),
1736							$thumbs_slider = $product.find( '.product-thumbs-slider' ),
1737							links;
1738
1739						if ( $image_slider.length ) {
1740							$image_slider.trigger( 'to.owl.carousel', [0, duration, true] );
1741							links = $image_slider.data( 'links' );
1742						}
1743						if ( $thumbs_slider.length ) {
1744							$thumbs_slider.trigger( 'to.owl.carousel', [0, duration, true] );
1745							$thumbs_slider.find( '.owl-item:eq(0)' ).trigger( 'click' );
1746						}
1747
1748						var $shop_single_image = $product.find( 'div.product-images .woocommerce-main-image' ).length ? $product.find( 'div.product-images .woocommerce-main-image' ) : $( '.single-product div.product-images .woocommerce-main-image' ),
1749							productimage = $shop_single_image.attr( 'data-o_src' ),
1750							imagetitle = $shop_single_image.attr( 'data-o_title' ),
1751							imagehref = $shop_single_image.attr( 'data-o_href' ),
1752							$shop_thumb_image = $product.find( '.woocommerce-main-thumb' ),
1753							thumbimage = $shop_thumb_image.attr( 'data-o_src' ),
1754							variation_image = variation.image_src,
1755							variation_link = variation.image_link,
1756							variation_title = variation.image_title,
1757							variation_thumb = variation.image_thumb;
1758
1759						if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder
1760							$shop_single_image = $product.find( '.porto-tb-featured-image img' ).eq( 0 );
1761							productimage = $shop_single_image.attr( 'data-o_src' );
1762							variation_image = variation.image.thumb_src;
1763						} else if ( $product.hasClass( 'product-col' ) ) { // shop pages
1764							$shop_single_image = $product.find( 'div.product-image .inner img:first-child' );
1765							productimage = $shop_single_image.attr( 'data-o_src' );
1766							variation_image = variation.image.thumb_src;
1767						}
1768
1769						if ( !productimage ) {
1770							productimage = $shop_single_image.attr( 'data-oi' ) ? $shop_single_image.attr( 'data-oi' ) : ( ( !$shop_single_image.attr( 'src' ) ) ? '' : $shop_single_image.attr( 'src' ) );
1771							$shop_single_image.attr( 'data-o_src', productimage );
1772						}
1773
1774						if ( !imagehref ) {
1775							imagehref = ( !$shop_single_image.attr( 'href' ) ) ? '' : $shop_single_image.attr( 'href' );
1776							$shop_single_image.attr( 'data-o_href', imagehref );
1777						}
1778
1779						if ( !imagetitle ) {
1780							imagetitle = ( !$shop_single_image.attr( 'alt' ) ) ? '' : $shop_single_image.attr( 'alt' );
1781							$shop_single_image.attr( 'data-o_title', imagetitle );
1782						}
1783
1784						if ( !thumbimage ) {
1785							thumbimage = $shop_thumb_image.attr( 'data-oi' ) ? $shop_thumb_image.attr( 'data-oi' ) : ( ( !$shop_thumb_image.attr( 'src' ) ) ? '' : $shop_thumb_image.attr( 'src' ) );
1786							$shop_thumb_image.attr( 'data-o_src', thumbimage );
1787						}
1788
1789						if ( variation_image ) {
1790							$shop_single_image.attr( 'src', variation_image );
1791							$shop_single_image.attr( 'srcset', '' );
1792							$shop_single_image.attr( 'alt', variation_title );
1793							$shop_single_image.attr( 'href', variation_link );
1794							$shop_thumb_image.attr( 'src', variation_thumb );
1795							if ( theme.product_image_popup && typeof links != 'undefined' ) {
1796								links[0].src = variation_link;
1797								links[0].title = variation_title;
1798							}
1799						} else {
1800							$shop_single_image.attr( 'src', productimage );
1801							$shop_single_image.attr( 'srcset', '' );
1802							$shop_single_image.attr( 'alt', imagetitle );
1803							$shop_single_image.attr( 'href', imagehref );
1804							$shop_thumb_image.attr( 'src', thumbimage );
1805							if ( theme.product_image_popup && typeof links != 'undefined' ) {
1806								links[0].src = imagehref;
1807								links[0].title = imagetitle;
1808							}
1809						}
1810						$shop_single_image.each( function() {
1811							var elevateZoom = $( this ).data( 'elevateZoom' );
1812							if ( typeof elevateZoom != 'undefined' ) {
1813								elevateZoom.swaptheimage( $( this ).attr( 'src' ), $( this ).attr( 'src' ) );
1814							}
1815						} );
1816					} );
1817
1818					// fix scrolling to top issue on fancybox quickview whenever updating variation
1819					var porto_fb_update_trigger = null;
1820					$( document ).on( 'found_variation reset_image', '.variations_form', function( event, variation ) {
1821						if ( $( this ).closest( '.fancybox-inner' ).length && $.fancybox ) {
1822							$( window ).off( 'resize.fb', $.fancybox.update );
1823							if ( porto_fb_update_trigger ) {
1824								theme.deleteTimeout( porto_fb_update_trigger );
1825							}
1826							porto_fb_update_trigger = theme.requestTimeout( function() {
1827								$( window ).on( 'resize.fb', $.fancybox.update );
1828								$.fancybox.reposition();
1829								porto_fb_update_trigger = false;
1830							}, 600 );
1831						}
1832					} );
1833
1834					return self;
1835				}
1836			}
1837
1838		} );
1839
1840	} ).apply( this, [window.theme, jQuery] );
1841
1842
1843	// Woocommerce Events
1844	( function( theme, $ ) {
1845
1846		theme = theme || {};
1847
1848		$.extend( theme, {
1849
1850			WooEvents: {
1851
1852				initialize: function() {
1853
1854					this.events();
1855
1856					return this;
1857				},
1858
1859				events: function() {
1860					var self = this;
1861
1862					// wcml currency switcher
1863					$( document ).on( 'click', '.wcml-switcher li', function() {
1864						if ( $( this ).parent().attr( 'disabled' ) == 'disabled' )
1865							return;
1866						var currency = $( this ).attr( 'rel' );
1867						self.loadCurrency( currency );
1868					} );
1869
1870					// woocommerce currency switcher
1871					$( document ).on( 'click', '.woocs-switcher li', function() {
1872						if ( $( this ).parent().attr( 'disabled' ) == 'disabled' )
1873							return;
1874						var currency = $( this ).attr( 'rel' );
1875						self.loadWoocsCurrency( currency );
1876					} );
1877
1878					return self;
1879				},
1880
1881				loadCurrency: function( currency ) {
1882					$( '.wcml-switcher' ).attr( 'disabled', 'disabled' );
1883					$( '.wcml-switcher' ).append( '<li class="loading"></li>' );
1884					var data = { action: 'wcml_switch_currency', currency: currency };
1885					$.ajax( {
1886						type: 'post',
1887						url: theme.ajax_url,
1888						data: {
1889							action: 'wcml_switch_currency',
1890							currency: currency
1891						},
1892						success: function( response ) {
1893							$( '.wcml-switcher' ).removeAttr( 'disabled' );
1894							$( '.wcml-switcher' ).find( '.loading' ).remove();
1895							window.location = window.location.href;
1896						}
1897					} );
1898				},
1899
1900				loadWoocsCurrency: function( currency ) {
1901					$( '.woocs-switcher' ).attr( 'disabled', 'disabled' );
1902					$( '.woocs-switcher' ).append( '<li class="loading"></li>' );
1903					var l = window.location.href;
1904					l = l.split( '?' );
1905					l = l[0];
1906					var string_of_get = '?';
1907					woocs_array_of_get.currency = currency;
1908
1909					if ( Object.keys( woocs_array_of_get ).length > 0 ) {
1910						jQuery.each( woocs_array_of_get, function( index, value ) {
1911							string_of_get = string_of_get + "&" + index + "=" + value;
1912						} );
1913					}
1914					window.location = l + string_of_get;
1915				},
1916
1917				removeParameterFromUrl: function( url, parameter ) {
1918					return url
1919						.replace( new RegExp( '[?&]' + parameter + '=[^&#]*(#.*)?$' ), '$1' )
1920						.replace( new RegExp( '([?&])' + parameter + '=[^&]*&' ), '$1' );
1921				}
1922			}
1923
1924		} );
1925
1926	} ).apply( this, [window.theme, jQuery] );
1927
1928	( function( theme, $ ) {
1929
1930		$( document ).ready( function() {
1931			// Woocommerce Qty Field
1932			if ( typeof theme.WooQtyField !== 'undefined' ) {
1933				theme.WooQtyField.initialize();
1934			}
1935
1936			// Woocommerce Quick View
1937			if ( typeof theme.WooQuickView !== 'undefined' ) {
1938				theme.WooQuickView.initialize();
1939			}
1940
1941			// Woocommerce Events
1942			if ( typeof theme.WooEvents !== 'undefined' ) {
1943				theme.WooEvents.initialize();
1944			}
1945
1946			// disable drop down
1947			if ( !( 'ontouchstart' in document ) ) {
1948				$( '.mini-cart' ).on( 'hide.bs.dropdown', function() {
1949					return false;
1950				} );
1951			} else {
1952				$( '#mini-cart .cart-head' ).on( 'click', function( e ) {
1953					$( this ).parent().toggleClass( 'open' );
1954				} );
1955				$( 'html,body' ).on( 'click', function( e ) {
1956					if ( $( '#mini-cart' ).hasClass( 'open' ) && !$( e.target ).closest( '#mini-cart' ).length ) {
1957						$( '#mini-cart' ).removeClass( 'open' );
1958					}
1959				} );
1960			}
1961
1962			$( document ).on( 'tabactivate', '.woocommerce-tabs', function( e, ui ) {
1963				var label = $( ui ).attr( 'data-target' );
1964				var panel = $( ui ).closest( '.woocommerce-tabs' ).find( '[aria-labelledby="' + label + '"' );
1965				theme.refreshVCContent( panel );
1966			} );
1967
1968			// Perfect WooCommerce Brand Plugin
1969			$( document ).find( '.pwb-columns a[href="' + window.location.href + '"' ).each( function(){
1970				$( this ).addClass( 'active' );
1971			} )
1972		} );
1973	} ).apply( this, [window.theme, jQuery] );
1974
1975
1976	( function( theme, $, undefined ) {
1977
1978		$( document ).ready( function() {
1979
1980			/*===================================================================================*/
1981			/*  TOOLTIP FOR YITH WISHLIST, COMPARE, ADD TO CART, QUICK VIEW
1982			/*===================================================================================*/
1983			if ( ! theme.isMobile() ) {
1984				$( document ).on( 'yith_wcwl_init_after_ajax', function() {
1985					$( '.product-col .add_to_wishlist:not([data-bs-original-title]), .product-col .yith-wcwl-wishlistaddedbrowse > a:not([data-bs-original-title]), .product-col .yith-wcwl-wishlistexistsbrowse > a:not([data-bs-original-title])' ).each( function() {
1986						let _this = $( this );
1987						if ( ! _this.attr( 'title' ) ) {
1988							_this.attr( 'title', _this.text().trim() );
1989						}
1990						_this.tooltip();
1991					} );
1992				} );
1993			}
1994			// Woocommerce Variation Form
1995			theme.WooVariationForm.initialize();
1996
1997			// Woocommerce Product Image Slider
1998			if ( typeof theme.initAsync == 'function' ) {
1999				theme.WooProductImageSlider.initialize();
2000				porto_woocommerce_init();
2001			} else {
2002				$.when( theme.asyncDeferred ).done( function() {
2003					theme.WooProductImageSlider.initialize();
2004					porto_woocommerce_init();
2005				} );
2006			}
2007
2008			// Yith plugins compatibility
2009			$( document ).on( 'yith_wccl_product_gallery_loaded', function() {
2010				theme.WooProductImageSlider.initialize();
2011			} );
2012
2013			$( window ).on( 'vc_reload', function() {
2014				porto_woocommerce_init();
2015				$( '.type-product' ).addClass( 'product' );
2016			} );
2017
2018			// Add wishlist popup
2019			/*if ( !$( '#yith-wcwl-popup-message' ).length ) {
2020				$( 'body' ).prepend( $( '<div>' ).attr( 'id', 'yith-wcwl-popup-message' ).html( '<div id="yith-wcwl-message"></div>' ).hide() );
2021			}*/
2022
2023			// shop horizontal filter
2024			$( document ).on( 'click', '.porto-product-filters-toggle a', function( e ) {
2025				e.preventDefault();
2026				$( this ).closest( '.porto-product-filters-toggle' ).toggleClass( 'opened' );
2027				var $products_wrapper = $( this ).closest( '#main' ).find( '.main-content' ).find( 'ul.products' ), offset, $main = $( this ).closest( '#main' ).find( '.main-content-wrap' );
2028				$main.toggleClass( 'opened' );
2029				if ( $main.hasClass( 'opened' ) ) {
2030					offset = -1;
2031				} else {
2032					offset = 1;
2033				}
2034				if ( $products_wrapper.hasClass( 'grid' ) ) {
2035					var cols_lg_index = 0, cols_md_index = 0, width_lg_index = 0, width_md_index = 0;
2036					for ( var i = 1; i <= 8; i++ ) {
2037						if ( !cols_lg_index && $products_wrapper.hasClass( 'ccols-xl-' + i ) ) {
2038							cols_lg_index = i;
2039							if ( i + offset >= 1 ) {
2040								$products_wrapper.removeClass( 'ccols-xl-' + i );
2041								$products_wrapper.addClass( 'ccols-xl-' + ( i + offset ) );
2042							}
2043						}
2044						if ( !cols_md_index && $products_wrapper.hasClass( 'ccols-lg-' + i ) ) {
2045							cols_md_index = i;
2046							if ( i + offset >= 1 ) {
2047								$products_wrapper.removeClass( 'ccols-lg-' + i );
2048								if ( offset === -1 ) {
2049									$products_wrapper.addClass( 'ccols-md-' + i );
2050								}
2051								$products_wrapper.addClass( 'ccols-lg-' + ( i + offset ) );
2052							}
2053						}
2054						if ( !width_lg_index && $products_wrapper.hasClass( 'pwidth-lg-' + i ) ) {
2055							width_lg_index = i;
2056							if ( i + offset >= 1 ) {
2057								$products_wrapper.removeClass( 'pwidth-lg-' + i );
2058								$products_wrapper.addClass( 'pwidth-lg-' + ( i + offset ) );
2059							}
2060						}
2061						if ( !width_md_index && $products_wrapper.hasClass( 'pwidth-md-' + i ) ) {
2062							width_md_index = i;
2063							if ( i + offset >= 1 ) {
2064								$products_wrapper.removeClass( 'pwidth-md-' + i );
2065								$products_wrapper.addClass( 'pwidth-md-' + ( i + offset ) );
2066							}
2067						}
2068					}
2069				}
2070				theme.requestTimeout( function() {
2071					$( window ).trigger( 'scroll' );
2072					// Update Carousel
2073					$( document ).find( '.owl-carousel' ).each( function( e ) {
2074						var $this = $( this );
2075						if ( $this.data( 'owl.carousel' ) ) {
2076							$this.trigger( 'refresh.owl.carousel' );
2077						}
2078					} );
2079					// Update Swiper
2080					$( document ).find( '.swiper-container' ).each( function( e ) {
2081						var $this = $( this ),
2082							$instance = $this.data( 'swiper' );
2083						if ( $instance ) {
2084							$instance.update();
2085						}
2086					} );
2087				}, 300 );
2088
2089				if ( $main.hasClass( 'opened' ) ) {
2090					$.cookie( 'porto_horizontal_filter', 'opened' );
2091				} else {
2092					$.cookie( 'porto_horizontal_filter', 'closed' );
2093				}
2094				theme.refreshStickySidebar( true );
2095
2096				return false;
2097			} );
2098			if ( $.cookie && 'opened' == $.cookie( 'porto_horizontal_filter' ) && $( '#main .porto-products-filter-body' ).length && !theme.isTablet() ) {
2099				$( '.porto-product-filters-toggle a' ).trigger( 'click' );
2100				$( '#main .porto-products-filter-body [data-plugin-sticky]:not(.manual)' ).addClass( 'manual' );
2101				setTimeout( function() {
2102					var $obj = $( '#main .porto-products-filter-body [data-plugin-sticky].manual' ),
2103						pluginOptions = $obj.data( 'plugin-options' );
2104					$obj.removeClass( 'manual' ).themeSticky( pluginOptions );
2105					theme.requestTimeout( function() {
2106						$( window ).trigger( 'scroll' );
2107					}, 100 );
2108				}, 500 );
2109			}
2110
2111			$( document ).on( 'click', '.porto-product-filters.style2 .widget-title', function( e ) {
2112				e.preventDefault();
2113				if ( $( this ).next().is( ':hidden' ) ) {
2114					$( '.porto-product-filters.style2 .widget-title' ).next().hide();
2115					$( '.porto-product-filters.style2 .widget' ).removeClass( 'opened' );
2116					$( this ).next().show();
2117					$( this ).next().find( 'input[type="text"]:first-child' ).focus();
2118				} else {
2119					$( this ).next().hide();
2120				}
2121				$( this ).parent().toggleClass( 'opened' );
2122				return false;
2123			} );
2124			$( 'body' ).on( 'click', function( e ) {
2125				if ( !$( e.target ).is( '.porto-product-filters' ) && !$( e.target ).is( '.porto-product-filters *' ) ) {
2126					$( '.porto-product-filters.style2 .widget-title' ).next().hide();
2127					$( '.porto-product-filters.style2 .widget' ).removeClass( 'opened' );
2128				}
2129			} );
2130
2131			// Perform AJAX login on form submit
2132			$( 'body' ).on( 'click', '#login-form-popup form .woocommerce-Button', function( e ) {
2133				var $this = $( this ),
2134					$form = $this.closest( 'form' ),
2135					isLogin = $this.hasClass( 'login-btn' );
2136				if ( !isLogin && !$this.hasClass( 'register-btn' ) ) {
2137					isLogin = $form.hasClass( 'login' );
2138				}
2139				$form.find( '#email' ).val( $form.find( '#username' ).val() );
2140				$form.find( 'p.status' ).show().text( js_porto_vars.login_popup_waiting_msg ? js_porto_vars.login_popup_waiting_msg : 'Please wait...' ).addClass( 'loading' );
2141				$form.find( 'button[type=submit]' ).attr( 'disabled', 'disabled' );
2142				$.ajax( {
2143					type: 'POST',
2144					dataType: 'json',
2145					url: theme.ajax_url,
2146					data: $form.serialize() + '&action=porto_account_login_popup_' + ( isLogin ? 'login' : 'register' ),
2147					success: function( data ) {
2148						$form.find( 'p.status' ).html( data.message.replace( '/<script.*?\/script>/s', '' ) ).removeClass( 'loading' );
2149						$form.find( 'button[type=submit]' ).removeAttr( 'disabled' );
2150						if ( data.loggedin === true ) {
2151							window.location.reload();
2152						}
2153					}
2154				} );
2155				e.preventDefault();
2156			} );
2157
2158			// shortcodes
2159			var $ajax_tab_cache = {};
2160			$( document ).on( 'click', '.porto-products.show-category .product-categories a', function( e ) {
2161				e.preventDefault();
2162				var $this = $( this ), $form = $this.closest( '.porto-products' ).find( '.pagination-form' ), id = $this.closest( '.porto-products' ).attr( 'id' ), group = [];
2163				$( this ).parent().siblings().removeClass( 'current' );
2164				$( this ).parent().addClass( 'current' );
2165				if ( typeof $this.data( 'sort_id' ) != 'undefined' ) {
2166					$form.find( 'input[name="orderby"]' ).val( $this.data( 'sort_id' ) );
2167					group = $this.data( 'sort_id' );
2168					$form.find( 'input[name="category"]' ).val( '' );
2169				}
2170				if ( typeof $this.data( 'cat_id' ) != 'undefined' ) {
2171					if ( typeof $this.data( 'sort_id' ) == 'undefined' ) {
2172						$form.find( 'input[name="orderby"]' ).val( $form.find( 'input[name="original_orderby"]' ).val() );
2173						group = $form.find( 'input[name="original_orderby"]' ).val();
2174					}
2175					if ( typeof $form.data( 'original_cat_id' ) == 'undefined' ) {
2176						$form.data( 'original_cat_id', $form.find( 'input[name="category"]' ).val() );
2177						group = $form.find( 'input[name="category"]' ).val();
2178					}
2179					if ( $this.data( 'cat_id' ) ) {
2180						$form.find( 'input[name="category"]' ).val( $this.data( 'cat_id' ) );
2181						group = $this.data( 'cat_id' );
2182					} else {
2183						if ( $form.data( 'original_cat_id' ) ) {
2184							$form.find( 'input[name="category"]' ).val( $form.data( 'original_cat_id' ) );
2185							group = $form.data( 'original_cat_id' );
2186						} else {
2187							$form.find( 'input[name="category"]' ).val( '' );
2188							group = '';
2189						}
2190					}
2191				}
2192				var data = $form.serialize() + '&product-page=1&action=porto_woocommerce_shortcodes_products&nonce=' + js_porto_vars.porto_nonce;
2193				$this.closest( '.porto-products' ).find( 'ul.products' ).trigger( 'porto_update_products', [data, '', $this, id, group] );
2194			} );
2195			$( document ).on( 'click', '.porto-products .page-numbers a', function( e ) {
2196				var $this = $( this ), pagination_style,
2197					$shop_container = $this.closest( '.porto-products' ).find( 'ul.products' ),
2198					cur_page = $shop_container.data( 'cur_page' ),
2199					max_page = $shop_container.data( 'max_page' ),
2200					$form = $this.closest( '.porto-products' ).find( '.pagination-form' );
2201				e.preventDefault();
2202				if ( $this.closest( '.pagination' ).hasClass( 'load-more' ) ) {
2203					if ( !cur_page || !max_page || ++cur_page > max_page ) {
2204						return;
2205					}
2206					pagination_style = 'load_more';
2207					$this.data( 'text', $this.text() );
2208					$this.text( js_porto_vars.loader_text );
2209				} else {
2210					var url = new RegExp( "product-page(=|/)([^(&|/)]*)", "i" ).exec( this.href );
2211					cur_page = url && unescape( url[2] ) || "";
2212					pagination_style = 'default';
2213				}
2214				var page_var = cur_page ? '&product-page=' + escape( cur_page ) : '', data = $form.serialize() + page_var + '&action=porto_woocommerce_shortcodes_products&nonce=' + js_porto_vars.porto_nonce;
2215				$shop_container.trigger( 'porto_update_products', [data, pagination_style, $this] );
2216				if ( 'default' == pagination_style ) {
2217					theme.scrolltoContainer( $shop_container );
2218				}
2219			} );
2220			$( document ).on( 'porto_update_products', 'ul.products', function( e, data, pagination_style, $obj, id, group ) {
2221				var $this = $( this );
2222				// ajax tab
2223				if ( undefined == $ajax_tab_cache[id] || -1 == Object.keys( $ajax_tab_cache[id] ).indexOf( group ) ) {
2224					porto_ajax_load_products( $this, data, pagination_style, $ajax_tab_cache, id, group );
2225				} else {
2226					var response = $ajax_tab_cache[id][group];
2227					//animation
2228					$this.css( 'opacity', 0 );
2229					$this.animate(
2230						{
2231							'opacity': 1,
2232						},
2233						400,
2234						function() {
2235							$this.css( 'opacity', '' );
2236						}
2237					);
2238
2239					porto_ajax_load_products_success( $this, response, pagination_style );
2240				}
2241			} );
2242
2243			// initialize woocommerce actions after skeleton loading
2244			var skeletonLoadingTrigger;
2245			$( '.skeleton-loading' ).on( 'skeleton-loaded', function() {
2246				var $this = $( this );
2247				if ( skeletonLoadingTrigger ) {
2248					theme.deleteTimeout( skeletonLoadingTrigger );
2249				}
2250				porto_woocommerce_variations_init( $this );
2251
2252				// yith wishlist pro compatibility
2253				if ( $this.hasClass( 'products' ) || $this.hasClass( 'product' ) ) {
2254					$( document ).trigger( 'yith_infs_added_elem' );
2255				}
2256
2257				skeletonLoadingTrigger = theme.requestTimeout( function() {
2258					porto_woocommerce_init();
2259					if ( $( 'body' ).hasClass( 'single-product' ) ) {
2260						theme.WooVariationForm.init();
2261						var $image_slider = $( '.product-image-slider' );
2262						if ( $image_slider.length && $image_slider.data( 'owl.carousel' ) ) {
2263							$image_slider.trigger( 'refresh.owl.carousel' );
2264						} else {
2265							theme.WooProductImageSlider.initialize();
2266						}
2267						$( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' );
2268
2269						// compatibility issue with Yith WooCommerce Booking form
2270						if ( $( document.body ).hasClass( 'yith-booking' ) ) {
2271							$( document ).trigger( 'yith-wcbk-init-booking-form' );
2272						}
2273					}
2274
2275					// refresh cart content
2276					if ( $this.find( '.widget_shopping_cart_content' ).length ) {
2277						$( document.body ).trigger( 'wc_fragment_refresh' );
2278					}
2279				}, 100 );
2280			} );
2281		} );
2282		
2283		var stickyShop = function() {
2284		
2285			// sticky add to cart
2286			var $sticky_product_obj = $( '.single-product .sticky-product' ),
2287				is_elementor_editor = $( document.body ).hasClass( 'elementor-editor-active' ),
2288				$sticky_product_form;
2289
2290			var init_sticky_add_to_cart_fn = function( $sticky_product_obj, is_elementor_editor ) {
2291				if ( is_elementor_editor && elementorFrontend && elementorFrontend.hooks ) {
2292					elementorFrontend.hooks.addAction( 'frontend/element_ready/porto_cp_addcart_sticky.default', function( $obj ) {
2293						$sticky_product_obj = $( '.single-product .sticky-product' );
2294						window.dispatchEvent( new Event( 'scroll' ) );
2295					} );
2296				}
2297
2298				$sticky_product_form = $( 'form.cart:visible' ).eq(0);
2299
2300				window.addEventListener( 'scroll', function() {
2301					var scrollTop = $( window ).scrollTop(),
2302						offset = theme.adminBarHeight() + ( theme.StickyHeader.sticky_height > 1 ? theme.StickyHeader.sticky_height : 0 ),
2303                        prevScrollPos = $sticky_product_obj.data('prev-pos') ? $sticky_product_obj.data('prev-pos') : 0;
2304					
2305					if ( ! $sticky_product_obj.hasClass( 'show-mobile' ) && $( window ).width() < 768 ) {
2306						$( 'body' ).css( 'padding-bottom', '' );
2307					} else if ( $sticky_product_form.length && $sticky_product_form.offset().top + $sticky_product_form.height() / 2 <= scrollTop + offset ) {
2308						if ( $( '.page-wrapper' ).hasClass( 'sticky-scroll-up' ) && ! $( 'html' ).hasClass( 'porto-search-opened' ) && $sticky_product_obj.hasClass( 'pos-top' ) ) {
2309							if ( scrollTop >= prevScrollPos ) {
2310								$sticky_product_obj.addClass('scroll-down');
2311							} else {
2312								$sticky_product_obj.removeClass('scroll-down');
2313							}
2314
2315							var scrollUpOffset = - theme.StickyHeader.sticky_height;
2316							if ( 'undefined' == typeof ( theme.StickyHeader.sticky_height ) ) {
2317								$sticky_product_obj.data( 'prev-pos', 0 );
2318							} else {
2319								// The transition of Sticky isn't working in this area
2320								var $transitionOffset = ( offset > 100 ) ? offset : 100;
2321								if ( $( 'form.cart' ).offset().top + $sticky_product_obj.outerHeight() + $transitionOffset < scrollTop + offset + scrollUpOffset ) {
2322									$sticky_product_obj.addClass( 'sticky-ready' );
2323								} else {
2324									$sticky_product_obj.removeClass( 'sticky-ready' );
2325								}
2326								$sticky_product_obj.data( 'prev-pos', scrollTop );
2327							}
2328						}
2329
2330						var porto_progress_obj = $( '.porto-scroll-progress.fixed-top.fixed-under-header' );
2331						if ( porto_progress_obj.length > 0 ) {
2332							offset += porto_progress_obj.height();
2333						}
2334
2335						$sticky_product_obj.removeClass( 'hide' );
2336						if ( !$sticky_product_obj.hasClass( 'pos-bottom' ) ) {
2337							$sticky_product_obj.css( 'top', offset );
2338						} else if ( $sticky_product_obj.hasClass( 'show-mobile' ) || ( ! $sticky_product_obj.hasClass( 'show-mobile' ) && $( window ).width() >= 768 ) ) {
2339							$( 'body' ).css( 'padding-bottom', $sticky_product_obj.outerHeight() );
2340						}
2341					} else {
2342						$sticky_product_obj.addClass( 'hide' );
2343						if ( $sticky_product_obj.hasClass( 'pos-bottom' ) && ( $sticky_product_obj.hasClass( 'show-mobile' ) || ( ! $sticky_product_obj.hasClass( 'show-mobile' ) && $( window ).width() >= 768 ) ) ) {
2344							$( 'body' ).css( 'padding-bottom', '' );
2345						}
2346					}
2347				}, { passive: true } );
2348				$sticky_product_obj.find( '.add-to-cart .button' ).on( 'click', function( e ) {
2349					e.preventDefault();
2350					if ( $sticky_product_obj.find( '.add-to-cart .qty' ).length ) {
2351						$( '.single-product form .quantity .qty' ).filter(function() {
2352							if ( $( this ).closest( '.product-col' ).length ) {
2353								return false;
2354							}
2355							return true;
2356						}).val( $sticky_product_obj.find( '.add-to-cart .qty' ).val() );
2357					}
2358					$( '.single-product form .single_add_to_cart_button' ).filter(function() {
2359						if ( $( this ).closest( '.product-col' ).length ) {
2360							return false;
2361						}
2362						return true;
2363					}).eq(0).trigger( 'click' );
2364				} );
2365				$( '.single-product .entry-summary .quantity' ).clone().prependTo( '.single-product .sticky-product .add-to-cart' );
2366
2367				var origin_img = $sticky_product_obj.find( '.sticky-image img' ).data( 'oi' ) ? $sticky_product_obj.find( '.sticky-image img' ).data( 'oi' ) : $sticky_product_obj.find( '.sticky-image img' ).attr( 'src' ),
2368					origin_price = $sticky_product_obj.find( '.price' ).html(),
2369					origin_stock = $sticky_product_obj.find( '.availability' ).html(),
2370					is_variation = false;
2371				$( document ).on( 'found_variation reset_data', '.variations_form', function( e, obj ) {
2372					if ( $( e.currentTarget ).closest( '.product-col' ).length == 0 ) {
2373						if ( obj ) {
2374							is_variation = true;
2375							$sticky_product_obj.find( '.sticky-image img' ).attr( 'src', obj.image_thumb ? obj.image_thumb : origin_img );
2376							$sticky_product_obj.find( '.price' ).replaceWith( obj.price_html );
2377							$sticky_product_obj.find( '.availability' ).html( obj.availability_html ? obj.availability_html : origin_stock );
2378						} else if ( is_variation ) {
2379							is_variation = false;
2380							$sticky_product_obj.find( '.sticky-image img' ).attr( 'src', origin_img );
2381							$sticky_product_obj.find( '.price' ).html( origin_price );
2382							$sticky_product_obj.find( '.availability' ).html( origin_stock );
2383						}
2384					}
2385				} );
2386			};
2387
2388			if ( $sticky_product_obj.length || is_elementor_editor ) {
2389				init_sticky_add_to_cart_fn( $sticky_product_obj, is_elementor_editor );
2390			} else if ( $( 'div.product.skeleton-loading' ).length ) {
2391				$( 'div.product.skeleton-loading' ).on( 'skeleton-loaded', function() {
2392					$sticky_product_obj = $( '.single-product .sticky-product' );
2393					init_sticky_add_to_cart_fn( $sticky_product_obj, is_elementor_editor );
2394				} );
2395			} else {
2396				$( document.body ).on( 'porto_elementor_editor_init', function() {
2397					var $sticky_product_obj = $( '.single-product .sticky-product' ),
2398						is_elementor_editor = $( document.body ).hasClass( 'elementor-editor-active' );
2399					if ( $sticky_product_obj.length || is_elementor_editor ) {
2400						init_sticky_add_to_cart_fn( $sticky_product_obj, is_elementor_editor );
2401					}
2402				} );
2403			}
2404
2405			// sticky filter on mobile
2406			if ( 1 === $( '.shop-loop-before' ).length ) {
2407				var porto_progress_obj = $( '.porto-scroll-progress.fixed-top.fixed-under-header' ),
2408					porto_progress_height = 0;
2409				if ( porto_progress_obj.length > 0 ) {
2410					var flag = false;
2411					if ( porto_progress_obj.is( ':hidden' ) ) {
2412						porto_progress_obj.show();
2413						flag = true;
2414					}
2415					porto_progress_height = porto_progress_obj.height();
2416					if ( flag ) {
2417						porto_progress_obj.hide();
2418					}
2419				} else {
2420					porto_progress_height = 0;
2421				}
2422
2423				var init_filter_sticky = function() {
2424					var $obj = $( '.shop-loop-before' ),
2425						prevScrollPos = $obj.data('prev-pos') ? $obj.data('prev-pos') : 0,
2426						scrollUpOffset = 0,
2427						$pageWrapper = $( '.page-wrapper' );
2428					if ( 'none' == $obj.css( 'display' ) ) {
2429						// Found Nothing
2430						return;
2431					}
2432					if ( !$obj.prev( '.filter-placeholder' ).length ) {
2433						$( '<div class="filter-placeholder m-0"></div>' ).insertBefore( $obj );
2434					}
2435					var $ph = $obj.prev( '.filter-placeholder' ),
2436						scrollTop = $( window ).scrollTop(),
2437						offset = theme.adminBarHeight() + theme.StickyHeader.sticky_height + porto_progress_height - 1,
2438						objHeight = $obj.outerHeight() + parseInt( $obj.css( 'margin-bottom' ) );
2439					if ( $( '.page-wrapper' ).hasClass( 'sticky-scroll-up' ) ) {
2440						if ( scrollTop >= prevScrollPos ) {
2441							$obj.addClass('scroll-down');
2442						} else {
2443							$obj.removeClass('scroll-down');
2444						}
2445						// Header is scroll-up Sticky Type
2446						scrollUpOffset = - theme.StickyHeader.sticky_height;
2447						if ( 'undefined' == typeof ( theme.StickyHeader.sticky_height ) ) {
2448							$obj.data( 'prev-pos', 0 );
2449						} else {
2450							// The transition of Sticky isn't working in this area
2451							var $transitionOffset = ( offset > 100 ) ? offset : 100;
2452							if ( $ph.offset().top + objHeight + $transitionOffset < scrollTop + offset + scrollUpOffset ) {
2453								$obj.addClass( 'sticky-ready' );
2454							} else {
2455								$obj.removeClass( 'sticky-ready' );
2456							}
2457							$obj.data( 'prev-pos', scrollTop );
2458						}
2459					}
2460					// if ( $( 'html.filter-sidebar-opened' ).length ) {
2461					// 	$ph.css( 'height', '' );
2462					// 	return;
2463					// }
2464					if ( ( $ph.offset().top + objHeight < scrollTop + offset + scrollUpOffset ) ) {
2465						if ( ! $pageWrapper.hasClass( 'sticky-scroll-up' ) || ( $pageWrapper.hasClass( 'sticky-scroll-up' ) && 0 !== prevScrollPos ) ) {
2466							$ph.css( 'height', objHeight );
2467							$obj.css( 'top', offset );
2468							$obj.addClass( 'sticky' );
2469						}
2470					} else {
2471						$ph.css( 'height', '' );
2472						$obj.removeClass( 'sticky' ).css( 'top', '' );
2473					}
2474				};
2475				if ( window.innerWidth < 992 ) {
2476					window.removeEventListener( 'scroll', init_filter_sticky );
2477					window.addEventListener( 'scroll', init_filter_sticky, { passive: true } );
2478					init_filter_sticky();
2479				}
2480				var request_timer = null,
2481					old_win_width = window.innerWidth;
2482				$( window ).on( 'resize', function() {
2483					if ( old_win_width != window.innerWidth ) {
2484						if ( request_timer ) {
2485							theme.deleteTimeout( request_timer );
2486							request_timer = false;
2487						}
2488						if ( window.innerWidth < 992 ) {
2489							request_timer = theme.requestTimeout( function() {
2490								window.removeEventListener( 'scroll', init_filter_sticky );
2491								window.addEventListener( 'scroll', init_filter_sticky, { passive: true } );
2492								$( window ).trigger( 'scroll' );
2493							}, 100 );
2494						} else {
2495							window.removeEventListener( 'scroll', init_filter_sticky );
2496							$( '.shop-loop-before' ).removeClass( 'sticky' ).css( 'top', '' ).prev( '.filter-placeholder' ).css( 'height', '' );
2497						}
2498
2499						if ( $sticky_product_obj.length ) {
2500							$sticky_product_form = $( 'form.cart:visible' ).eq(0);
2501						}
2502						old_win_width = window.innerWidth;
2503					}
2504				} );
2505			}
2506		}
2507		if ( theme.isReady ) { // Finish init
2508			stickyShop();
2509		}
2510		$( document ).on( 'porto_theme_init', stickyShop );
2511
2512		// cart page accordion
2513		$( '.cart-v2 .cart_totals .accordion-toggle.out' ).removeClass( 'out' );
2514		$( document ).ajaxComplete( function( event, xhr, options ) {
2515			$( '.cart-v2 .cart_totals .accordion-toggle.out' ).each( function() {
2516				if ( $( $( this ).attr( 'href' ) ).length && $( $( this ).attr( 'href' ) ).is( ':hidden' ) ) {
2517					$( this ).removeClass( 'collapsed' );
2518					$( $( this ).attr( 'href' ) ).addClass( 'show' );
2519				}
2520			} );
2521		} );
2522
2523		// porto products filter element
2524		$( '.porto_products_filter_form .btn-submit' ).on( 'click', function( e ) {
2525			e.preventDefault();
2526			var data = $( this ).closest( 'form' ).serializeArray(),
2527				submit_data = '';
2528			for ( var i in data ) {
2529				var param = data[i];
2530				if ( param.value ) {
2531					if ( submit_data ) {
2532						submit_data += '&';
2533					}
2534					submit_data += param.name + '=' + param.value;
2535					if ( 'min_price' == param.name ) {
2536						var max_price = $( this ).closest( 'form' ).find( '.porto_dropdown_price_range option:selected' ).data( 'maxprice' );
2537						if ( max_price ) {
2538							submit_data += '&max_price=' + max_price;
2539						}
2540					}
2541				}
2542			}
2543			var action_url = $( this ).closest( 'form' ).attr( 'action' );
2544			location.href = action_url + ( -1 === action_url.indexOf( '?' ) ? '?' : '&' ) + submit_data;
2545		} );
2546
2547		// yith wishlist
2548		if ( $( '.wishlist_table.responsive' ).length ) {
2549			$( window ).on( 'resize', function() {
2550				var media = window.matchMedia( '(max-width: 768px)' ),
2551					$wishlist_table = $( '.wishlist_table.responsive' );
2552				if ( $wishlist_table.hasClass( 'traditional' ) ) {
2553					if ( media.matches ) {
2554						$wishlist_table.addClass( 'mobile' );
2555					} else {
2556						$wishlist_table.removeClass( 'mobile' );
2557					}
2558				}
2559			} );
2560		}
2561
2562		// pre-order
2563		if ( js_porto_vars.pre_order ) {
2564			var porto_pre_order = {
2565				init: function() {
2566					this.$add_to_cart_btn = $( '.product-summary-wrap .single_add_to_cart_button:not(.wpcbn-btn)' );
2567					this.add_to_cart_label = this.$add_to_cart_btn.html();
2568					$( '.product-summary-wrap form.variations_form' ).on( 'show_variation', function( e, v, p ) {
2569						if ( v.porto_pre_order ) {
2570							porto_pre_order.$add_to_cart_btn.html( v.porto_pre_order_label );
2571							if ( v.porto_pre_order_date ) {
2572								$( this ).find( '.woocommerce-variation-description' ).append( v.porto_pre_order_date );
2573							}
2574						} else {
2575							porto_pre_order.$add_to_cart_btn.html( porto_pre_order.add_to_cart_label );
2576						}
2577					} ).on( 'hide_variation', function() {
2578						porto_pre_order.$add_to_cart_btn.html( porto_pre_order.add_to_cart_label );
2579					} );
2580				}
2581			};
2582			if ( $( 'div.product.skeleton-loading' ).length ) {
2583				$( 'div.product.skeleton-loading' ).on( 'skeleton-loaded', function() {
2584					porto_pre_order.init();
2585				} );
2586			} else {
2587				porto_pre_order.init();
2588			}
2589		}
2590
2591		// refresh yith wishlist
2592		if ( $( '#header .my-wishlist .wishlist-count' ).length ) {
2593			$( document.body ).on( 'added_to_wishlist removed_from_wishlist added_to_cart', function( e ) {
2594				var $obj = $( '#header .my-wishlist .wishlist-count' );
2595				if ( $obj.text() ) {
2596					$.ajax( {
2597						type: 'POST',
2598						dataType: 'json',
2599						url: theme.ajax_url,
2600						data: {
2601							action: 'porto_refresh_wishlist_count',
2602							nonce: js_porto_vars.porto_nonce,
2603						},
2604						success: function( response ) {
2605							if ( response || 0 === response ) {
2606								$obj.addClass( 'count-updating' ).text( Number( response ) );
2607								setTimeout( function() {
2608									$obj.removeClass( 'count-updating' );
2609								}, 1000 );
2610							}
2611						}
2612					} );
2613				}
2614			} );
2615		}
2616
2617		// fix contact form 7 role="alert" issue in cart page
2618		if ( $( document.body ).hasClass( 'woocommerce-cart' ) && $( '.wpcf7 .screen-reader-response' ).length ) {
2619			$( '.wpcf7 .screen-reader-response' ).attr( 'role', '' );
2620		}
2621
2622		// fix dokan search vendor
2623		$( '#dokan-store-listing-filter-form-wrap .store-search-input' ).on( 'keydown', function( e ) {
2624			if ( e.which && event.which == 13 ) {
2625				$( this ).closest( 'form' ).find( '#apply-filter-btn' ).trigger( 'click' );
2626				e.preventDefault();
2627			}
2628		} );
2629
2630		// add spinner to block
2631		if ( $.fn.block ) {
2632			var funcBlock = $.fn.block;
2633			$.fn.block = function( opts ) {
2634				if ( this.hasClass( 'yith-wcwl-add-to-wishlist' ) ) {
2635					this.children().addClass( 'pe-none opacity-6' );
2636					return this;
2637				}
2638				if ( this.is( '.woocommerce-checkout' ) ) {
2639					this.append( '<div class="loader-container d-block"><div class="loader"><i class="porto-ajax-loader"></i></div></div>' );
2640				}
2641				return funcBlock.call( this, opts );
2642			}
2643
2644			var funcUnblock = $.fn.unblock;
2645			$.fn.unblock = function( opts ) {
2646				if ( this.hasClass( 'yith-wcwl-add-to-wishlist' ) ) {
2647					this.children().removeClass( 'pe-none opacity-6' );
2648					return this;
2649				}
2650				funcUnblock.call( this, opts );
2651				this.is( '.processing' ) || ( this.is( '.woocommerce-checkout' ) && this.children( '.loader-container' ).remove() );
2652				return this;
2653			}
2654		}
2655		$( 'body' ).on( 'click', '.single_add_to_cart_button.scroll-to-sticky', function (e) {
2656			$( 'html, body' ).animate(
2657				{ scrollTop: $( 'form.cart' ).offset().top - 200 }
2658			);
2659		} )
2660	} )( window.theme, jQuery );
2661
2662	// Compare
2663	( function( theme, $ ) {
2664		// remove margin-right
2665		$( 'body' ).on( 'click', '.yith_woocompare_colorbox #cboxClose, #cboxOverlay', function() {
2666			$( 'html' ).css( { 'overflow': '', 'margin-right': '' } );
2667		} );
2668	} )( window.theme, window.jQuery );
2669
2670} )();
2671
2672function porto_woocommerce_init( $wrap ) {
2673	'use strict';
2674
2675	if ( !$wrap ) {
2676		$wrap = jQuery( document.body );
2677	}
2678	// Woo Widget Toggle
2679	( function( $ ) {
2680
2681		if ( $.fn.themeWooWidgetToggle ) {
2682
2683			$( function() {
2684				$wrap.find( '.widget_filter_by_brand, .widget_product_categories, .widget_price_filter, .widget_layered_nav, .widget_layered_nav_filters, .widget_rating_filter, .widget-woof, .porto_widget_price_filter, #wcfmmp-store .widget.sidebar-box, #wcfmmp-store-lists-sidebar .sidebar-box' ).find( '.widget-title' ).each( function() {
2685					var $this = $( this ),
2686						opts;
2687
2688					var pluginOptions = $this.data( 'plugin-options' );
2689					if ( pluginOptions )
2690						opts = pluginOptions;
2691
2692					$this.themeWooWidgetToggle( opts );
2693				} );
2694			} );
2695
2696		}
2697
2698		// Woo Widget Accordion
2699		if ( $.fn.themeWooWidgetAccordion ) {
2700
2701			$( function() {
2702				$wrap.find( '.widget_filter_by_brand, .widget_product_categories, .widget_price_filter, .widget_layered_nav, .widget_layered_nav_filters, .widget_rating_filter, .widget-woof, #wcfmmp-store .widget.sidebar-box, #wcfmmp-store-lists-sidebar .sidebar-box' ).each( function() {
2703					var $this = $( this ),
2704						opts;
2705
2706					var pluginOptions = $this.data( 'plugin-options' );
2707					if ( pluginOptions )
2708						opts = pluginOptions;
2709
2710					$this.themeWooWidgetAccordion( opts );
2711				} );
2712			} );
2713
2714		}
2715
2716		// Woo Products Slider
2717		if ( $.fn.themeWooProductsSlider ) {
2718
2719			$( function() {
2720				var $direct_carousels = $wrap.find( '.products-slider:not(.manual)' ).filter( function() {
2721					if ( $( this ).closest( '.porto-carousel:not(.owl-loaded)' ).length ) {
2722						return false;
2723					}
2724					return true;
2725				} );
2726				var $parent_carousel = $wrap.find( '.porto-carousel:not(.owl-loaded)' ).filter( function() {
2727					if ( $( this ).find( '.products-slider:not(.manual)' ).length ) {
2728						return true;
2729					}
2730					return false;
2731				} );
2732				if ( $parent_carousel.length ) {
2733					$parent_carousel.one( 'initialized.owl.carousel', function() {
2734						$( this ).find( '.products-slider:not(.manual)' ).each( function() {
2735							var $this = $( this );
2736							$this.themeWooProductsSlider( $this.data( 'plugin-options' ) );
2737						} );
2738					} );
2739				}
2740
2741				$direct_carousels.each( function() {
2742					var $this = $( this ),
2743						opts;
2744
2745					var pluginOptions = $this.data( 'plugin-options' );
2746					if ( pluginOptions )
2747						opts = pluginOptions;
2748
2749					setTimeout( function() {
2750						$this.themeWooProductsSlider( opts );
2751					}, 0 );
2752				} );
2753			} );
2754		}
2755
2756		/*===================================================================================*/
2757		/*  TOOLTIP FOR YITH WISHLIST, COMPARE, ADD TO CART, QUICK VIEW
2758		/*===================================================================================*/
2759		if ( ! theme.isMobile() ) {
2760			$wrap.find( '.product-col .quickview, .product-col .add_to_cart_read_more, .product-col .add_to_cart_button, .product-col a.compare, .product-col .add_to_wishlist, .product-col .yith-wcwl-wishlistaddedbrowse > a, .product-col .yith-wcwl-wishlistexistsbrowse > a' ).each( function() {
2761				let _this = $( this );
2762				// Exclude
2763				let $productCol = _this.closest( '.product-col' );
2764				if ( _this.closest( '.porto-tb-woo-link' ).hasClass( 'no-tooltip' ) ) {
2765					return;
2766				}
2767				if ( _this.hasClass( 'add_to_cart_read_more' ) || _this.hasClass( 'add_to_cart_button' ) ) {
2768					if ( $productCol.hasClass( 'product-wq_onimage' ) || $productCol.hasClass( 'product-onimage' ) || $productCol.hasClass( 'product-outimage' ) || $productCol.hasClass( 'product-default' ) ) {
2769						return;
2770					}
2771					if ( _this.closest( 'ul.products' ).hasClass( 'list' ) ) {
2772						return;
2773					}
2774				}
2775				if ( _this.hasClass( 'quickview' ) ) {
2776					if ( $productCol.hasClass( 'product-wq_onimage' ) || $productCol.hasClass( 'product-onimage3' ) || $productCol.hasClass( 'product-onimage2' ) || $productCol.hasClass( 'product-onimage' ) || $productCol.hasClass( 'product-outimage_aq_onimage' ) ) {
2777						return;
2778					}
2779				}
2780				if ( ! _this.attr( 'title' ) ) {
2781					_this.attr( 'title', _this.text().trim() );
2782				}
2783				_this.tooltip();
2784			} );
2785		}
2786
2787	} )( jQuery );
2788}
2789
2790function porto_woocommerce_variations_init( $parent_obj ) {
2791	'use strict';
2792
2793	theme.requestTimeout( function() {
2794		var form_variation = $parent_obj.find( 'form.variations_form:not(.vf_init)' );
2795		if ( form_variation.length && jQuery.fn.wc_variation_form ) {
2796			form_variation.each( function() {
2797				var data_a = jQuery._data( this, 'events' );
2798				if ( !data_a || !data_a['show_variation'] ) {
2799					jQuery( this ).wc_variation_form();
2800				}
2801			} );
2802		}
2803	}, 100 );
2804}
2805function porto_ajax_load_products( $obj, data, pagination_style, $ajax_tab_cache, id, group ) {
2806	'use strict';
2807	( function( $ ) {
2808		if ( $obj.hasClass( 'loading' ) ) {
2809			return;
2810		}
2811		$obj.addClass( 'loading' );
2812		if ( 'load_more' != pagination_style ) {
2813			$obj.addClass( 'yith-wcan-loading' );
2814			if ( !$obj.children( '.porto-loading-icon' ).length ) {
2815				$obj.append( '<i class="porto-loading-icon"></i>' );
2816			}
2817		}
2818		if ( $ajax_tab_cache[id] == undefined ) {
2819			$ajax_tab_cache[id] = {};
2820		}
2821		$.ajax( {
2822			url: theme.ajax_url,
2823			data: data,
2824			type: 'post',
2825			success: function( response ) {
2826				//cache
2827				if ( $( response ).length ) {
2828					$ajax_tab_cache[id][group] = $( response ).html();
2829				} else {
2830					$ajax_tab_cache[id][group] = '';
2831				}
2832				porto_ajax_load_products_success( $obj, response, pagination_style );
2833			},
2834			complete: function() {
2835				$obj.removeClass( 'loading' );
2836			}
2837		} );
2838	} )( jQuery );
2839}
2840
2841function porto_ajax_load_products_success( $obj, success, pagination_style ) {
2842	'use strict';
2843
2844	( function( $ ) {
2845		let _successProducts = $( success ).find( 'ul.products' );
2846		if ( $obj.data( 'cur_page' ) && _successProducts.data( 'cur_page' ) ) {
2847			$obj.data( 'cur_page', _successProducts.data( 'cur_page' ) );
2848		}
2849		if ( ! ( $obj.hasClass( 'grid-creative' ) && typeof $obj.attr( 'data-plugin-masonry' ) != 'undefined' ) ) {
2850			_successProducts.children( ':not(.grid-col-sizer)' ).addClass( 'fadeInUp animated' );
2851		}
2852		if ( 'load_more' == pagination_style ) {
2853			$obj.append( _successProducts.html() );
2854		} else {
2855			if ( $obj.hasClass( 'owl-carousel' ) ) {
2856				$obj.parent().css( 'min-height', $obj.parent().height() );
2857			}
2858			if ( $obj.hasClass( 'grid-creative' ) && typeof $obj.attr( 'data-plugin-masonry' ) != 'undefined' ) {
2859				$obj.isotope( 'remove', $obj.children() );
2860				$obj.find( '.grid-col-sizer' ).remove();
2861				var newItems = _successProducts.children();
2862				$obj.append( newItems );
2863				$obj.isotope( 'appended', newItems );
2864				$obj.imagesLoaded( function() {
2865					$obj.isotope( 'layout' );
2866				} );
2867			} else {
2868				if ( $( success ).length ) {
2869					$obj.html( _successProducts.html() );
2870				} else {
2871					$obj.html( '' );
2872				}
2873			}
2874		}
2875
2876		if ( $obj.hasClass( 'owl-carousel' ) && $.fn.themeWooProductsSlider ) {
2877			$obj.trigger( 'destroy.owl.carousel' );
2878			theme.requestTimeout( function() {
2879				var pluginOptions = $obj.data( 'plugin-options' ), opts;
2880				if ( pluginOptions )
2881					opts = pluginOptions;
2882				$obj.data( '__wooProductsSlider', '' ).themeWooProductsSlider( opts );
2883				$obj.parent().css( 'min-height', '' );
2884			}, 100 );
2885		}
2886		if ( $obj.closest( '.porto-products' ).find( '.shop-loop-after' ).length ) {
2887			if ( $( success ).find( '.shop-loop-after' ).length ) {
2888				$obj.closest( '.porto-products' ).find( '.shop-loop-after' ).replaceWith( $( success ).find( '.shop-loop-after' ) );
2889			} else {
2890				$obj.closest( '.porto-products' ).find( '.shop-loop-after' ).remove();
2891			}
2892		}
2893		if ( typeof $obj.data( 'infinitescroll' ) != 'undefined' ) {
2894			var infinitescrollData = $obj.data( 'infinitescroll' );
2895			infinitescrollData.options.state.currPage = 1;
2896			$obj.data( 'infinitescroll', infinitescrollData );
2897		}
2898		$obj.removeClass( 'yith-wcan-loading' );
2899		if ( 'load_more' == pagination_style && typeof $obj != 'undefined' && typeof $obj.data( 'text' ) != 'undefined' ) {
2900			$obj.text( $obj.data( 'text' ) );
2901		}
2902		$( document ).trigger( "yith-wcan-ajax-filtered" );
2903	} )( jQuery );
2904}

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.