PageSourceSearch

https://ppmadrid.es/wp-content/themes/porto/js/woocommerce-theme.js?ver=6.4.1

js ppmadrid.es collected 2026-10-02 12:57:27 UTC 131,380 bytes, 3,526 lines download raw bytes

1( function () {
2	'use strict';
3
4	// Theme Functions
5	function portoCalcSliderButtonsPosition( $parent, padding ) {
6		var $buttons = $parent.find( '.show-nav-title .owl-nav' );
7		if ( $buttons.length ) {
8			if ( window.theme.rtl ) {
9				$buttons.css( 'left', padding );
10			} else {
11				$buttons.css( 'right', padding );
12			}
13			if ( $buttons.closest( '.porto-products' ).length && $buttons.closest( '.porto-products' ).parent().children( '.products-slider-title' ).length ) {
14				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 );
15				$buttons.css( 'margin-top', newMT );
16			}
17		}
18	}
19
20	// Woocommerce Widget Toggle
21	( function ( theme, $ ) {
22
23		theme = theme || {};
24
25		var instanceName = '__wooWidgetToggle';
26
27		var WooWidgetToggle = function ( $el, opts ) {
28			return this.initialize( $el, opts );
29		};
30
31		WooWidgetToggle.defaults = {
32
33		};
34
35		WooWidgetToggle.prototype = {
36			initialize: function ( $el, opts ) {
37				if ( $el.data( instanceName ) ) {
38					return this;
39				}
40
41				this.$el = $el;
42
43				this
44					.setData()
45					.setOptions( opts )
46					.build();
47
48				return this;
49			},
50
51			setData: function () {
52				this.$el.data( instanceName, this );
53
54				return this;
55			},
56
57			setOptions: function ( opts ) {
58				this.options = $.extend( true, {}, WooWidgetToggle.defaults, opts, {
59					wrapper: this.$el
60				} );
61
62				return this;
63			},
64
65			build: function () {
66				var $el = this.options.wrapper;
67
68				$el.parent().removeClass( 'closed' );
69				if ( !$el.find( '.toggle' ).length ) {
70					$el.append( '<span class="toggle"></span>' );
71				}
72				$el.find( '.toggle' ).on( 'click', function () {
73					if ( $el.next().is( ":visible" ) ) {
74						$el.parent().addClass( 'closed' );
75					} else {
76						$el.parent().removeClass( 'closed' );
77					}
78					$el.next().stop().slideToggle( 200 );
79					theme.refreshVCContent();
80				} );
81
82				return this;
83			}
84		};
85
86		// expose to scope
87		$.extend( theme, {
88			WooWidgetToggle: WooWidgetToggle
89		} );
90
91		// jquery plugin
92		$.fn.themeWooWidgetToggle = function ( opts ) {
93			return this.map( function () {
94				var $this = $( this );
95
96				if ( $this.data( instanceName ) ) {
97					return $this.data( instanceName );
98				} else {
99					return new theme.WooWidgetToggle( $this, opts );
100				}
101
102			} );
103		}
104
105	} ).apply( this, [ window.theme, jQuery ] );
106
107
108	// Woocommerce Widget Accordion
109	( function ( theme, $ ) {
110
111		theme = theme || {};
112
113		var instanceName = '__wooWidgetAccordion';
114
115		var WooWidgetAccordion = function ( $el, opts ) {
116			return this.initialize( $el, opts );
117		};
118
119		WooWidgetAccordion.defaults = {
120
121		};
122
123		WooWidgetAccordion.prototype = {
124			initialize: function ( $el, opts ) {
125				if ( $el.data( instanceName ) ) {
126					return this;
127				}
128
129				this.$el = $el;
130
131				this
132					.setData()
133					.setOptions( opts )
134					.build();
135
136				return this;
137			},
138
139			setData: function () {
140				this.$el.data( instanceName, this );
141
142				return this;
143			},
144
145			setOptions: function ( opts ) {
146				this.options = $.extend( true, {}, WooWidgetAccordion.defaults, opts, {
147					wrapper: this.$el
148				} );
149
150				return this;
151			},
152
153			build: function () {
154				var self = this,
155					$el = this.options.wrapper;
156
157				$el.find( 'ul.children' ).each( function () {
158					var $this = $( this );
159					if ( !$this.prev().hasClass( 'toggle' ) ) {
160						$this.before(
161							$( '<span class="toggle"></span>' ).on( 'click', function () {
162								var $that = $( this );
163								if ( $that.next().is( ":visible" ) ) {
164									$that.parent().removeClass( 'open' ).addClass( 'closed' );
165								} else {
166									$that.parent().addClass( 'open' ).removeClass( 'closed' );
167								}
168								$that.next().stop().slideToggle( 200 );
169								theme.refreshVCContent();
170							} )
171						);
172					}
173				} );
174				$el.find( 'li[class*="current-"]' ).addClass( 'current' );
175
176				return this;
177			}
178		};
179
180		// expose to scope
181		$.extend( theme, {
182			WooWidgetAccordion: WooWidgetAccordion
183		} );
184
185		// jquery plugin
186		$.fn.themeWooWidgetAccordion = function ( opts ) {
187			return this.map( function () {
188				var $this = $( this );
189
190				if ( $this.data( instanceName ) ) {
191					return $this.data( instanceName );
192				} else {
193					return new theme.WooWidgetAccordion( $this, opts );
194				}
195
196			} );
197		}
198
199	} ).apply( this, [ window.theme, jQuery ] );
200
201	// Woocommerce Products Slider
202	if ( typeof jQuery.fn.owlCarousel == 'function' ) {
203		( function ( theme, $ ) {
204
205			theme = theme || {};
206
207			var instanceName = '__wooProductsSlider';
208
209			var WooProductsSlider = function ( $el, opts ) {
210				return this.initialize( $el, opts );
211			};
212
213			WooProductsSlider.defaults = {
214				rtl: theme.rtl,
215				autoplay: theme.slider_autoplay == '1' ? true : false,
216				autoplayTimeout: theme.slider_speed ? theme.slider_speed : 5000,
217				loop: theme.slider_loop,
218				nav: false,
219				navText: [ "", "" ],
220				dots: false,
221				autoplayHoverPause: true,
222				items: 1,
223				responsive: {},
224				autoHeight: true,
225				lazyLoad: true
226			};
227
228			WooProductsSlider.prototype = {
229				initialize: function ( $el, opts ) {
230					if ( $el.data( instanceName ) ) {
231						return this;
232					}
233
234					this.$el = $el;
235
236					this
237						.setData()
238						.setOptions( opts )
239						.build();
240
241					return this;
242				},
243
244				setData: function () {
245					this.$el.data( instanceName, true );
246
247					return this;
248				},
249
250				setOptions: function ( opts ) {
251					this.options = $.extend( true, {}, WooProductsSlider.defaults, opts, {
252						wrapper: this.$el
253					} );
254
255					return this;
256				},
257
258				calcOwlHeight: function ( $el ) {
259					var h = 0;
260					$el.find( '.owl-item.active' ).each( function () {
261						if ( h < $( this ).height() )
262							h = $( this ).height();
263					} );
264					$el.find( '.owl-stage-outer' ).height( h );
265				},
266
267				build: function () {
268					var self = this,
269						$el = this.options.wrapper,
270						lg = this.options.lg,
271						md = this.options.md,
272						xs = this.options.xs,
273						ls = this.options.ls,
274						$slider_wrapper = $el.closest( '.slider-wrapper' ),
275						single = this.options.single,
276						dots = this.options.dots,
277						nav = this.options.nav,
278						responsive = {},
279						items,
280						// scrollwidth = 0 not using getscrollbarwidth
281						scrollWidth = 0,
282						count = $el.find( '> *' ).length,
283						w_xs = 576 - scrollWidth,
284						w_md = 768 - scrollWidth,
285						w_lg = parseInt( js_porto_vars.screen_lg ) - scrollWidth,
286						w_sl = 1400 - scrollWidth;
287
288					if ( $el.find( '.product-col' ).get( 0 ) ) {
289						portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) );
290					}
291
292					if ( single ) {
293						items = 1;
294					} else {
295						items = lg ? lg : 1;
296						if ( this.options.xl ) {
297							responsive[ w_sl ] = { items: this.options.xl, loop: ( this.options.loop && count > this.options.xl ) ? true : false };
298						}
299						responsive[ w_lg ] = { items: items, loop: ( this.options.loop && count > items ) ? true : false };
300						if ( md ) responsive[ w_md ] = { items: md, loop: ( this.options.loop && count > md ) ? true : false };
301						if ( xs ) responsive[ w_xs ] = { items: xs, loop: ( this.options.loop && count > xs ) ? true : false };
302						if ( ls ) responsive[ 0 ] = { items: ls, loop: ( this.options.loop && count > ls ) ? true : false };
303					}
304
305					this.options = $.extend( true, {}, this.options, {
306						loop: ( this.options.loop && count > items ) ? true : false,
307						items: items,
308						responsive: responsive,
309						onRefresh: function () {
310							if ( $el.find( '.product-col' ).get( 0 ) ) {
311								portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) );
312							}
313						},
314						onInitialized: function () {
315							if ( $el.find( '.product-col' ).get( 0 ) ) {
316								portoCalcSliderButtonsPosition( $slider_wrapper, $el.find( '.product-col' ).css( 'padding-left' ) );
317							}
318							//$el.find('.cloned .porto-lazyload:not(.lazy-load-loaded)').themePluginLazyLoad();
319
320							if ( $el.find( '.owl-item.cloned' ).length ) {
321								setTimeout( function () {
322									var ins = $el.find( '.owl-item.cloned .porto-lazyload:not(.lazy-load-loaded)' ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } );
323									if ( ins && ins.loadAndDestroy ) {
324										ins.loadAndDestroy();
325									}
326								}, 100 );
327							}
328						},
329						touchDrag: ( count == 1 ) ? false : true,
330						mouseDrag: ( count == 1 ) ? false : true
331					} );
332
333					// Auto Height Fixes
334					if ( this.options.autoHeight ) {
335						var thisobj = this;
336						$( window ).on( 'resize', function () {
337							thisobj.calcOwlHeight( $el );
338						} );
339
340						if ( theme.isLoaded ) {
341							setTimeout( function () {
342								thisobj.calcOwlHeight( $el );
343							}, 100 );
344						} else {
345							$( window ).on( 'load', function () {
346								thisobj.calcOwlHeight( $el );
347							} );
348						}
349					}
350
351					$el.owlCarousel( this.options );
352
353					return this;
354				}
355			};
356
357			// expose to scope
358			$.extend( theme, {
359				WooProductsSlider: WooProductsSlider
360			} );
361
362			// jquery plugin
363			$.fn.themeWooProductsSlider = function ( opts ) {
364				return this.map( function () {
365					var $this = $( this );
366
367					if ( $this.data( instanceName ) ) {
368						return $this;
369					} else {
370						return new theme.WooProductsSlider( $this, opts );
371					}
372
373				} );
374			}
375
376		} ).apply( this, [ window.theme, jQuery ] );
377	}
378
379	// Woocommerce Add to Cart, View Cart Events
380	( function ( theme, $ ) {
381
382		var $supports_html5_storage;
383		try {
384			$supports_html5_storage = ( 'sessionStorage' in window && window.sessionStorage !== null );
385
386			window.sessionStorage.setItem( 'wc', 'test' );
387			window.sessionStorage.removeItem( 'wc' );
388		} catch ( err ) {
389			$supports_html5_storage = false;
390		}
391
392		var setCartCreationTimestamp = function () {
393			if ( $supports_html5_storage ) {
394				sessionStorage.setItem( 'wc_cart_created', ( new Date() ).getTime() );
395			}
396		};
397
398		var setCartHash = function ( cart_hash ) {
399			if ( $supports_html5_storage && wc_cart_fragments_params ) {
400				localStorage.setItem( wc_cart_fragments_params.cart_hash_key, cart_hash );
401				sessionStorage.setItem( wc_cart_fragments_params.cart_hash_key, cart_hash );
402			}
403		};
404
405		var initAjaxRemoveCartItem = function () {
406			$( document ).off( 'click', '.widget_shopping_cart .remove-product, .shop_table.cart .remove-product' ).on( 'click', '.widget_shopping_cart .remove-product, .shop_table.cart .remove-product', function ( e ) {
407				e.preventDefault();
408				var $this = $( this );
409				var cart_id = $this.data( "cart_id" );
410				var product_id = $this.data( "product_id" );
411				$this.closest( 'li' ).find( '.ajax-loading' ).show();
412
413				$.ajax( {
414					type: 'POST',
415					dataType: 'json',
416					url: theme.ajax_url,
417					data: {
418						action: "porto_cart_item_remove",
419						nonce: js_porto_vars.porto_nonce,
420						cart_id: cart_id
421					},
422					success: function ( response ) {
423						var this_page = window.location.toString(),
424							item_count = $( response.fragments[ 'div.widget_shopping_cart_content' ] ).find( '.mini_cart_item' ).length;
425
426						this_page = this_page.replace( 'add-to-cart', 'added-to-cart' );
427						updateCartFragment( response );
428						$( document.body ).trigger( 'wc_fragments_refreshed' );
429						$( '.viewcart-' + product_id ).removeClass( 'added' );
430						$( '.porto_cart_item_' + cart_id ).remove();
431
432						// Block widgets and fragments
433						if ( item_count == 0 && ( $( 'body' ).hasClass( 'woocommerce-cart' ) || $( 'body' ).hasClass( 'woocommerce-checkout' ) ) ) {
434							$( '.page-content' ).fadeTo( 400, 0.8 ).block( {
435								message: null,
436								overlayCSS: {
437									opacity: 0.2
438								}
439							} );
440						} else {
441							$( '.shop_table.cart, .shop_table.review-order, .updating, .cart_totals' ).fadeTo( 400, 0.8 ).block( {
442								message: null,
443								overlayCSS: {
444									opacity: 0.2
445								}
446							} );
447						}
448
449						// Unblock
450						$( '.widget_shopping_cart, .updating' ).stop( true ).css( 'opacity', '1' ).unblock();
451
452						// Cart page elements
453						if ( item_count == 0 && ( $( 'body' ).hasClass( 'woocommerce-cart' ) || $( 'body' ).hasClass( 'woocommerce-checkout' ) ) ) {
454							$( '.page-content' ).load( this_page + ' .page-content:eq(0) > *', function () {
455								$( '.page-content' ).stop( true ).css( 'opacity', '1' ).unblock();
456							} );
457						} else {
458							$( '.shop_table.cart' ).load( this_page + ' .shop_table.cart:eq(0) > *', function () {
459								$( '.shop_table.cart' ).stop( true ).css( 'opacity', '1' ).unblock();
460							} );
461
462							$( '.cart_totals' ).load( this_page + ' .cart_totals:eq(0) > *', function () {
463								$( '.cart_totals' ).stop( true ).css( 'opacity', '1' ).unblock();
464							} );
465
466							// Checkout page elements
467							$( '.shop_table.review-order' ).load( this_page + ' .shop_table.review-order:eq(0) > *', function () {
468								$( '.shop_table.review-order' ).stop( true ).css( 'opacity', '1' ).unblock();
469							} );
470						}
471					}
472				} );
473
474				return false;
475			} );
476		};
477
478		var refreshCartFragment = function () {
479			initAjaxRemoveCartItem();
480			if ( $.cookie( 'woocommerce_items_in_cart' ) > 0 ) {
481				$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show();
482			} else {
483				$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide();
484			}
485		};
486
487		var updateCartFragment = function ( data ) {
488			if ( data && data.fragments ) {
489				var fragments = data.fragments,
490					cart_hash = data.cart_hash;
491
492				$.each( fragments, function ( key, value ) {
493					$( key ).replaceWith( value );
494				} );
495				if ( typeof wc_cart_fragments_params === 'undefined' ) {
496					return;
497				}
498				/* Storage Handling */
499				if ( $supports_html5_storage ) {
500					var prev_cart_hash = sessionStorage.getItem( 'wc_cart_hash' );
501
502					if ( prev_cart_hash === null || prev_cart_hash === undefined || prev_cart_hash === '' ) {
503						setCartCreationTimestamp();
504					}
505					sessionStorage.setItem( wc_cart_fragments_params.fragment_name, JSON.stringify( fragments ) );
506					setCartHash( cart_hash );
507				}
508			}
509		};
510
511		$( function () {
512
513			refreshCartFragment();
514
515			// add ajax cart loading
516			$( document ).on( 'click', '.add_to_cart_button', function ( e ) {
517				var $this = $( this );
518				if ( $this.is( '.product_type_simple' ) ) {
519					if ( $this.attr( 'data-product_id' ) ) {
520						$this.addClass( 'product-adding' );
521					}
522					// add to cart notifaction style 2, 3
523					if ( $this.hasClass( 'viewcart-style-2' ) || $this.hasClass( 'viewcart-style-3' ) ) {
524						$( 'body' ).append( '<div id="loading-mask"><div class="background-overlay"></div></div>' );
525						if ( !$( this ).closest( '.product' ).find( '.loader-container' ).length ) {
526							$( this ).closest( '.product' ).find( '.product-image' ).append( '<div class="loader-container"><div class="loader"><i class="porto-ajax-loader"></i></div></div>' );
527						}
528						$( this ).closest( '.product' ).find( '.loader-container' ).show();
529					}
530				}
531			} );
532
533			// add to cart action
534			$( document ).on( 'click', 'span.add_to_cart_button', function ( e ) {
535				var $this = $( this );
536				if ( $this.is( '.product_type_simple' ) ) {
537					if ( !$this.attr( 'data-product_id' ) ) {
538						window.location.href = $this.attr( 'href' );
539					}
540				} else {
541					window.location.href = $this.attr( 'href' );
542				}
543			} );
544
545			$( 'body' ).on( 'added_to_cart', function () {
546				$( 'ul.products li.product .added_to_cart, .porto-tb-item .added_to_cart' ).remove();
547				initAjaxRemoveCartItem();
548			} );
549
550			$( document.body ).on( 'wc_fragments_refreshed wc_fragments_loaded', function () {
551				refreshCartFragment();
552			} );
553
554			$( document ).on( 'click', '.product-image .viewcart, .after-loading-success-message .viewcart', function ( e ) {
555				if ( wc_add_to_cart_params.cart_url ) {
556					window.location.href = wc_add_to_cart_params.cart_url;
557				}
558				e.preventDefault();
559			} );
560			var porto_product_add_cart_timer = null;
561			$( document ).on( 'added_to_cart', 'body', function ( event ) {
562				var $mc_item = $( '#mini-cart .cart-items' );
563				if ( $mc_item.length ) {
564					$mc_item.addClass( 'count-updating' );
565					setTimeout( function () {
566						$mc_item.removeClass( 'count-updating' );
567					}, 1000 );
568				}
569
570				//add to cart notifaction style 2,3
571				$( 'body #loading-mask' ).remove();
572
573				$( '.add_to_cart_button.product-adding' ).each( function () {
574					var $link = $( this );
575					$link.removeClass( 'product-adding' );
576					if ( $link.hasClass( 'viewcart-style-1' ) ) {
577						$link.closest( '.product' ).find( '.viewcart' ).addClass( 'added' );
578					} else {
579						$link.closest( '.product' ).find( '.loader-container' ).hide();
580						if ( $link.closest( 'li.outofstock' ).length ) {
581							return;
582						}
583						var $msg;
584						if ( $link.hasClass( 'viewcart-style-2' ) ) {
585							$msg = $( '.after-loading-success-message .success-message-container' ).eq( 0 );
586							$msg.find( '.product-name' ).text( $link.closest( '.product' ).find( '.woocommerce-loop-product__title' ).text() );
587						} else {
588							$msg = $( '.after-loading-success-message .success-message-container' ).last().clone().removeClass( 'd-none' );
589							$msg.find( '.product-name' ).empty().append( $link.closest( '.product' ).find( '.product-loop-title, .post-title a' ).clone() );
590						}
591						$msg.find( '.msg-box img' ).remove();
592						if ( $link.closest( '.product' ).find( '.product-image img' ).length ) {
593							var $img = $link.closest( '.product' ).find( '.product-image img' ).eq( 0 );
594							$( '<img />' ).attr( 'src', $img.data( 'oi' ) ? $img.data( 'oi' ) : $img.attr( 'src' ) ).appendTo( $msg.find( '.msg-box' ) );
595						}
596						$( '.after-loading-success-message' ).eq( 0 ).stop().show();
597
598						if ( $link.hasClass( 'viewcart-style-2' ) ) {
599							if ( porto_product_add_cart_timer ) {
600								clearTimeout( porto_product_add_cart_timer );
601							}
602							porto_product_add_cart_timer = setTimeout( function () { $( '.after-loading-success-message' ).eq( 0 ).hide(); }, 4000 );
603						} else {
604							$msg.prependTo( '.after-loading-success-message' );
605							theme.requestFrame( function () {
606								$msg.addClass( 'active' );
607							} );
608							setTimeout( function () { $msg.find( '.mfp-close' ).trigger( 'click' ); }, 5000 );
609						}
610					}
611				} );
612			} );
613
614			$( '.after-loading-success-message .continue_shopping' ).on( 'click', function () {
615				$( '.after-loading-success-message' ).eq( 0 ).fadeOut( 200 );
616			} );
617			$( '.after-loading-success-message' ).on( 'click', '.mfp-close', function () {
618				var $obj = $( this ).closest( '.success-message-container' );
619				$obj.removeClass( 'active' );
620				theme.requestTimeout( function () {
621					$obj.slideUp( 300, function () {
622						$obj.remove();
623					} );
624				}, 350 );
625			} );
626
627			$( document.body ).on( 'click', '.variations_form .variations .filter-item-list .filter-color, .variations_form .variations .filter-item-list .filter-item', function ( e ) {
628				e.preventDefault();
629				var $this = $( this ),
630					$selector = $this.closest( 'ul' ).siblings( 'select' );
631				if ( !$selector.length || $this.hasClass( 'disabled' ) ) {
632					return;
633				}
634				var $li_obj = $this.closest( 'li' );
635				if ( $li_obj.hasClass( 'active' ) ) {
636					$li_obj.removeClass( 'active' );
637					$selector.val( '' );
638				} else {
639					$li_obj.addClass( 'active' ).siblings().removeClass( 'active' );
640					$selector.val( $this.data( 'value' ) );
641				}
642				$selector.trigger( 'change.wc-variation-form' );
643			} );
644			$( document ).on( 'wc_variation_form', '.variations_form', function () {
645				$( this ).addClass( 'vf_init' );
646				if ( $( this ).find( '.filter-item-list' ).length < 1 ) {
647					return;
648				}
649				$( this ).find( '.variations select' ).trigger( 'focusin' );
650			} );
651			$( document ).on( 'updated_wc_div', function () {
652				$( '.woocommerce-cart-form .porto-lazyload' ).themePluginLazyLoad();
653			} );
654			$( document ).on( 'found_variation reset_data', '.variations_form', function ( e, args ) {
655				// attribute description
656				var $this = $( this );
657				if ( $this.find( '.product-attr-description' ).length ) {
658					if ( typeof args == 'undefined' ) {
659						$this.find( '.product-attr-description' ).removeClass( 'active' );
660					} else {
661						$this.find( '.product-attr-description' ).addClass( 'active' );
662						$this.find( '.product-attr-description .attr-desc' ).removeClass( 'active' );
663						$this.find( '.variations select' ).each( function () {
664							var $obj = $( this );
665							$this.find( '.product-attr-description .attr-desc[data-attrid="' + $obj.val() + '"]' ).addClass( 'active' );
666						} );
667					}
668				}
669
670				if ( $this.find( ".filter-item-list" ).length < 1 ) {
671					return;
672				}
673				$this.find( ".filter-item-list" ).each( function () {
674					if ( $( this ).next( "select" ).length < 1 ) {
675						return;
676					}
677					var selector = $( this ).next( "select" ),
678						//html = '',
679						$list = $( this );
680					$list.find( 'li.active' ).removeClass( 'active' );
681					$list.find( '.filter-color, .filter-item' ).removeClass( 'enabled' ).removeClass( 'disabled' );
682					selector.children( "option" ).each( function () {
683						/*var isColor = typeof $(this).data('color') != 'undefined' ? true : false,
684							isImage = typeof $(this).data('image') != 'undefined' ? true : false,
685						spanClass = isColor ? "filter-color" : ( isImage ? "filter-item filter-image" : "filter-item" );*/
686						if ( !$( this ).val() ) {
687							return;
688						}
689						$list.find( '[data-value="' + $( this ).val() + '"]' ).addClass( 'enabled' );
690						if ( $( this ).val() == selector.val() ) {
691							$list.find( '[data-value="' + $( this ).val() + '"]' ).parent().addClass( 'active' );
692						}
693						/*html += '<li';
694						if ($(this).val() == selector.val()) {
695							html += ' class="active"';
696						}
697						html += '><a href="#" data-value="'+ escape( $(this).val() ) +'" class="' + spanClass + '"';
698						if (isColor) {
699							html += ' style="background-color: #' + escape( $(this).data('color').replace('#','') ) + '"';
700						}
701						if (isImage) {
702							html += ' style="background-image:url(' + $(this).data('image') + ')"';
703						}
704						html += '>';
705						if (!isColor) {
706							html += $(this).text();
707						}
708						html += '</a></li>';*/
709					} );
710					$list.find( '.filter-color:not(.enabled), .filter-item:not(.enabled)' ).addClass( 'disabled' );
711					//$(this).html(html);
712				} );
713			} );
714
715			// daily sale
716			$( document ).on( 'found_variation reset_data', '.variations_form', function ( e, obj ) {
717				var $timer = $( this ).closest( '.product' ).find( '.sale-product-daily-deal.for-some-variations' );
718				if ( !$timer.length ) {
719					return;
720				}
721				if ( obj && obj.is_purchasable && typeof obj.porto_date_on_sale_to != 'undefined' && obj.porto_date_on_sale_to ) {
722					var saleTimer = $timer.find( '.porto_countdown-dateAndTime' );
723					if ( saleTimer.data( 'terminal-date' ) != obj.porto_date_on_sale_to ) {
724						var newDate = new Date( obj.porto_date_on_sale_to );
725						saleTimer.porto_countdown( 'option', { until: newDate } );
726						saleTimer.data( 'terminal-date', obj.porto_date_on_sale_to );
727					}
728					$timer.slideDown();
729				} else {
730					if ( $timer.is( ':hidden' ) ) {
731						$timer.hide();
732					} else {
733						$timer.slideUp();
734					}
735				}
736			} );
737
738			$( 'body' ).on( 'click', '.product-attr-description > a', function ( e ) {
739				e.preventDefault();
740				$( this ).next().stop().slideToggle( 400 );
741			} );
742
743			// if product was already added to cart, show check icon in add to cart button and view cart button in single product page
744			if ( $( document.body ).hasClass( 'single-product' ) ) {
745				$( document ).on( 'woocommerce_variation_has_changed', '.variations_form', function ( e, variation ) {
746					$( document.body ).removeClass( 'single-add-to-cart' );
747				} );
748				$( document ).on( 'found_variation', '.variations_form', function ( e, variation ) {
749					try {
750						var cart_items = JSON.parse( sessionStorage.getItem( wc_cart_fragments_params.fragment_name ) );
751						if ( cart_items[ 'div.widget_shopping_cart_content' ] ) {
752							var cart_item = $( cart_items[ 'div.widget_shopping_cart_content' ] ).find( '.porto-variation-' + variation.variation_id );
753							if ( cart_item.length ) {
754								theme.requestFrame( function () {
755									$( document.body ).addClass( 'single-add-to-cart' );
756								} );
757							}
758						}
759					} catch ( e ) {
760					}
761				} );
762			}
763		} );
764
765	} ).apply( this, [ window.theme, jQuery ] );
766
767
768	// Woocommerce Category Filter
769	( function ( theme, $ ) {
770
771		/**
772		 Copyright (c) 2010, All Right Reserved, Wong Shek Hei @ [email protected]
773		 License: GNU Lesser General Public License (http://www.gnu.org/licenses/lgpl.html)
774		 **/
775		var expr = /[.#\w].([\S]*)/g, classexpr = /(?!(\[))(\.)[^.#[]*/g, idexpr = /(#)[^.#[]*/, tagexpr = /^[\w]+/, varexpr = /(\w+?)=(['"])([^\2$]*?)\2/, simpleselector = /^[\w]+$/, parseSelector = function ( d ) {
776			for ( var c = { sel: [], val: [] }, a = [], j = !1, h = "", e = [], f = 0, m = d.length; f < m; f++ ) {
777				var g = d.charAt( f );
778				if ( j ) if ( "\\" === g && f + 1 < d.length ) e.push( d.charAt( ++f ) ); else if ( h === g ) h = "", e.push( g ); else if ( ( "'" === g || '"' === g ) && "" === h ) h = g, e.push( g ); else if ( "]" === g && "" === h ) c.val.push( e.join( "" ) ), e = [], j = !1; else {
779					if ( "]" !== g || "" !== h ) "" === h && "," === g ? ( c.val.push( e.join( "" ) ),
780						e = [] ) : e.push( g )
781				} else "\\" === g && f + 1 < d.length ? j && e.push( d.charAt( ++f ) ) : "[" === g && "" === h ? j = !0 : " " === g || "+" === g ? ( c.sel = c.sel.join( "" ), a.push( c ), "+" === g && a.push( { sel: "+", val: "" } ), c = { sel: [], val: [] } ) : " " !== g && "]" !== g && c.sel.push( g )
782			}
783			if ( 0 != c.sel.length || 0 != c.val.length ) c.sel = c.sel.join( "" ), a.push( c );
784			for ( f = 0; f < a.length; f++ ) {
785				c = a[ f ].sel;
786				if ( "+" === c ) b.tag = c; else {
787					var b = [];
788					b.tag = tagexpr.exec( c );
789					b.id = idexpr.exec( c );
790					b.id && Array.isArray( b.id ) && ( b.id = b.id[ 0 ].substr( 1 ) );
791					b.tag || ( b.tag = "div" );
792					b.vars = [];
793					for ( d = 0; d < a[ f ].val.length; d++ )h =
794						a[ f ].val[ d ].indexOf( "=" ), j = a[ f ].val[ d ].substr( 0, h ), h = a[ f ].val[ d ].substr( h + 1 ), h = h.replace( /^[\s]*[\"\']*|[\"\']*[\s]*$/g, "" ), "text" === j ? b.text = h : b.vars.push( [ j, h ] );
795					c = c.match( classexpr );
796					j = [];
797					if ( c ) {
798						for ( d = 0; d < c.length; d++ )j.push( c[ d ].substr( 1 ) );
799						b.className = j.join( " " )
800					}
801				}
802				a[ f ] = b
803			}
804			return a
805		}, rmFromParent = function ( d ) {
806			var c = d.parentNode, a = d.nextSibling;
807			c.removeChild( d );
808			return a ? function () {
809				c.insertBefore( d, a )
810			} : function () {
811				c.appendChild( d )
812			}
813		}, nonArrVer = function ( d, c ) {
814			var a = [], a = simpleselector.test( d ) ? [
815				{ tag: d }
816			] : parseSelector( d ),
817				j = [];
818			"undefined" === typeof c && ( c = 1 );
819			for ( var h = [], e = [], f = [], m = document.createElement( "div" ), g = 0, b = 0; b < a.length; b++ ) {
820				if ( "+" == a[ b ].tag ) e = f.slice(), --g; else {
821					for ( var l = 0; l < c; l++ ) {
822						var k;
823						if ( "input" == a[ b ].tag ) {
824							k = [];
825							k.push( "<" + a[ b ].tag );
826							a[ b ].id && k.push( "id='" + a[ b ].id + "'" );
827							a[ b ].className && ( k.push( "class='" + a[ b ].className ), b + 1 === a.length && k.push( lastClass ), k.push( "'" ) );
828							if ( a[ b ].vars ) for ( var n = 0; n < a[ b ].vars.length; n++ )k.push( a[ b ].vars[ n ][ 0 ] + "='" + a[ b ].vars[ n ][ 1 ] + "'" );
829							a[ b ].text && k.push( "value='" + a[ b ].text + "'" );
830							k.push( "/>" );
831							f[ l ] = e[ l ];
832							e[ l ] ? ( e[ l ].innerHTML += k.join( " " ), e[ l ] = e[ l ].lastChild ) : ( m.innerHTML = k.join( " " ), e[ l ] = m.removeChild( m.firstChild ) )
833						} else {
834							k = document.createElement( a[ b ].tag );
835							if ( a[ b ].vars ) for ( var n = 0; n < a[ b ].vars.length; n++ )k.setAttribute( a[ b ].vars[ n ][ 0 ], a[ b ].vars[ n ][ 1 ] );
836							a[ b ].id && ( k.id = a[ b ].id );
837							a[ b ].className && ( k.className = a[ b ].className );
838							a[ b ].text && k.appendChild( document.createTextNode( a[ b ].text ) );
839							f[ l ] = e[ l ];
840							e[ l ] = e[ l ] ? e[ l ].appendChild( k ) : k
841						}
842					}
843					g++ || Array.prototype.push.apply( h, e );
844				}
845				j = $.merge( j, e );
846			}
847			return $( h )
848		}, arrVer = function ( d, c, a ) {
849			for ( var j = d.match( /%[^%]*%/g ) || [], h = [], e = 0; e < c.length; e++ ) {
850				for ( var f = d, m = 0; m < j.length; m++ )var g = j[ m ].substr( 1, j[ m ].length - 2 ), f = f.replace( j[ m ], c[ e ][ g ] );
851				h = $.merge( h, nonArrVer( f, a ) )
852			}
853			return $( h )
854		};
855
856		$.porto_jseldom = function ( d ) {
857			if ( 2 == arguments.length && $.isPlainObject( arguments[ 1 ] ) ) return arrVer.apply( this, [ arguments[ 0 ], [ arguments[ 1 ] ] ] );
858			if ( 1 == arguments.length || 2 == arguments.length && !Array.isArray( arguments[ 1 ] ) ) return nonArrVer.apply( this, arguments );
859			if ( 2 == arguments.length ) return arrVer.apply( this, arguments )
860		};
861
862		var refreshPriceSlider = function () {
863
864			var $price_slider = $( '.price_slider' );
865
866			if ( $price_slider.length ) {
867				// woocommerce_price_slider_params is required to continue, ensure the object exists
868				if ( typeof woocommerce_price_slider_params === 'undefined' ) {
869					return false;
870				}
871
872				// Get markup ready for slider
873				$( 'input#min_price, input#max_price' ).hide();
874				$( '.price_slider, .price_label' ).show();
875
876				// Price slider uses jquery ui
877				var min_price = $( '.price_slider_amount #min_price' ).data( 'min' ),
878					max_price = $( '.price_slider_amount #max_price' ).data( 'max' ),
879					current_min_price = parseInt( $( '.price_slider_amount #min_price' ).val() ? $( '.price_slider_amount #min_price' ).val() : min_price, 10 ),
880					current_max_price = parseInt( $( '.price_slider_amount #max_price' ).val() ? $( '.price_slider_amount #max_price' ).val() : max_price, 10 );
881
882				$( '.price_slider' ).slider( {
883					range: true,
884					animate: true,
885					min: min_price,
886					max: max_price,
887					values: [ current_min_price, current_max_price ],
888					create: function () {
889
890						$( '.price_slider_amount #min_price' ).val( current_min_price );
891						$( '.price_slider_amount #max_price' ).val( current_max_price );
892
893						$( document.body ).trigger( 'price_slider_create', [ current_min_price, current_max_price ] );
894					},
895					slide: function ( event, ui ) {
896
897						$( 'input#min_price' ).val( ui.values[ 0 ] );
898						$( 'input#max_price' ).val( ui.values[ 1 ] );
899
900						$( document.body ).trigger( 'price_slider_slide', [ ui.values[ 0 ], ui.values[ 1 ] ] );
901					},
902					change: function ( event, ui ) {
903
904						$( document.body ).trigger( 'price_slider_change', [ ui.values[ 0 ], ui.values[ 1 ] ] );
905					}
906				} );
907			}
908
909			// remove filter loading
910			$( '.yith-woo-ajax-navigation, .yith-wcan-list-price-filter' ).removeClass( 'loading' );
911		};
912
913		var categoryAjaxProcess = function ( href, updateSelect2, updateStyle ) {
914			var shop_before = '.shop-loop-before',
915				$shop_before = $( shop_before ),
916				shop_after = '.shop-loop-after:not(.is-shortcode)',
917				shop_container = '.archive-products .products:not(.is-shortcode)',
918				shop_info = '.archive-products .woocommerce-info',
919				//$wrapper = $('#content.site-main'),
920				$shop_parent = $shop_before.parent(),
921				$shop_container = $( shop_container ),
922				$sticky_sidebar = $( '.sidebar [data-plugin-sticky]' ),
923				show_toolbar = $shop_before.data( 'show' ),
924				horizontal_filter = '.porto-product-filters:not(.style2)';
925
926			if ( show_toolbar )
927				$( shop_before + ',' + shop_after ).stop( true ).fadeTo( 400, 1 ).block( { message: null, overlayCSS: { opacity: 0.2 } } );
928			if ( js_porto_vars.use_skeleton_screen.indexOf( 'shop' ) == -1 ) {
929				if ( $shop_container.length ) {
930					$shop_container.addClass( 'yith-wcan-loading' );
931					if ( !$shop_container.children( '.porto-loading-icon' ).length ) {
932						$shop_container.append( '<i class="porto-loading-icon"></i>' );
933					}
934				} else {
935					$( shop_info ).html( '' ).addClass( 'yith-wcan-loading products' );
936					if ( !$( shop_info ).children( '.porto-loading-icon' ).length ) {
937						$( shop_info ).append( '<i class="porto-loading-icon"></i>' );
938					}
939				}
940			} else {
941				if ( $shop_container.length ) {
942					$shop_container.addClass( 'skeleton-body' );
943					var lg_cols,
944						other_col_cls = $shop_container.data( ( $shop_container.hasClass( 'list' ) ? 'list' : 'grid' ) + '_col_cls' );
945					if ( $shop_container.hasClass( 'list' ) && ! other_col_cls ) {
946						lg_cols = 4;
947					} else {
948						for ( var i = 1; i <= 8; i++ ) {
949							if ( $shop_container.hasClass( 'pcols-lg-' + i ) ) {
950								lg_cols = i;
951								break;
952							}
953						}
954						if ( !lg_cols ) {
955							if ( $shop_container.hasClass( 'has-ccols' ) ) {
956								var clses;
957								if ( other_col_cls ) {
958									clses = $shop_container.attr( 'class' ).split( ' ' );
959									var new_cls = [];
960									for ( var i = 0; i < clses.length; i++ ) {
961										if ( 0 !== clses[i].indexOf( 'ccols-' ) && 'has-ccols' != clses[i] ) {
962											new_cls.push( clses[i] );
963										}
964									}
965									$shop_container.attr( 'class', new_cls.join( ' ' ) + ' ' + other_col_cls );
966									clses = other_col_cls.split( ' ' );
967								} else {
968									clses = $shop_container.attr( 'class' ).split( ' ' );
969								}
970								for ( var i = 0; i < clses.length; i++ ) {
971									if ( 0 === clses[ i ].indexOf( 'ccols-' ) ) {
972										lg_cols = clses[ i ].replace( /ccols-[sm|md|lg|xl|xxl]*[-]*([\d])/, '$1' );
973										break;
974									}
975								}
976							}
977						}
978					}
979					if ( lg_cols ) {
980						var product_class = 'product product-col';
981						$shop_container.empty();
982						if ( $shop_container.data( 'product_layout' ) ) {
983							product_class += ' ' + escape( $shop_container.data( 'product_layout' ) );
984						}
985						for ( var i = 0; i < lg_cols * 3; i++ ) {
986							$shop_container.append( '<li class="' + product_class + '"></li>' );
987						}
988					} else {
989						$shop_container.find( '.product-col' ).empty();
990					}
991
992					if ( $shop_container.hasClass( 'owl-loaded' ) ) {
993						$shop_container.removeClass( 'owl-loaded' );
994					}
995				}
996			}
997
998			if ( $( horizontal_filter ).length ) {
999				$( horizontal_filter ).block( { message: null, overlayCSS: { opacity: 0.2 } } );
1000			}
1001
1002			if ( $sticky_sidebar.get( 0 ) ) {
1003				//$shop_parent.css('min-height', $sticky_sidebar.height());
1004				theme.refreshStickySidebar( false );
1005			}
1006
1007			theme.scrolltoContainer( show_toolbar ? ( $shop_before.hasClass( 'sticky' ) && $shop_before.prev( '.filter-placeholder' ).length ? $shop_before.prev( '.filter-placeholder' ) : $shop_before ) : $shop_container );
1008
1009			$( '.yith-woo-ajax-navigation, .yith-wcan-list-price-filter' ).addClass( 'loading' );
1010
1011			var cart_content, widget_cart;
1012
1013			if ( widget_cart = $( '.sidebar-content .widget_shopping_cart' ).get( 0 ) ) {
1014				cart_content = $( widget_cart ).html();
1015			}
1016
1017			$.ajax( {
1018				url: href,
1019				data: { portoajax: true, load_posts_only: true },
1020				type: "POST",
1021				success: function ( response ) {
1022
1023					var $parent = $shop_container.parent(),
1024						$response = $( response );
1025
1026					if ( $sticky_sidebar.get( 0 ) )
1027						$shop_parent.css( 'min-height', 0 );
1028
1029					var $response_container = $response.find( shop_container );
1030					// products container
1031					if ( $response_container.length ) {
1032						if ( $shop_container.length && $shop_container.data( 'infinitescroll' ) ) {
1033							try {
1034								$shop_container.data( 'infinitescroll' ).destroy();
1035								var ins = $shop_container.data( '__postsinfinite' );
1036								if ( ins ) {
1037									ins.destroy();
1038								}
1039							} catch ( e ) {
1040							}
1041						}
1042						// update style
1043						if ( typeof updateStyle != 'undefined' && updateStyle && $parent.hasClass( 'porto-posts-grid' ) ) {
1044							var old_style = $shop_container.siblings( 'style' ),
1045								new_style = $response_container.siblings( 'style' );
1046							if ( old_style.length && new_style.length ) {
1047								old_style.replaceWith( new_style );
1048							}
1049						}
1050
1051						//$parent.html( $response_container );
1052						$shop_container.replaceWith( $response_container[0].outerHTML );
1053						$shop_container = $( shop_container );
1054					} else if ( $parent.hasClass( 'porto-posts-grid' ) ) {
1055						$shop_container.empty();
1056					} else {
1057						$parent.html( $response.find( '.woocommerce-info' ) );
1058						$parent.find( '.woocommerce-info' ).addClass( 'products' );
1059					}
1060
1061					if ( $( shop_before + ',' + shop_after ).get( 0 ) )
1062						$( shop_before + ',' + shop_after ).stop( true ).css( 'opacity', '1' ).unblock();
1063
1064					// top toolbar
1065					if ( $response.find( shop_before ).length ) {
1066						if ( $( shop_before ).length == 0 ) {
1067							$.porto_jseldom( shop_before ).insertBefore( $( shop_container ) );
1068						}
1069
1070						$( shop_before ).each( function( index ) {
1071							var $res_shop_before = $response.find( shop_before ).eq( index );
1072							if ( $res_shop_before.length ) {
1073								$( this ).html( $res_shop_before.html() ).show();
1074							}
1075						} );
1076					} else {
1077						$( shop_before ).empty();
1078					}
1079
1080					// reset variations form
1081					porto_woocommerce_variations_init( $parent );
1082
1083					// horizontal filter
1084					if ( $response.find( horizontal_filter ).length ) {
1085						$( horizontal_filter ).html( $response.find( horizontal_filter ).html() );
1086					}
1087					$( horizontal_filter ).unblock();
1088
1089					// bottom toolbar
1090					if ( $response.find( shop_after ).length ) {
1091						if ( $( shop_after ).length == 0 ) {
1092							$.porto_jseldom( shop_after ).insertAfter( $( shop_container ) );
1093						}
1094						$( shop_after ).html( $response.find( shop_after ).html() ).show();
1095					} else {
1096						$( shop_after ).empty();
1097					}
1098
1099					// update pagination in shop builder
1100					var $pagination = $parent.children( '.pagination-wrap' ),
1101						$newPagination = $response_container.siblings( '.pagination-wrap' );
1102					if ( $pagination.length ) {
1103						$pagination[ 0 ].outerHTML = $newPagination.length ? $newPagination[ 0 ].outerHTML : '';
1104					} else {
1105						$newPagination.length && $parent.append( $newPagination );
1106					}
1107
1108					// update result count
1109					var $count = $( '.woocommerce-result-count' );
1110					if ( $count.length ) {
1111						var $newCount = $response.find( '.woocommerce-result-count' ).eq( 0 );
1112						$count[ 0 ].outerHTML = $newCount.length ? $newCount[ 0 ].outerHTML : '';
1113					}
1114
1115					// update category filter in shop builder
1116					/*var $filter = $parent.children( '.product-filter' ),
1117						$newFilter = $response_container.siblings( '.product-filter' );
1118					if ( $filter.length ) {
1119						if ( $newFilter.length ) {
1120							$filter.replaceWith( $newFilter );
1121						} else {
1122							$filter.remove();
1123						}
1124					} else if ( $newFilter.length ) {
1125						$newFilter = $newFilter.insertBefore( $shop_container );
1126					}
1127					if ( $newFilter.length && $newFilter.hasClass( 'porto-ajax-filter' ) ) {
1128
1129					}*/
1130
1131					// infinite scroll
1132					if ( $parent.hasClass( 'porto-posts-grid' ) ) {
1133						if ( $parent.is( '.porto-ajax-load.load-infinite, .porto-ajax-load.load-more' ) ) {
1134							$parent.portoInfiniteScroll();
1135						}
1136					} else if ( typeof theme.PostsInfinite !== 'undefined' && typeof porto_infinite_scroll !== 'undefined' ) {
1137						new theme.PostsInfinite( $( shop_container ) );
1138					}
1139
1140					$( '.sidebar-content' ).each( function ( index ) {
1141						var $this = $( this ),
1142							$that = $( $response.find( '.sidebar-content' ).get( index ) );
1143
1144						$this.html( $that.html() );
1145
1146						if ( typeof updateSelect2 != 'undefined' && updateSelect2 ) {
1147							// Use Select2 enhancement if possible
1148							if ( jQuery().selectWoo ) {
1149								var porto_wc_layered_nav_select = function () {
1150									$this.find( 'select.woocommerce-widget-layered-nav-dropdown' ).each( function () {
1151										$( this ).selectWoo( {
1152											placeholder: $( this ).find( 'option' ).eq( 0 ).text(),
1153											minimumResultsForSearch: 5,
1154											width: '100%',
1155											allowClear: typeof $( this ).attr( 'multiple' ) != 'undefined' && $( this ).attr( 'multiple' ) == 'multiple' ? 'false' : 'true'
1156										} );
1157									} );
1158								};
1159								porto_wc_layered_nav_select();
1160							}
1161							$( 'body' ).children( 'span.select2-container' ).remove();
1162						}
1163					} );
1164
1165					var $script = $response.filter( 'script:contains("var woocommerce_price_slider_params")' ).first();
1166					if ( $script && $script.length && $script.text().indexOf( '{' ) !== -1 && $script.text().indexOf( '}' ) !== -1 ) {
1167						var arrStr = $script.text().substring( $script.text().indexOf( '{' ), $script.text().indexOf( '}' ) + 1 );
1168						window.woocommerce_price_slider_params = JSON.parse( arrStr );
1169					}/* else {
1170						window.woocommerce_price_slider_params = undefined;
1171					}*/
1172
1173					//update browser history (IE doesn't support it)
1174					if ( !navigator.userAgent.match( /msie/i ) ) {
1175						window.history.pushState( { "pageTitle": response.pageTitle }, "", href );
1176					}
1177
1178					$parent.removeClass( 'porto-ajax-loading' );
1179
1180					//trigger ready event
1181					$( document ).trigger( "yith-wcan-ajax-filtered" );
1182
1183					if ( widget_cart = $( '.sidebar-content .widget_shopping_cart' ).get( 0 ) ) {
1184						$( '.sidebar-content .widget_shopping_cart' ).html( cart_content );
1185						if ( $.cookie( 'woocommerce_items_in_cart' ) > 0 ) {
1186							$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).show();
1187						} else {
1188							$( '.hide_cart_widget_if_empty' ).closest( '.widget_shopping_cart' ).hide();
1189						}
1190					}
1191				}
1192			} );
1193		};
1194
1195		function porto_update_url_param( uri, key, value ) {
1196			var re = new RegExp( "([?&])" + key + "=.*?(&|$)", "i" );
1197			var separator = uri.indexOf( '?' ) !== -1 ? "&" : "?";
1198			if ( uri.match( re ) ) {
1199				return uri.replace( re, '$1' + key + "=" + value + '$2' );
1200			} else {
1201				return uri + separator + key + "=" + value;
1202			}
1203		}
1204
1205		var categoryAjax = function () {
1206			// add class in price filter widget
1207			$( '.widget_price_filter' ).addClass( 'yith-wcan-list-price-filter' );
1208
1209			if ( theme.category_ajax ) {
1210
1211				// order by ajax
1212				$( '.woocommerce-ordering' ).off( 'change', 'select.orderby' ).on( 'change', 'select.orderby', function ( e ) {
1213					e.preventDefault();
1214
1215					var $this = $( this ),
1216						$form = $this.closest( 'form' ),
1217						href = '?' + $form.serialize();
1218
1219					categoryAjaxProcess( href );
1220				} );
1221
1222				// view ajax
1223				$( '.woocommerce-viewing' ).off( 'change', 'select.count' ).on( 'change', 'select.count', function ( e ) {
1224					e.preventDefault();
1225
1226					var $this = $( this ),
1227						$form = $this.closest( 'form' ),
1228						href = '?' + $form.serialize();
1229
1230					categoryAjaxProcess( href );
1231				} );
1232
1233				// pagination ajax
1234				$( '.woocommerce-pagination:not(.load-more)' ).each( function () {
1235					if ( $( this ).closest( '.porto-products' ).length || $( this ).closest( '#comments' ).length ) {
1236						return;
1237					}
1238					$( this ).off( 'click', 'a.page-numbers' ).on( 'click', 'a.page-numbers', function ( e ) {
1239						e.preventDefault();
1240						var href = this.href;
1241						categoryAjaxProcess( href );
1242					} );
1243				} );
1244
1245				// yith filter
1246				$( document ).off( 'click', '.yith-wcan a' ).on( 'click', '.yith-wcan a', function ( e ) {
1247					$( this ).yith_wcan_ajax_filters( e, this );
1248				} );
1249
1250				// price filter ajax
1251				$( '.widget_price_filter .price_slider_wrapper' ).off( 'click', '.button' ).on( 'click', '.button', function ( e ) {
1252					e.preventDefault();
1253
1254					var $this = $( this ),
1255						$form = $this.closest( 'form' ),
1256						action = $form.attr( 'action' ),
1257						href = action + ( -1 === action.indexOf( '?' ) ? '?' : '&' ) + $form.serialize(),
1258						$count = $( '.woocommerce-viewing select.count' );
1259
1260					if ( $count.length ) {
1261						var count = $( '.woocommerce-viewing select.count' ).val();
1262						if ( count != $count.find( 'option:not([disabled]):first' ).val() ) {
1263							href += '&count=' + count;
1264						}
1265					}
1266
1267					$( '.widget_price_filter' ).removeClass( 'yith-wcan-list-price-filter' );
1268
1269					categoryAjaxProcess( href );
1270				} );
1271				$( '.porto_widget_price_filter' ).off( 'click', '.button' ).on( 'click', '.button', function ( e ) {
1272					e.preventDefault();
1273
1274					var $this = $( this ),
1275						$form = $this.closest( 'form' ),
1276						action = $form.attr( 'action' ),
1277						$count = $( '.woocommerce-viewing select.count' ),
1278						hrefArr = $form.serializeArray(),
1279						href = action;
1280					$.each( hrefArr, function ( i, field ) {
1281						if ( $.trim( field.value ) ) {
1282							if ( action.indexOf( '?' ) == -1 && href == action ) {
1283								href += '?';
1284							} else {
1285								href += '&';
1286							}
1287							href += ( field.name + "=" + $.trim( field.value ) );
1288						}
1289					} );
1290					if ( $count.length ) {
1291						var count = $( '.woocommerce-viewing select.count' ).val();
1292						if ( count != $count.find( 'option:not([disabled]):first' ).val() ) {
1293							if ( href.indexOf( '?' ) == -1 ) {
1294								href += '?count=' + count;
1295							} else {
1296								href += '&count=' + count;
1297							}
1298						}
1299					}
1300
1301					categoryAjaxProcess( href );
1302				} );
1303
1304				// layerd nav filter
1305				$( '.widget_layered_nav, .widget_rating_filter, .widget_layered_nav_filters' ).off( 'click', 'a' ).on( 'click', 'a', function ( e ) {
1306					if ( $( this ).hasClass( 'yit-wcan-select-open' ) )
1307						return;
1308
1309					e.preventDefault();
1310
1311					var $this = $( this ),
1312						href = $this.attr( 'href' ),
1313						$count = $( '.woocommerce-viewing select.count' );
1314
1315					if ( $this.hasClass( 'yith-wcan-reset-navigation' ) && !$( '.archive-products .products:not(.is-shortcode)' ).length ) {
1316						window.location.href = href;
1317						return false;
1318					}
1319
1320					if ( $count.length ) {
1321						var count = $( '.woocommerce-viewing select.count' ).val();
1322						if ( count != $count.find( 'option:not([disabled]):first' ).val() ) {
1323							//href += '&count=' + count;
1324							href = porto_update_url_param( href, 'count', count );
1325						}
1326					}
1327
1328					var yith_select = $this.closest( '.yith-wcan-select' );
1329					if ( yith_select.get( 0 ) ) {
1330						yith_select.parent().css( { "opacity": 0, "z-index": -1 } );
1331					}
1332
1333					categoryAjaxProcess( href );
1334
1335					return false;
1336				} );
1337
1338				$( '.widget_layered_nav select' ).off( 'change' ).on( 'change', function ( e ) {
1339					e.preventDefault();
1340
1341					var $this = $( this ),
1342						name = $this.closest( 'form' ).find( 'input[type=hidden]' ).length ? $this.closest( 'form' ).find( 'input[type=hidden]' ).attr( 'name' ).replace( 'filter_', '' ) : $this.attr( 'class' ).replace( 'dropdown_layered_nav_', '' ),
1343						slug = $this.val(),
1344						href,
1345						$count = $( '.woocommerce-viewing select.count' );
1346
1347					href = window.location.href;
1348					href = href.replace( /\/page\/\d+/, "" ).replace( "&amp;", '&' ).replace( "%2C", ',' );
1349
1350					href = porto_update_url_param( href, 'filtering', '1' );
1351					href = porto_update_url_param( href, 'filter_' + name, slug );
1352					if ( $count.length ) {
1353						var count = $( '.woocommerce-viewing select.count' ).val();
1354						if ( count != $count.find( 'option:not([disabled]):first' ).val() ) {
1355							href = porto_update_url_param( href, 'count', count );
1356						}
1357					}
1358
1359					categoryAjaxProcess( href, name );
1360					return false;
1361				} );
1362			} else {
1363				$( document ).on( 'change', '.woocommerce-viewing select.count', function () {
1364					$( this ).closest( 'form' ).trigger( 'submit' );
1365				} );
1366			}
1367		};
1368
1369		var ajaxFiltered = function ( initLoad ) {
1370			var shop_before = '.shop-loop-before',
1371				shop_after = '.shop-loop-after',
1372				shop_container = '.archive-products .products',
1373				$shop_before = $( shop_before ),
1374				$shop_parent = $shop_before.parent(),
1375				$shop_toolbox = $( shop_before + ',' + shop_after ),
1376				$sticky_sidebar = $( '.sidebar [data-plugin-sticky]' );
1377
1378			if ( $sticky_sidebar.get( 0 ) ) {
1379				$shop_parent.css( 'min-height', 0 );
1380			}
1381
1382			if ( $shop_toolbox.length ) {
1383				$shop_toolbox.stop( true ).fadeTo( 400, 1 ).unblock();
1384			}
1385			if ( $( shop_container ).find( '.product' ).length || $( shop_after ).closest( '.porto-products' ).length || $shop_before.hasClass( 'shop-builder' ) ) {
1386				$shop_toolbox.show().data( 'show', true );
1387			} else {
1388				$shop_toolbox.hide().data( 'show', false );
1389				if ( $shop_before.find( '.porto-product-filters.style2' ).length ) {
1390					$shop_before.show().data( 'show', true );
1391				}
1392			}
1393
1394			if ( typeof initLoad == 'undefined' || ! initLoad ) {
1395				porto_init();
1396				porto_woocommerce_init();
1397			}
1398
1399			$( '.woocommerce-ordering' ).off( 'change', 'select.orderby' ).on( 'change', 'select.orderby', function () {
1400				$( this ).closest( 'form' ).trigger( 'submit' );
1401			} );
1402
1403			// category ajax
1404			refreshPriceSlider();
1405			categoryAjax();
1406		};
1407
1408		// initialize woocommerce actions after skeleton loading
1409		var skeletonLoadingTrigger;
1410		$( '.skeleton-loading' ).on( 'skeleton-loaded', function () {
1411			var $this = $( this );
1412			if ( skeletonLoadingTrigger ) {
1413				theme.deleteTimeout( skeletonLoadingTrigger );
1414			}
1415			porto_woocommerce_variations_init( $this );
1416
1417			// yith wishlist pro compatibility
1418			if ( $this.hasClass( 'products' ) || $this.hasClass( 'product' ) ) {
1419				$( document ).trigger( 'yith_infs_added_elem' );
1420			}
1421
1422			skeletonLoadingTrigger = theme.requestTimeout( function () {
1423				porto_woocommerce_init();
1424				refreshPriceSlider();
1425				if ( $( 'body' ).hasClass( 'single-product' ) ) {
1426					theme.WooVariationForm.init();
1427					var $image_slider = $( '.product-image-slider' );
1428					if ( $image_slider.length && $image_slider.data( 'owl.carousel' ) ) {
1429						$image_slider.trigger( 'refresh.owl.carousel' );
1430					} else {
1431						theme.WooProductImageSlider.initialize();
1432					}
1433					$( '.wc-tabs-wrapper, .woocommerce-tabs, #rating' ).trigger( 'init' );
1434
1435					// compatibility issue with Yith WooCommerce Booking form
1436					if ( $( document.body ).hasClass( 'yith-booking' ) ) {
1437						$( document ).trigger( 'yith-wcbk-init-booking-form' );
1438					}
1439				}
1440
1441				// refresh cart content
1442				if ( $this.find( '.widget_shopping_cart_content' ).length ) {
1443					$( document.body ).trigger( 'wc_fragment_refresh' );
1444				}
1445			}, 100 );
1446		} );
1447
1448		$( function () {
1449			// yith woo ajax filter events
1450			if ( typeof yith_wcan != 'undefined' ) {
1451				yith_wcan.container = '.archive-products .products';
1452				yith_wcan.pagination = '.shop-loop-before';
1453				yith_wcan.result_count = '.shop-loop-after';
1454			}
1455
1456			$( document ).on( 'click', '.yith-wcan a', function ( e ) {
1457				// add price filter loading
1458				var shop_before = '.shop-loop-before',
1459					$shop_before = $( shop_before ),
1460					shop_after = '.shop-loop-after',
1461					shop_container = '.archive-products .products',
1462					shop_info = '.archive-products .woocommerce-info',
1463					//$shop_parent = $shop_before.parent(),
1464					$sticky_sidebar = $( '.sidebar [data-plugin-sticky]' ),
1465					show_toolbar = $shop_before.data( 'show' );
1466
1467				if ( show_toolbar )
1468					$( shop_before + ',' + shop_after ).stop( true ).show().fadeTo( 400, 0.8 ).block( { message: null, overlayCSS: { opacity: 0.2 } } );
1469				if ( $( shop_container ).length ) {
1470					$( shop_container ).html( '' ).addClass( 'yith-wcan-loading' );
1471					if ( !$( shop_container ).children( '.porto-loading-icon' ).length ) {
1472						$( shop_container ).append( '<i class="porto-loading-icon"></i>' );
1473					}
1474				} else {
1475					$( shop_info ).html( '' ).addClass( 'yith-wcan-loading products' );
1476					if ( !$( shop_info ).children( '.porto-loading-icon' ).length ) {
1477						$( shop_info ).append( '<i class="porto-loading-icon"></i>' );
1478					}
1479				}
1480
1481				if ( $sticky_sidebar.get( 0 ) ) {
1482					//$shop_parent.css('min-height', $sticky_sidebar.height());
1483					theme.refreshStickySidebar( false );
1484				}
1485				$( '.yith-woo-ajax-navigation, .yith-wcan-list-price-filter' ).addClass( 'loading' );
1486				theme.scrolltoContainer( show_toolbar ? ( $shop_before.hasClass( 'sticky' ) && $shop_before.prev( '.filter-placeholder' ).length ? $shop_before.prev( '.filter-placeholder' ) : $shop_before ) : $( shop_container ) );
1487			} );
1488
1489			$( document ).ready( function () {
1490				ajaxFiltered( true );
1491			} );
1492
1493			$( document ).on( 'yith-wcan-ajax-filtered', function () {
1494				ajaxFiltered();
1495			} );
1496
1497			//categoryAjax();
1498
1499			// product filter ajax
1500			if ( theme.prdctfltr_ajax ) {
1501				// select count
1502				$( document ).on( 'change', '.woocommerce-viewing select.count', function () {
1503					$( this ).closest( 'form' ).trigger( 'submit' );
1504				} );
1505				// page number
1506				$( document ).on( 'click', '.woocommerce-pagination:not(.load-more) a.page-numbers', function ( e ) {
1507					var $shop_before = $( '.shop-loop-before' );
1508					theme.scrolltoContainer( $shop_before.hasClass( 'sticky' ) && $shop_before.prev( '.filter-placeholder' ).length ? $shop_before.prev( '.filter-placeholder' ) : $shop_before );
1509				} );
1510			}
1511
1512			// woocommerce grid / list
1513			$( document ).on( 'click', '.gridlist-toggle #grid, .gridlist-toggle #list', function ( e ) {
1514				e.preventDefault();
1515				var $this = $( this );
1516				if ( $this.hasClass( 'active' ) ) {
1517					return false;
1518				}
1519				$( '.gridlist-toggle #grid, .gridlist-toggle #list' ).removeClass( 'active' );
1520				$this.addClass( 'active' );
1521				if ( $.cookie ) {
1522					$.cookie( 'gridcookie', $this.attr( 'id' ), { path: '/' } );
1523				}
1524				if ( theme.category_ajax ) {
1525					if ( js_porto_vars.use_skeleton_screen.indexOf( 'shop' ) != -1 ) {
1526						$( '.archive-products ul.products, .archive-products .products-container' ).removeClass( 'grid' ).removeClass( 'list' ).addClass( $this.attr( 'id' ) );
1527					} else {
1528						$( '.archive-products' ).addClass( 'porto-ajax-loading' );
1529					}
1530					categoryAjaxProcess( window.location.href, undefined, true );
1531				} else {
1532					location.reload();
1533				}
1534				return false;
1535			} );
1536		} );
1537
1538	} ).apply( this, [ window.theme, jQuery ] );
1539
1540
1541	// Woocommerce Product Image Slider
1542	( function ( theme, $ ) {
1543
1544		theme = theme || {};
1545
1546		var duration = 300,
1547			flag = false;
1548
1549		$.extend( theme, {
1550
1551			WooProductImageSlider: {
1552
1553				defaults: {
1554					elements: '.product-image-slider'
1555				},
1556
1557				initialize: function ( $elements ) {
1558					if ( !$.fn.owlCarousel ) return false;
1559					this.$elements = ( $elements || $( this.defaults.elements ) );
1560					if ( !this.$elements.length && !$( '.product-images-block' ).length ) {
1561						return this;
1562					}
1563
1564					this.build();
1565
1566					return this;
1567				},
1568
1569				build: function () {
1570					var self = this,
1571						thumbs_count = theme.product_thumbs_count;
1572
1573					if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) {
1574						var zoomConfig = {
1575							responsive: true,
1576							zoomWindowFadeIn: 200,
1577							zoomWindowFadeOut: 100,
1578							zoomType: js_porto_vars.zoom_type,
1579							cursor: 'grab'
1580						};
1581
1582						if ( js_porto_vars.zoom_type == 'lens' ) {
1583							zoomConfig.scrollZoom = js_porto_vars.zoom_scroll;
1584							zoomConfig.lensSize = js_porto_vars.zoom_lens_size;
1585							zoomConfig.lensShape = js_porto_vars.zoom_lens_shape;
1586							zoomConfig.containLensZoom = js_porto_vars.zoom_contain_lens;
1587							zoomConfig.lensBorderSize = js_porto_vars.zoom_lens_border;
1588							zoomConfig.borderColour = js_porto_vars.zoom_border_color;
1589						}
1590
1591						if ( js_porto_vars.zoom_type == 'inner' ) {
1592							zoomConfig.borderSize = 0;
1593						} else {
1594							zoomConfig.borderSize = js_porto_vars.zoom_border;
1595						}
1596
1597						if ( !self.$elements.length ) {
1598							var $images_grid = $( '.product-images-block' );
1599							if ( $images_grid.length ) {
1600								$images_grid.find( 'img' ).each( function () {
1601									var $this = $( this );
1602									zoomConfig.zoomContainer = $this.parent();
1603									if ( $.fn.elevateZoom ) {
1604										$this.elevateZoom( zoomConfig );
1605									} else {
1606										setTimeout( function () {
1607											if ( $.fn.elevateZoom ) {
1608												$this.elevateZoom( zoomConfig );
1609											}
1610										}, 1000 );
1611									}
1612								} );
1613							}
1614						}
1615					}
1616
1617					self.$elements.each( function () {
1618						var $this = $( this ),
1619							$product = $this.closest( '.product' );
1620						if ( !$product.length ) {
1621							$product = $this.closest( '.product_layout, .product-layout-image' ).eq(0);
1622						}
1623						var $thumbs_slider = $product.find( '.product-thumbs-slider' ),
1624							$thumbs = $product.find( '.product-thumbnails-inner' ),
1625							$thumbs_vertical_slider = $product.find( '.product-thumbs-vertical-slider' ),
1626							currentSlide = 0,
1627							count = $this.find( '> *' ).length;
1628
1629						$this.find( '> *:first-child' ).imagesLoaded( function () {
1630							$thumbs_slider.owlCarousel( {
1631								rtl: theme.rtl,
1632								loop: false,
1633								autoplay: false,
1634								items: thumbs_count,
1635								nav: false,
1636								navText: [ "", "" ],
1637								dots: false,
1638								rewind: true,
1639								margin: 8,
1640								stagePadding: 1,
1641								lazyLoad: true,
1642								onInitialized: function () {
1643									self.selectThumb( null, $thumbs_slider, 0 );
1644									if ( $thumbs_slider.find( '.owl-item' ).length >= thumbs_count )
1645										$thumbs_slider.append( '<div class="thumb-nav"><div class="thumb-prev"></div><div class="thumb-next"></div></div>' );
1646								}
1647							} ).on( 'click', '.owl-item', function () {
1648								self.selectThumb( $this, $thumbs_slider, $( this ).index() );
1649							} );
1650							if ( $thumbs_vertical_slider.length > 0 ) {
1651								$thumbs_vertical_slider.slick( {
1652									dots: false,
1653									vertical: true,
1654									slidesToShow: thumbs_count > 2 ? thumbs_count - 1 : thumbs_count,
1655									slidesToScroll: 1
1656								} ).on( 'click', '.img-thumbnail', function () {
1657									self.selectVerticalSliderThumb( $this, $thumbs_vertical_slider, $( this ).data( 'slick-index' ) );
1658								} );
1659								self.selectVerticalSliderThumb( null, $thumbs_vertical_slider, 0 );
1660								if ( $thumbs_vertical_slider.find( '.porto-lazyload' ).length ) {
1661									theme.requestTimeout( function () {
1662										$thumbs_vertical_slider.find( '.slick-cloned .porto-lazyload:not(.lazy-load-loaded)' ).each( function () {
1663											$( this ).attr( 'src', $( this ).data( 'oi' ) ).removeAttr( 'data-oi' ).addClass( 'lazy-load-loaded' );
1664										} );
1665									}, 100 );
1666								}
1667							}
1668
1669							self.selectVerticalThumb( null, $thumbs, 0 );
1670							$thumbs.off( 'click', '.img-thumbnail' ).on( 'click', '.img-thumbnail', function () {
1671								self.selectVerticalThumb( $this, $thumbs, $( this ).index() );
1672							} );
1673
1674							$thumbs_slider.off( 'click', '.thumb-prev' ).on( 'click', '.thumb-prev', function ( e ) {
1675								var currentThumb = $thumbs_slider.data( 'currentThumb' );
1676								self.selectThumb( $this, $thumbs_slider, --currentThumb );
1677							} );
1678							$thumbs_slider.off( 'click', '.thumb-next' ).on( 'click', '.thumb-next', function ( e ) {
1679								var currentThumb = $thumbs_slider.data( 'currentThumb' );
1680								self.selectThumb( $this, $thumbs_slider, ++currentThumb );
1681							} );
1682
1683							var links = [];
1684							if ( theme.product_image_popup ) {
1685								var i = 0;
1686								$this.find( 'img' ).each( function () {
1687									var slide = {};
1688
1689									slide.src = $( this ).attr( 'href' );
1690									slide.title = $( this ).attr( 'alt' );
1691
1692									links[ i ] = slide;
1693									i++;
1694								} );
1695							}
1696
1697							var itemsCount = typeof $this.data( 'items' ) != 'undefined' ? $this.data( 'items' ) : 1,
1698								itemsResponsive = typeof $this.data( 'responsive' ) != 'undefined' ? $this.data( 'responsive' ) : {},
1699								centerItem = typeof $this.data( 'centeritem' ) != 'undefined' ? true : false;
1700							for ( var itemCount in itemsResponsive ) {
1701								itemsResponsive[ itemCount ] = { items: itemsResponsive[ itemCount ] };
1702							}
1703							$this.owlCarousel( {
1704								rtl: theme.rtl,
1705								loop: ( count > 1 ) ? true : false,
1706								autoplay: false,
1707								items: itemsCount,
1708								responsive: itemsResponsive,
1709								autoHeight: true,
1710								nav: true,
1711								navText: [ "", "" ],
1712								dots: false,
1713								rewind: true,
1714								lazyLoad: true,
1715								center: centerItem,
1716								onInitialized: function () {
1717									if ( $this.find( '.owl-item.cloned' ).length ) {
1718										setTimeout( function () {
1719											var ins = $this.find( '.owl-item.cloned .porto-lazyload:not(.lazy-load-loaded)' ).themePluginLazyLoad( { effect: 'fadeIn', effect_speed: 400 } );
1720											if ( ins && ins.loadAndDestroy ) {
1721												ins.loadAndDestroy();
1722											}
1723										}, 100 );
1724									}
1725									//$this.find('.cloned .porto-lazyload:not(.lazy-load-loaded)').themePluginLazyLoad();
1726									if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) {
1727										$this.find( 'img' ).each( function () {
1728											var $this = $( this );
1729											zoomConfig.zoomContainer = $this.parent();
1730											if ( $.fn.elevateZoom ) {
1731												$this.elevateZoom( zoomConfig );
1732											} else {
1733												setTimeout( function () {
1734													if ( $.fn.elevateZoom ) {
1735														$this.elevateZoom( zoomConfig );
1736													}
1737												}, 1000 );
1738											}
1739										} );
1740									}
1741								},
1742								onTranslate: function ( event ) {
1743									currentSlide = event.item.index - $this.find( '.cloned' ).length / 2;
1744									currentSlide = ( currentSlide + event.item.count ) % event.item.count;
1745									self.selectThumb( null, $thumbs_slider, currentSlide );
1746									self.selectVerticalThumb( null, $thumbs, currentSlide );
1747									self.selectVerticalSliderThumb( null, $thumbs_vertical_slider, currentSlide );
1748
1749									/*var $obj = event.relatedTarget.items(currentSlide).find('img.owl-lazy:not(.owl-lazy-loaded)');
1750									if ($obj.length) {
1751										var src = $obj.attr('href'),
1752											elevateZoom = $obj.data('elevateZoom'),
1753											smallImage = $obj.data('src') ? $obj.data('src') : $obj.attr('src');
1754										if (typeof elevateZoom != 'undefined') {
1755											elevateZoom.swaptheimage(smallImage, src);
1756										}
1757									}*/
1758								},
1759								onRefreshed: function () {
1760									if ( theme.product_zoom && ( !( 'ontouchstart' in document ) || ( ( 'ontouchstart' in document ) && theme.product_zoom_mobile ) ) ) {
1761										$this.find( 'img' ).each( function () {
1762											var $this = $( this ),
1763												src = typeof $this.attr( 'href' ) != 'undefined' ? $this.attr( 'href' ) : ( $this.data( 'oi' ) ? $this.data( 'oi' ) : $this.attr( 'src' ) ),
1764												elevateZoom = $this.data( 'elevateZoom' ),
1765												smallImage = $this.data( 'src' ) ? $this.data( 'src' ) : ( $this.data( 'oi' ) ? $this.data( 'oi' ) : $this.attr( 'src' ) );
1766											if ( typeof elevateZoom != 'undefined' ) {
1767												elevateZoom.startZoom();
1768												elevateZoom.swaptheimage( smallImage, src );
1769											} else if ( $.fn.elevateZoom ) {
1770												zoomConfig.zoomContainer = $this.parent();
1771												$this.elevateZoom( zoomConfig );
1772											}
1773										} );
1774									}
1775								}
1776							} );
1777
1778							$this.data( 'links', links );
1779
1780							if ( theme.product_image_popup ) {
1781								var $zoom_buttons = $this.next();
1782								$zoom_buttons.off( 'click' ).on( 'click', function ( e ) {
1783									e.preventDefault();
1784									if ( $.fn.magnificPopup ) {
1785										$.magnificPopup.close();
1786										$.magnificPopup.open( $.extend( true, {}, theme.mfpConfig, {
1787											items: $this.data( 'links' ),
1788											gallery: {
1789												enabled: true
1790											},
1791											type: 'image'
1792										} ), currentSlide );
1793									}
1794								} );
1795							}
1796						} );
1797					} );
1798
1799					return self;
1800				},
1801
1802				selectThumb: function ( $image_slider, $thumbs_slider, index ) {
1803					if ( flag || !$thumbs_slider.length ) return;
1804
1805					flag = true;
1806					var len = $thumbs_slider.find( '.owl-item' ).length,
1807						actives = [],
1808						i = 0;
1809
1810					index = ( index + len ) % len;
1811					if ( $image_slider ) {
1812						$image_slider.trigger( 'to.owl.carousel', [ index, duration, true ] );
1813					}
1814					$thumbs_slider.find( '.owl-item' ).removeClass( 'selected' );
1815					$thumbs_slider.find( '.owl-item:eq(' + index + ')' ).addClass( 'selected' );
1816					$thumbs_slider.data( 'currentThumb', index );
1817					$thumbs_slider.find( '.owl-item.active' ).each( function () {
1818						actives[ i++ ] = $( this ).index();
1819					} );
1820					if ( $.inArray( index, actives ) == -1 ) {
1821						if ( Math.abs( index - actives[ 0 ] ) > Math.abs( index - actives[ actives.length - 1 ] ) ) {
1822							$thumbs_slider.trigger( 'to.owl.carousel', [ ( index - actives.length + 1 ) % len, duration, true ] );
1823						} else {
1824							$thumbs_slider.trigger( 'to.owl.carousel', [ index % len, duration, true ] );
1825						}
1826					}
1827					flag = false;
1828				},
1829
1830				selectVerticalSliderThumb: function ( $image_slider, $thumbs_vertical_slider, index ) {
1831					if ( flag || !$thumbs_vertical_slider.length ) return;
1832					flag = true;
1833					var len = $thumbs_vertical_slider[ 0 ].slick.slideCount,
1834						actives = [],
1835						i = 0;
1836					index = ( index + len ) % len;
1837					if ( $image_slider ) {
1838						$image_slider.trigger( 'to.owl.carousel', [ index, duration, true ] );
1839					}
1840					$thumbs_vertical_slider.find( '.img-thumbnail' ).removeClass( 'selected' );
1841					$thumbs_vertical_slider.find( '.img-thumbnail:eq(' + index + ')' ).addClass( 'selected' );
1842					$thumbs_vertical_slider.data( 'currentThumb', index );
1843					$thumbs_vertical_slider.find( '.img-thumbnail.slick-active' ).each( function () {
1844						actives[ i++ ] = $( this ).index();
1845					} );
1846					if ( $.inArray( index, actives ) == -1 ) {
1847						if ( Math.abs( index - actives[ 0 ] ) > Math.abs( index - actives[ actives.length - 1 ] ) ) {
1848							$thumbs_vertical_slider.get( 0 ).slick.goTo( ( index - actives.length + 1 ) % len, false );
1849						} else {
1850							$thumbs_vertical_slider.get( 0 ).slick.goTo( index % len, false );
1851						}
1852					}
1853					flag = false;
1854				},
1855
1856				selectVerticalThumb: function ( $image_slider, $thumbs, index ) {
1857					if ( flag || !$thumbs.length ) return;
1858					flag = true;
1859					var len = $thumbs.find( '.img-thumbnail' ).length,
1860						i = 0;
1861
1862					index = ( index + len ) % len;
1863					if ( $image_slider ) {
1864						$image_slider.trigger( 'to.owl.carousel', [ index, duration, true ] );
1865					}
1866					$thumbs.find( '.img-thumbnail' ).removeClass( 'selected' );
1867					$thumbs.find( '.img-thumbnail:eq(' + index + ')' ).addClass( 'selected' );
1868					$thumbs.data( 'currentThumb', index );
1869					flag = false;
1870				}
1871			}
1872
1873		} );
1874
1875	} ).apply( this, [ window.theme, jQuery ] );
1876
1877
1878	// Woocommerce Quick View
1879	( function ( theme, $ ) {
1880
1881		theme = theme || {};
1882
1883		$.extend( theme, {
1884
1885			WooQuickView: {
1886
1887				initialize: function () {
1888
1889					this.events();
1890
1891					return this;
1892				},
1893
1894				events: function () {
1895					var self = this;
1896
1897					$( document ).on( 'click', '.quickview', function ( e ) {
1898						e.preventDefault();
1899
1900						if ( !$.fn.elevateZoom && !$( '#porto-scr
1900ipt-jquery-elevatezoom' ).length ) {
1901							var js = document.createElement( 'script' );
1902							js.id = 'porto-script-jquery-elevatezoom';
1903							$( js ).appendTo( 'body' ).attr( 'src', js_porto_vars.ajax_loader_url.replace( '/images/[email protected]', '/js/libs/jquery.elevatezoom.min.js' ) );
1904						}
1905
1906						var $this = $( this ),
1907							pid = $this.attr( 'data-id' );
1908
1909						function init_quick_view_window() {
1910
1911							var args = {
1912								href: theme.ajax_url,
1913								ajax: {
1914									data: {
1915										action: 'porto_product_quickview',
1916										variation_flag: typeof wc_add_to_cart_variation_params !== 'undefined',
1917										pid: pid,
1918										nonce: js_porto_vars.porto_nonce
1919									}
1920								},
1921								type: 'ajax',
1922								helpers: {
1923									overlay: {
1924										locked: true,
1925										fixed: true
1926									}
1927								},
1928								tpl: {
1929									error: '<p class="fancybox-error">' + theme.request_error + '</p>',
1930									closeBtn: '<a title="' + js_porto_vars.popup_close + '" class="fancybox-item fancybox-close" href="javascript:;"></a>',
1931									next: '<a title="' + js_porto_vars.popup_next + '" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
1932									prev: '<a title="' + js_porto_vars.popup_prev + '" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
1933								},
1934								autoSize: true,
1935								autoWidth: true,
1936								afterShow: function ( flag ) {
1937									theme.requestTimeout( function () {
1938										if ( typeof flag == 'undefined' || flag ) {
1939											porto_woocommerce_init();
1940										}
1941										theme.WooProductImageSlider.initialize( $( '.quickview-wrap-' + pid ).find( '.product-image-slider' ) );
1942
1943										// compatibility issue with Yith WooCommerce Booking form
1944										if ( $( document.body ).hasClass( 'yith-booking' ) ) {
1945											$( document ).trigger( 'yith-wcbk-init-booking-form' );
1946										}
1947
1948										// Variation Form
1949										var form_variation = $( '.quickview-wrap-' + pid ).find( 'form.variations_form' );
1950										if ( form_variation.length > 0 ) {
1951											form_variation.wc_variation_form();
1952										}
1953										$( document.body ).trigger( 'porto_init_countdown', [ $( '.quickview-wrap-' + pid ) ] );
1954									}, 200 );
1955								},
1956								onUpdate: function () {
1957									theme.requestTimeout( function () {
1958										if ( js_porto_vars.use_skeleton_screen.indexOf( 'quickview' ) == -1 || !js_porto_vars.quickview_skeleton ) {
1959											porto_woocommerce_init();
1960										}
1961										var $slider = $( '.quickview-wrap-' + pid ).find( '.product-image-slider' );
1962										if ( typeof $slider.data( 'owl.carousel' ) != 'undefined' && typeof $slider.data( 'owl.carousel' )._invalidated != 'undefined' )
1963											$slider.data( 'owl.carousel' )._invalidated.width = true;
1964										$slider.trigger( 'refresh.owl.carousel' );
1965										$( document.body ).trigger( 'porto_init_countdown', [ $( '.quickview-wrap-' + pid ) ] );
1966									}, 300 );
1967								}
1968							};
1969							if ( js_porto_vars.use_skeleton_screen.indexOf( 'quickview' ) != -1 && js_porto_vars.quickview_skeleton ) {
1970								delete args[ 'href' ];
1971								delete args[ 'ajax' ];
1972								args[ 'type' ] = 'inline';
1973								$.fancybox.open(
1974									js_porto_vars.quickview_skeleton,
1975									args
1976								);
1977								$.ajax( {
1978									url: theme.ajax_url,
1979									type: 'post',
1980									dataType: 'html',
1981									data: {
1982										action: 'porto_product_quickview',
1983										variation_flag: typeof wc_add_to_cart_variation_params !== 'undefined',
1984										pid: pid,
1985										nonce: js_porto_vars.porto_nonce
1986									},
1987									success: function ( res ) {
1988										var $res = $( res );
1989										$res.imagesLoaded( function () {
1990											$( '.skeleton-body.product' ).replaceWith( $res );
1991											theme.WooQtyField.initialize();
1992											$( window ).trigger( 'resize' );
1993											args[ 'afterShow' ].call( false );
1994										} );
1995									}
1996								} );
1997							} else {
1998								$.fancybox( args );
1999							}
2000						}
2001
2002						if ( $.fn.fancybox ) {
2003							init_quick_view_window();
2004						} else if ( !$( '#porto-script-jquery-fancybox' ).length ) {
2005							var js1 = document.createElement( 'script' );
2006							js1.id = 'porto-script-jquery-fancybox';
2007							$( js1 ).appendTo( 'body' ).on( 'load', function () {
2008								init_quick_view_window();
2009							} ).attr( 'src', js_porto_vars.ajax_loader_url.replace( '/images/[email protected]', '/js/libs/jquery.fancybox.min.js' ) );
2010						}
2011
2012						return false;
2013					} );
2014
2015					// ajax add to cart on quickview
2016					if ( typeof wc_add_to_cart_params != 'undefined' ) {
2017						$( document.body ).on( 'click', '.single-product .single_add_to_cart_button:not(.disabled)', function ( e ) {
2018							if ( $( this ).closest( '.single-product' ).hasClass( 'product-type-external' ) || $( this ).closest( '.single-product' ).hasClass( 'product-type-grouped' ) ) {
2019								return true;
2020							}
2021							e.preventDefault();
2022
2023							var $button = $( this ),
2024								product_id = $button.val(),
2025								variation_id = $button.closest( 'form' ).find( 'input[name="variation_id"]' ).val(),
2026								quantity = $button.closest( 'form' ).find( 'input[name="quantity"]' ).val();
2027							if ( $button.hasClass( 'loading' ) ) {
2028								return false;
2029							}
2030							$button.removeClass( 'added' );
2031							$button.addClass( 'loading' );
2032							$button.parent().addClass( 'porto-ajax-loading' );
2033							if ( !$button.siblings( '.porto-loading-icon' ).length ) {
2034								$( '<span class="porto-loading-icon"></span>' ).insertAfter( $button );
2035							}
2036
2037							var data = {
2038								action: 'porto_add_to_cart',
2039								product_id: variation_id ? variation_id : product_id,
2040								quantity: quantity
2041							};
2042							if ( variation_id ) {
2043								var $variations = $button.closest( 'form' ).find( '.variations select' );
2044								if ( $variations.length ) {
2045									$variations.each( function () {
2046										var name = $( this ).data( 'attribute_name' ),
2047											val = $( this ).val();
2048										if ( name && val ) {
2049											data[ name ] = val;
2050										}
2051									} );
2052								}
2053							}
2054
2055							// Trigger event.
2056							$( document.body ).trigger( 'adding_to_cart', [ $button, data ] );
2057
2058							$.ajax( {
2059								type: 'POST',
2060								url: theme.ajax_url,
2061								data: data,
2062								dataType: 'json',
2063								success: function ( response ) {
2064									$button.parent().removeClass( 'porto-ajax-loading' );
2065									if ( !response ) {
2066										return;
2067									}
2068									if ( response.error && response.product_url ) {
2069										window.location = response.product_url;
2070										return;
2071									}
2072									// Redirect to cart option
2073									if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) {
2074										window.location = wc_add_to_cart_params.cart_url;
2075										return;
2076									}
2077
2078									// Trigger event.
2079									$( document.body ).trigger( 'added_to_cart', [ response.fragments, response.cart_hash, $button ] );
2080								}
2081							} );
2082						} );
2083					}
2084
2085					return self;
2086				}
2087			}
2088
2089		} );
2090
2091	} ).apply( this, [ window.theme, jQuery ] );
2092
2093
2094	// Woocommerce Qty Field
2095	( function ( theme, $ ) {
2096
2097		theme = theme || {};
2098
2099		$.extend( theme, {
2100
2101			WooQtyField: {
2102
2103				initialize: function () {
2104
2105					this.build()
2106						.events();
2107
2108					return this;
2109				},
2110
2111				qty_handler: function () {
2112					var $obj = $( this );
2113					if ( $obj.closest( '.quantity' ).next( '.add_to_cart_button[data-quantity]' ).length ) {
2114						var count = $obj.val();
2115						if ( count ) {
2116							$obj.closest( '.quantity' ).next( '.add_to_cart_button[data-quantity]' ).attr( 'data-quantity', count );
2117						}
2118					}
2119				},
2120
2121				build: function () {
2122					var self = this;
2123
2124					// Quantity buttons
2125					$( '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>' );
2126
2127					// Target quantity inputs on product pages
2128					$( 'input.qty:not(.product-quantity input.qty)' ).each( function () {
2129						var min = parseFloat( $( this ).attr( 'min' ) );
2130
2131						if ( min && min > 0 && parseFloat( $( this ).val() ) < min ) {
2132							$( this ).val( min );
2133						}
2134					} );
2135
2136					$( 'input.qty:not(.product-quantity input.qty)' ).off( 'change', self.qty_handler ).on( 'change', self.qty_handler );
2137
2138					$( document ).off( 'click', '.quantity .plus, .quantity .minus' ).on( 'click', '.quantity .plus, .quantity .minus', function () {
2139
2140						// Get values
2141						var $qty = $( this ).closest( '.quantity' ).find( '.qty' ),
2142							currentVal = parseFloat( $qty.val() ),
2143							max = parseFloat( $qty.attr( 'max' ) ),
2144							min = parseFloat( $qty.attr( 'min' ) ),
2145							step = $qty.attr( 'step' );
2146
2147						// Format values
2148						if ( !currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0;
2149						if ( max === '' || max === 'NaN' ) max = '';
2150						if ( min === '' || min === 'NaN' ) min = 0;
2151						if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) === 'NaN' ) step = 1;
2152
2153						// Change the value
2154						if ( $( this ).is( '.plus' ) ) {
2155
2156							if ( max && ( max == currentVal || currentVal > max ) ) {
2157								$qty.val( max );
2158							} else {
2159								$qty.val( currentVal + parseFloat( step ) );
2160							}
2161
2162						} else {
2163
2164							if ( min && ( min == currentVal || currentVal < min ) ) {
2165								$qty.val( min );
2166							} else if ( currentVal > 0 ) {
2167								$qty.val( currentVal - parseFloat( step ) );
2168							}
2169
2170						}
2171
2172						// Trigger change event
2173						$qty.trigger( 'change' );
2174					} );
2175
2176					return self;
2177				},
2178
2179				events: function () {
2180					var self = this;
2181
2182					$( document ).ajaxComplete( function ( event, xhr, options ) {
2183						self.build();
2184					} );
2185
2186					return self;
2187				}
2188			}
2189
2190		} );
2191
2192	} ).apply( this, [ window.theme, jQuery ] );
2193
2194
2195	// Woocommerce Variation Form
2196	( function ( theme, $ ) {
2197
2198		theme = theme || {};
2199
2200		var duration = 300;
2201
2202		$.extend( theme, {
2203
2204			WooVariationForm: {
2205
2206				initialize: function () {
2207
2208					this.init().events();
2209
2210					return this;
2211				},
2212
2213				init: function () {
2214					$( '.variations_form' ).each( function () {
2215						var $variation_form = $( this ),
2216							$reset_variations = $variation_form.find( '.reset_variations' );
2217
2218						if ( $reset_variations.css( 'visibility' ) == 'hidden' )
2219							$reset_variations.hide();
2220					} );
2221					return this;
2222				},
2223
2224				events: function () {
2225					var self = this;
2226
2227					$( document ).on( 'check_variations', '.variations_form', function ( event, exclude, focus ) {
2228						var $variation_form = $( this ),
2229							$reset_variations = $variation_form.find( '.reset_variations' );
2230
2231						if ( $reset_variations.css( 'visibility' ) == 'hidden' )
2232							$reset_variations.hide();
2233					} );
2234
2235					$( document ).on( 'reset_image', '.variations_form', function ( event ) {
2236						var $product = $( this ).closest( '.product, .product-col' ),
2237							$product_img = $product.find( 'div.product-images .woocommerce-main-image' );
2238						if ( $product.hasClass( 'product-col' ) ) { // shop pages
2239							$product_img = $product.find( 'div.product-image .inner img:first-child' );
2240						} else if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder
2241							$product_img = $product.find( '.porto-tb-featured-image img' ).eq( 0 );
2242						}
2243						var o_src = $product_img.attr( 'data-o_src' ),
2244							o_title = $product_img.attr( 'data-o_title' ),
2245							o_href = $product_img.attr( 'data-o_href' ),
2246							$thumb_img = $product.find( '.woocommerce-main-thumb' ),
2247							o_thumb_src = $thumb_img.attr( 'data-o_src' );
2248
2249						var $image_slider = $product.find( '.product-image-slider' ),
2250							$thumbs_slider = $product.find( '.product-thumbs-slider' ),
2251							links;
2252
2253						if ( $image_slider.length ) {
2254							$image_slider.trigger( 'to.owl.carousel', [ 0, duration, true ] );
2255							links = $image_slider.data( 'links' );
2256						}
2257						if ( $thumbs_slider.length ) {
2258							$thumbs_slider.trigger( 'to.owl.carousel', [ 0, duration, true ] );
2259							$thumbs_slider.find( '.owl-item:eq(0)' ).trigger( 'click' );
2260						}
2261
2262						if ( o_src ) {
2263							$product_img
2264								.attr( 'src', o_src )
2265								.attr( 'srcset', '' )
2266								.attr( 'alt', o_title )
2267								.attr( 'href', o_href );
2268
2269							$product_img.each( function () {
2270								var elevateZoom = $( this ).data( 'elevateZoom' );
2271								if ( typeof elevateZoom != 'undefined' ) {
2272									elevateZoom.swaptheimage( $( this ).attr( 'src' ), $( this ).attr( 'src' ) );
2273								}
2274							} );
2275
2276							if ( theme.product_image_popup && typeof links != 'undefined' ) {
2277								links[ 0 ].src = o_href;
2278								links[ 0 ].title = o_title;
2279							}
2280						}
2281						if ( o_thumb_src ) {
2282							$thumb_img.attr( 'src', o_thumb_src );
2283						}
2284					} );
2285
2286					$( document ).on( 'found_variation', '.variations_form', function ( event, variation ) {
2287
2288						if ( typeof variation == 'undefined' ) {
2289							return;
2290						}
2291
2292						var $product = $( this ).closest( '.product, .product-col' ),
2293							$image_slider = $product.find( '.product-image-slider' ),
2294							$thumbs_slider = $product.find( '.product-thumbs-slider' ),
2295							links;
2296
2297						if ( $image_slider.length ) {
2298							$image_slider.trigger( 'to.owl.carousel', [ 0, duration, true ] );
2299							links = $image_slider.data( 'links' );
2300						}
2301						if ( $thumbs_slider.length ) {
2302							$thumbs_slider.trigger( 'to.owl.carousel', [ 0, duration, true ] );
2303							$thumbs_slider.find( '.owl-item:eq(0)' ).trigger( 'click' );
2304						}
2305
2306						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' ),
2307							productimage = $shop_single_image.attr( 'data-o_src' ),
2308							imagetitle = $shop_single_image.attr( 'data-o_title' ),
2309							imagehref = $shop_single_image.attr( 'data-o_href' ),
2310							$shop_thumb_image = $product.find( '.woocommerce-main-thumb' ),
2311							thumbimage = $shop_thumb_image.attr( 'data-o_src' ),
2312							variation_image = variation.image_src,
2313							variation_link = variation.image_link,
2314							variation_title = variation.image_title,
2315							variation_thumb = variation.image_thumb;
2316
2317						if ( $product.hasClass( 'product-col' ) ) { // shop pages
2318							$shop_single_image = $product.find( 'div.product-image .inner img:first-child' );
2319							variation_image = variation.image.thumb_src;
2320						} else if ( $product.hasClass( 'porto-tb-item' ) ) { // in type builder
2321							$shop_single_image = $product.find( '.porto-tb-featured-image img' ).eq( 0 );
2322							variation_image = variation.image.thumb_src;
2323						}
2324
2325						if ( !productimage ) {
2326							productimage = $shop_single_image.attr( 'data-oi' ) ? $shop_single_image.attr( 'data-oi' ) : ( ( !$shop_single_image.attr( 'src' ) ) ? '' : $shop_single_image.attr( 'src' ) );
2327							$shop_single_image.attr( 'data-o_src', productimage );
2328						}
2329
2330						if ( !imagehref ) {
2331							imagehref = ( !$shop_single_image.attr( 'href' ) ) ? '' : $shop_single_image.attr( 'href' );
2332							$shop_single_image.attr( 'data-o_href', imagehref );
2333						}
2334
2335						if ( !imagetitle ) {
2336							imagetitle = ( !$shop_single_image.attr( 'alt' ) ) ? '' : $shop_single_image.attr( 'alt' );
2337							$shop_single_image.attr( 'data-o_title', imagetitle );
2338						}
2339
2340						if ( !thumbimage ) {
2341							thumbimage = $shop_thumb_image.attr( 'data-oi' ) ? $shop_thumb_image.attr( 'data-oi' ) : ( ( !$shop_thumb_image.attr( 'src' ) ) ? '' : $shop_thumb_image.attr( 'src' ) );
2342							$shop_thumb_image.attr( 'data-o_src', thumbimage );
2343						}
2344
2345						if ( variation_image ) {
2346							$shop_single_image.attr( 'src', variation_image );
2347							$shop_single_image.attr( 'srcset', '' );
2348							$shop_single_image.attr( 'alt', variation_title );
2349							$shop_single_image.attr( 'href', variation_link );
2350							$shop_thumb_image.attr( 'src', variation_thumb );
2351							if ( theme.product_image_popup && typeof links != 'undefined' ) {
2352								links[ 0 ].src = variation_link;
2353								links[ 0 ].title = variation_title;
2354							}
2355						} else {
2356							$shop_single_image.attr( 'src', productimage );
2357							$shop_single_image.attr( 'srcset', '' );
2358							$shop_single_image.attr( 'alt', imagetitle );
2359							$shop_single_image.attr( 'href', imagehref );
2360							$shop_thumb_image.attr( 'src', thumbimage );
2361							if ( theme.product_image_popup && typeof links != 'undefined' ) {
2362								links[ 0 ].src = imagehref;
2363								links[ 0 ].title = imagetitle;
2364							}
2365						}
2366						$shop_single_image.each( function () {
2367							var elevateZoom = $( this ).data( 'elevateZoom' );
2368							if ( typeof elevateZoom != 'undefined' ) {
2369								elevateZoom.swaptheimage( $( this ).attr( 'src' ), $( this ).attr( 'src' ) );
2370							}
2371						} );
2372					} );
2373
2374					// fix scrolling to top issue on fancybox quickview whenever updating variation
2375					var porto_fb_update_trigger = null;
2376					$( document ).on( 'found_variation reset_image', '.variations_form', function ( event, variation ) {
2377						if ( $( this ).closest( '.fancybox-inner' ).length && $.fancybox ) {
2378							$( window ).off( 'resize.fb', $.fancybox.update );
2379							if ( porto_fb_update_trigger ) {
2380								theme.deleteTimeout( porto_fb_update_trigger );
2381							}
2382							porto_fb_update_trigger = theme.requestTimeout( function () {
2383								$( window ).on( 'resize.fb', $.fancybox.update );
2384								porto_fb_update_trigger = false;
2385							}, 160 );
2386						}
2387					} );
2388
2389					return self;
2390				}
2391			}
2392
2393		} );
2394
2395	} ).apply( this, [ window.theme, jQuery ] );
2396
2397
2398	// Woocommerce Events
2399	( function ( theme, $ ) {
2400
2401		theme = theme || {};
2402
2403		$.extend( theme, {
2404
2405			WooEvents: {
2406
2407				initialize: function () {
2408
2409					this.events();
2410
2411					return this;
2412				},
2413
2414				events: function () {
2415					var self = this;
2416
2417					// wcml currency switcher
2418					$( '.wcml-switcher li' ).on( 'click', function () {
2419						if ( $( this ).parent().attr( 'disabled' ) == 'disabled' )
2420							return;
2421						var currency = $( this ).attr( 'rel' );
2422						self.loadCurrency( currency );
2423					} );
2424
2425					// woocommerce currency switcher
2426					$( '.woocs-switcher li' ).on( 'click', function () {
2427						if ( $( this ).parent().attr( 'disabled' ) == 'disabled' )
2428							return;
2429						var currency = $( this ).attr( 'rel' );
2430						self.loadWoocsCurrency( currency );
2431					} );
2432
2433					return self;
2434				},
2435
2436				loadCurrency: function ( currency ) {
2437					$( '.wcml-switcher' ).attr( 'disabled', 'disabled' );
2438					$( '.wcml-switcher' ).append( '<li class="loading"></li>' );
2439					var data = { action: 'wcml_switch_currency', currency: currency };
2440					$.ajax( {
2441						type: 'post',
2442						url: theme.ajax_url,
2443						data: {
2444							action: 'wcml_switch_currency',
2445							currency: currency
2446						},
2447						success: function ( response ) {
2448							$( '.wcml-switcher' ).removeAttr( 'disabled' );
2449							$( '.wcml-switcher' ).find( '.loading' ).remove();
2450							window.location = window.location.href;
2451						}
2452					} );
2453				},
2454
2455				loadWoocsCurrency: function ( currency ) {
2456					$( '.woocs-switcher' ).attr( 'disabled', 'disabled' );
2457					$( '.woocs-switcher' ).append( '<li class="loading"></li>' );
2458					var l = window.location.href;
2459					l = l.split( '?' );
2460					l = l[ 0 ];
2461					var string_of_get = '?';
2462					woocs_array_of_get.currency = currency;
2463
2464					if ( Object.keys( woocs_array_of_get ).length > 0 ) {
2465						jQuery.each( woocs_array_of_get, function ( index, value ) {
2466							string_of_get = string_of_get + "&" + index + "=" + value;
2467						} );
2468					}
2469					window.location = l + string_of_get;
2470				},
2471
2472				removeParameterFromUrl: function ( url, parameter ) {
2473					return url
2474						.replace( new RegExp( '[?&]' + parameter + '=[^&#]*(#.*)?$' ), '$1' )
2475						.replace( new RegExp( '([?&])' + parameter + '=[^&]*&' ), '$1' );
2476				}
2477			}
2478
2479		} );
2480
2481	} ).apply( this, [ window.theme, jQuery ] );
2482
2483	( function ( theme, $ ) {
2484
2485		$( document ).ready( function () {
2486			// Woocommerce Qty Field
2487			if ( typeof theme.WooQtyField !== 'undefined' ) {
2488				theme.WooQtyField.initialize();
2489			}
2490
2491			// Woocommerce Quick View
2492			if ( typeof theme.WooQuickView !== 'undefined' ) {
2493				theme.WooQuickView.initialize();
2494			}
2495
2496			// Woocommerce Events
2497			if ( typeof theme.WooEvents !== 'undefined' ) {
2498				theme.WooEvents.initialize();
2499			}
2500
2501			// disable drop down
2502			if ( !( 'ontouchstart' in document ) ) {
2503				$( '.mini-cart' ).on( 'hide.bs.dropdown', function () {
2504					return false;
2505				} );
2506			} else {
2507				$( '#mini-cart .cart-head' ).on( 'click', function ( e ) {
2508					$( this ).parent().toggleClass( 'open' );
2509				} );
2510				$( 'html,body' ).on( 'click', function ( e ) {
2511					if ( $( '#mini-cart' ).hasClass( 'open' ) && !$( e.target ).closest( '#mini-cart' ).length ) {
2512						$( '#mini-cart' ).removeClass( 'open' );
2513					}
2514				} );
2515			}
2516
2517			$( document ).on( 'tabactivate', '.woocommerce-tabs', function ( e, ui ) {
2518				var label = $( ui ).attr( 'aria-controls' );
2519				var panel = $( '[aria-labelledby="' + label + '"' );
2520				theme.refreshVCContent( panel );
2521			} );
2522		} );
2523	} ).apply( this, [ window.theme, jQuery ] );
2524
2525
2526	( function ( theme, $, undefined ) {
2527
2528		$( document ).ready( function () {
2529			// Woocommerce Variation Form
2530			theme.WooVariationForm.initialize();
2531
2532			// Woocommerce Product Image Slider
2533			if ( typeof theme.initAsync == 'function' ) {
2534				theme.WooProductImageSlider.initialize();
2535				porto_woocommerce_init();
2536			} else {
2537				$.when( theme.asyncDeferred ).done( function () {
2538					theme.WooProductImageSlider.initialize();
2539					porto_woocommerce_init();
2540				} );
2541			}
2542
2543			// Sales Popup
2544			if ( typeof theme.salesPopup !== 'undefined' && !document.getElementById( 'yith-woocompare' ) && window.Worker ) {
2545				theme.salesPopup.initialize();
2546			}
2547
2548			$( window ).on( 'vc_reload', function () {
2549				porto_woocommerce_init();
2550				$( '.type-product' ).addClass( 'product' );
2551			} );
2552
2553			// Add wishlist popup
2554			/*if ( !$( '#yith-wcwl-popup-message' ).length ) {
2555				$( 'body' ).prepend( $( '<div>' ).attr( 'id', 'yith-wcwl-popup-message' ).html( '<div id="yith-wcwl-message"></div>' ).hide() );
2556			}*/
2557
2558			// shop horizontal filter
2559			$( document ).on( 'click', '.porto-product-filters-toggle a', function ( e ) {
2560				e.preventDefault();
2561				$( this ).closest( '.porto-product-filters-toggle' ).toggleClass( 'opened' );
2562				var $products_wrapper = $( this ).closest( '#main' ).find( '.main-content' ).find( 'ul.products' ), offset, $main = $( this ).closest( '#main' ).find( '.main-content-wrap' );
2563				$main.toggleClass( 'opened' );
2564				if ( $main.hasClass( 'opened' ) ) {
2565					offset = -1;
2566				} else {
2567					offset = 1;
2568				}
2569				if ( $products_wrapper.hasClass( 'grid' ) ) {
2570					var cols_lg_index = 0, cols_md_index = 0, width_lg_index = 0, width_md_index = 0;
2571					for ( var i = 1; i <= 8; i++ ) {
2572						if ( !cols_lg_index && $products_wrapper.hasClass( 'pcols-lg-' + i ) ) {
2573							cols_lg_index = i;
2574							if ( i + offset >= 1 ) {
2575								$products_wrapper.removeClass( 'pcols-lg-' + i );
2576								$products_wrapper.addClass( 'pcols-lg-' + ( i + offset ) );
2577							}
2578						}
2579						if ( !cols_md_index && $products_wrapper.hasClass( 'pcols-md-' + i ) ) {
2580							cols_md_index = i;
2581							if ( i + offset >= 1 ) {
2582								$products_wrapper.removeClass( 'pcols-md-' + i );
2583								if ( offset === -1 ) {
2584									$products_wrapper.addClass( 'pcols-sm-' + i );
2585								}
2586								$products_wrapper.addClass( 'pcols-md-' + ( i + offset ) );
2587							}
2588						}
2589						if ( !width_lg_index && $products_wrapper.hasClass( 'pwidth-lg-' + i ) ) {
2590							width_lg_index = i;
2591							if ( i + offset >= 1 ) {
2592								$products_wrapper.removeClass( 'pwidth-lg-' + i );
2593								$products_wrapper.addClass( 'pwidth-lg-' + ( i + offset ) );
2594							}
2595						}
2596						if ( !width_md_index && $products_wrapper.hasClass( 'pwidth-md-' + i ) ) {
2597							width_md_index = i;
2598							if ( i + offset >= 1 ) {
2599								$products_wrapper.removeClass( 'pwidth-md-' + i );
2600								$products_wrapper.addClass( 'pwidth-md-' + ( i + offset ) );
2601							}
2602						}
2603					}
2604				}
2605				theme.requestTimeout( function () {
2606					$( window ).trigger( 'scroll' );
2607				}, 300 );
2608
2609				if ( $main.hasClass( 'opened' ) ) {
2610					$.cookie( 'porto_horizontal_filter', 'opened' );
2611				} else {
2612					$.cookie( 'porto_horizontal_filter', 'closed' );
2613				}
2614				return false;
2615			} );
2616			if ( $.cookie && 'opened' == $.cookie( 'porto_horizontal_filter' ) && $( '#main .porto-products-filter-body' ).length && !theme.isTablet() ) {
2617				$( '.porto-product-filters-toggle a' ).trigger( 'click' );
2618				$( '#main .porto-products-filter-body [data-plugin-sticky]:not(.manual)' ).addClass( 'manual' );
2619				setTimeout( function () {
2620					var $obj = $( '#main .porto-products-filter-body [data-plugin-sticky].manual' ),
2621						pluginOptions = $obj.data( 'plugin-options' );
2622					$obj.removeClass( 'manual' ).themeSticky( pluginOptions );
2623					theme.requestTimeout( function () {
2624						$( window ).trigger( 'scroll' );
2625					}, 100 );
2626				}, 500 );
2627			}
2628
2629			$( document ).on( 'click', '.porto-product-filters.style2 .widget-title', function ( e ) {
2630				e.preventDefault();
2631				if ( $( this ).next().is( ':hidden' ) ) {
2632					$( '.porto-product-filters.style2 .widget-title' ).next().hide();
2633					$( '.porto-product-filters.style2 .widget' ).removeClass( 'opened' );
2634					$( this ).next().show();
2635					$( this ).next().find( 'input[type="text"]:first-child' ).focus();
2636				} else {
2637					$( this ).next().hide();
2638				}
2639				$( this ).parent().toggleClass( 'opened' );
2640				return false;
2641			} );
2642			$( 'body' ).on( 'click', function ( e ) {
2643				if ( !$( e.target ).is( '.porto-product-filters' ) && !$( e.target ).is( '.porto-product-filters *' ) ) {
2644					$( '.porto-product-filters.style2 .widget-title' ).next().hide();
2645					$( '.porto-product-filters.style2 .widget' ).removeClass( 'opened' );
2646				}
2647			} );
2648
2649			// Perform AJAX login on form submit
2650			$( 'body' ).on( 'click', '#login-form-popup form .woocommerce-Button', function ( e ) {
2651				var $this = $( this ),
2652					$form = $this.closest( 'form' ),
2653					isLogin = $this.hasClass( 'login-btn' );
2654				if ( !isLogin && !$this.hasClass( 'register-btn' ) ) {
2655					isLogin = $form.hasClass( 'login' );
2656				}
2657				$form.find( '#email' ).val( $form.find( '#username' ).val() );
2658				$form.find( 'p.status' ).show().text( 'Please wait...' ).addClass( 'loading' );
2659				$form.find( 'button[type=submit]' ).attr( 'disabled', 'disabled' );
2660				$.ajax( {
2661					type: 'POST',
2662					dataType: 'json',
2663					url: theme.ajax_url,
2664					data: $form.serialize() + '&action=porto_account_login_popup_' + ( isLogin ? 'login' : 'register' ),
2665					success: function ( data ) {
2666						$form.find( 'p.status' ).html( data.message.replace( '/<script.*?\/script>/s', '' ) ).removeClass( 'loading' );
2667						$form.find( 'button[type=submit]' ).removeAttr( 'disabled' );
2668						if ( data.loggedin === true ) {
2669							window.location.reload();
2670						}
2671					}
2672				} );
2673				e.preventDefault();
2674			} );
2675
2676			// shortcodes
2677			var $ajax_tab_cache = {};
2678			$( document ).on( 'click', '.porto-products.show-category .product-categories a', function ( e ) {
2679				e.preventDefault();
2680				var $this = $( this ), $form = $this.closest( '.porto-products' ).find( '.pagination-form' ), id = $this.closest( '.porto-products' ).attr( 'id' ), group = [];
2681				$( this ).parent().siblings().removeClass( 'current' );
2682				$( this ).parent().addClass( 'current' );
2683				if ( typeof $this.data( 'sort_id' ) != 'undefined' ) {
2684					$form.find( 'input[name="orderby"]' ).val( $this.data( 'sort_id' ) );
2685					group = $this.data( 'sort_id' );
2686					$form.find( 'input[name="category"]' ).val( '' );
2687				}
2688				if ( typeof $this.data( 'cat_id' ) != 'undefined' ) {
2689					if ( typeof $this.data( 'sort_id' ) == 'undefined' ) {
2690						$form.find( 'input[name="orderby"]' ).val( $form.find( 'input[name="original_orderby"]' ).val() );
2691						group = $form.find( 'input[name="original_orderby"]' ).val();
2692					}
2693					if ( typeof $form.data( 'original_cat_id' ) == 'undefined' ) {
2694						$form.data( 'original_cat_id', $form.find( 'input[name="category"]' ).val() );
2695						group = $form.find( 'input[name="category"]' ).val();
2696					}
2697					if ( $this.data( 'cat_id' ) ) {
2698						$form.find( 'input[name="category"]' ).val( $this.data( 'cat_id' ) );
2699						group = $this.data( 'cat_id' );
2700					} else {
2701						if ( $form.data( 'original_cat_id' ) ) {
2702							$form.find( 'input[name="category"]' ).val( $form.data( 'original_cat_id' ) );
2703							group = $form.data( 'original_cat_id' );
2704						} else {
2705							$form.find( 'input[name="category"]' ).val( '' );
2706							group = '';
2707						}
2708					}
2709				}
2710				var data = $form.serialize() + '&product-page=1&action=porto_woocommerce_shortcodes_products&nonce=' + js_porto_vars.porto_nonce;
2711				$this.closest( '.porto-products' ).find( 'ul.products' ).trigger( 'porto_update_products', [ data, '', $this, id, group ] );
2712			} );
2713			$( document ).on( 'click', '.porto-products .page-numbers a', function ( e ) {
2714				var $this = $( this ), pagination_style,
2715					$shop_container = $this.closest( '.porto-products' ).find( 'ul.products' ),
2716					cur_page = $shop_container.data( 'cur_page' ),
2717					max_page = $shop_container.data( 'max_page' ),
2718					$form = $this.closest( '.porto-products' ).find( '.pagination-form' );
2719				e.preventDefault();
2720				if ( $this.closest( '.pagination' ).hasClass( 'load-more' ) ) {
2721					if ( !cur_page || !max_page || ++cur_page > max_page ) {
2722						return;
2723					}
2724					pagination_style = 'load_more';
2725					$this.data( 'text', $this.text() );
2726					$this.text( js_porto_vars.loader_text );
2727				} else {
2728					var url = new RegExp( "product-page(=|/)([^(&|/)]*)", "i" ).exec( this.href );
2729					cur_page = url && unescape( url[ 2 ] ) || "";
2730					pagination_style = 'default';
2731				}
2732				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;
2733				$shop_container.trigger( 'porto_update_products', [ data, pagination_style, $this ] );
2734				if ( 'default' == pagination_style ) {
2735					theme.scrolltoContainer( $shop_container );
2736				}
2737			} );
2738			$( document ).on( 'porto_update_products', 'ul.products', function ( e, data, pagination_style, $obj, id, group ) {
2739				var $this = $( this );
2740				// ajax tab
2741				if ( undefined == $ajax_tab_cache[ id ] || -1 == Object.keys( $ajax_tab_cache[ id ] ).indexOf( group ) ) {
2742					porto_ajax_load_products( $this, data, pagination_style, $ajax_tab_cache, id, group );
2743				} else {
2744					var response = $ajax_tab_cache[ id ][ group ];
2745					//animation
2746					$this.css( 'opacity', 0 );
2747					$this.animate(
2748						{
2749							'opacity': 1,
2750						},
2751						400,
2752						function () {
2753							$this.css( 'opacity', '' );
2754						}
2755					);
2756
2757					porto_ajax_load_products_success( $this, response, pagination_style );
2758				}
2759			} );
2760		} );
2761
2762
2763		// shortcode: porto_one_page_category_products
2764		$( '.porto-onepage-category.show-products .category-section .sub-category' ).children( '.cat-item' ).addClass( 'product-col' );
2765		$( document ).on( 'click', '.porto-onepage-category .sub-category a', function ( e ) {
2766			var $this = $( this ), category, data;
2767			category = new RegExp( "cat-item-([^( |\")]*)", "i" ).exec( $this.parent().attr( 'class' ) );
2768			category = category && unescape( category[ 1 ] ) || "";
2769			if ( category ) {
2770				data = $this.closest( '.category-details' ).find( '.ajax-form' ).serialize() + '&action=porto_woocommerce_shortcodes_products&category_description=true&category=' + category + '&nonce=' + js_porto_vars.porto_nonce;
2771				e.preventDefault();
2772				$this.closest( '.category-section' ).find( '.woocommerce > ul.products' ).trigger( 'porto_update_products', [ data, '' ] );
2773			}
2774		} );
2775		var scrollspyData = null;
2776		$( document ).on( 'porto_theme_init', function () {
2777			if ( $( '.porto-onepage-category.show-products' ).length && typeof bootstrap != 'undefined' ) {
2778				document.body.style.position = 'relative';
2779				scrollspyData = new bootstrap.ScrollSpy( 'body', { target: '.porto-onepage-category.show-products .category-list', offset: theme.StickyHeader.sticky_height + theme.adminBarHeight() + theme.sticky_nav_height + 20 } );
2780				var previousScrollTop = 0, $loadObj;
2781				window.addEventListener( 'scroll', function () {
2782					if ( !$( '.porto-onepage-category.show-products.ajax-load .category-section:not(.ajax-loaded)' ).length ) {
2783						return;
2784					}
2785					var currentScrollTop = $( window ).scrollTop();
2786					if ( previousScrollTop > currentScrollTop ) { // up
2787						$loadObj = $( '.porto-onepage-category.show-products.ajax-load .category-section:not(.ajax-loaded)' ).last();
2788					} else { //down
2789						$loadObj = $( '.porto-onepage-category.show-products.ajax-load .category-section:not(.ajax-loaded)' ).eq( 0 );
2790					}
2791					previousScrollTop = $( window ).scrollTop();
2792					if ( !$loadObj.closest( '.porto-onepage-category' ).hasClass( 'loading' ) && ( $loadObj.offset().top <= $( window ).scrollTop() + $( window ).innerHeight() * 0.7 ) ) {
2793						$loadObj.trigger( 'porto_load_category_products' );
2794					}
2795				}, { passive: true } );
2796			}
2797
2798			// sticky add to cart
2799			var $sticky_product_obj = $( '.single-product .sticky-product' ),
2800				is_elementor_editor = $( document.body ).hasClass( 'elementor-editor-active' );
2801			if ( $sticky_product_obj.length || is_elementor_editor ) {
2802				if ( is_elementor_editor && elementorFrontend && elementorFrontend.hooks ) {
2803					elementorFrontend.hooks.addAction( 'frontend/element_ready/porto_cp_addcart_sticky.default', function ( $obj ) {
2804						$sticky_product_obj = $( '.single-product .sticky-product' );
2805						window.dispatchEvent( new Event( 'scroll' ) );
2806					} );
2807				}
2808				window.addEventListener( 'scroll', function () {
2809					var scrollTop = $( window ).scrollTop(),
2810						offset = theme.adminBarHeight() + theme.StickyHeader.sticky_height;
2811					if ( $( 'form.cart' ).length && $( 'form.cart' ).offset().top + $( 'form.cart' ).height() / 2 <= scrollTop + offset ) {
2812						$sticky_product_obj.removeClass( 'hide' );
2813						if ( !$sticky_product_obj.hasClass( 'pos-bottom' ) ) {
2814							$sticky_product_obj.css( 'top', offset );
2815						}
2816					} else {
2817						$sticky_product_obj.addClass( 'hide' );
2818					}
2819				}, { passive: true } );
2820				$sticky_product_obj.find( '.add-to-cart .button' ).on( 'click', function ( e ) {
2821					e.preventDefault();
2822					$( '.single-product form .quantity .qty' ).val( $sticky_product_obj.find( '.add-to-cart .qty' ).val() );
2823					$( '.single-product form .single_add_to_cart_button' ).trigger( 'click' );
2824				} );
2825				$( '.single-product .entry-summary .quantity' ).clone().prependTo( '.single-product .sticky-product .add-to-cart' );
2826
2827				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' ),
2828					origin_price = $sticky_product_obj.find( '.price' ).html(),
2829					origin_stock = $sticky_product_obj.find( '.availability' ).html(),
2830					is_variation = false;
2831				$( document ).on( 'found_variation reset_data', '.variations_form', function ( e, obj ) {
2832					if ( obj ) {
2833						is_variation = true;
2834						$sticky_product_obj.find( '.sticky-image img' ).attr( 'src', obj.image_thumb ? obj.image_thumb : origin_img );
2835						$sticky_product_obj.find( '.price' ).replaceWith( obj.price_html );
2836						$sticky_product_obj.find( '.availability' ).html( obj.availability_html ? obj.availability_html : origin_stock );
2837					} else if ( is_variation ) {
2838						is_variation = false;
2839						$sticky_product_obj.find( '.sticky-image img' ).attr( 'src', origin_img );
2840						$sticky_product_obj.find( '.price' ).html( origin_price );
2841						$sticky_product_obj.find( '.availability' ).html( origin_stock );
2842					}
2843				} );
2844			}
2845
2846			// sticky filter on mobile
2847			if ( 1 === $( '.shop-loop-before' ).length && $( '.mobile-sidebar' ).length ) {
2848				var porto_progress_obj = $( '.porto-scroll-progress.fixed-under-header' ),
2849					porto_progress_height = 0;
2850				if ( porto_progress_obj.length ) {
2851					var flag = false;
2852					if ( porto_progress_obj.is( ':hidden' ) ) {
2853						porto_progress_obj.show();
2854						flag = true;
2855					}
2856					porto_progress_height = porto_progress_obj.height();
2857					if ( flag ) {
2858						porto_progress_obj.hide();
2859					}
2860				} else {
2861					porto_progress_height = 0;
2862				}
2863
2864				var init_filter_sticky = function () {
2865					var $obj = $( '.shop-loop-before' );
2866					if ( !$obj.prev( '.filter-placeholder' ).length ) {
2867						$( '<div class="filter-placeholder m-0"></div>' ).insertBefore( $obj );
2868					}
2869					var $ph = $obj.prev( '.filter-placeholder' ),
2870						scrollTop = $( window ).scrollTop(),
2871						offset = theme.adminBarHeight() + theme.StickyHeader.sticky_height + porto_progress_height - 1;
2872					if ( $( 'html.filter-sidebar-opened' ).length ) {
2873						$ph.css( 'height', '' );
2874						return;
2875					}
2876					if ( $ph.offset().top <= scrollTop + offset ) {
2877						$ph.css( 'height', $obj.outerHeight() + parseInt( $obj.css( 'margin-bottom' ) ) );
2878						$obj.addClass( 'sticky' ).css( 'top', offset );
2879					} else {
2880						$ph.css( 'height', '' );
2881						$obj.removeClass( 'sticky' );
2882					}
2883				};
2884				if ( window.innerWidth < 992 ) {
2885					window.removeEventListener( 'scroll', init_filter_sticky );
2886					window.addEventListener( 'scroll', init_filter_sticky, { passive: true } );
2887					init_filter_sticky();
2888				}
2889				var request_timer = null,
2890					old_win_width = window.innerWidth;
2891				$( window ).on( 'resize', function () {
2892					if ( old_win_width != window.innerWidth ) {
2893						if ( request_timer ) {
2894							theme.deleteTimeout( request_timer );
2895							request_timer = false;
2896						}
2897						if ( window.innerWidth < 992 ) {
2898							request_timer = theme.requestTimeout( function () {
2899								window.removeEventListener( 'scroll', init_filter_sticky );
2900								window.addEventListener( 'scroll', init_filter_sticky, { passive: true } );
2901								$( window ).trigger( 'scroll' );
2902							}, 100 );
2903						} else {
2904							window.removeEventListener( 'scroll', init_filter_sticky );
2905							$( '.shop-loop-before' ).removeClass( 'sticky' ).css( 'to
2905p', '' ).prev( '.filter-placeholder' ).css( 'height', '' );
2906						}
2907						old_win_width = window.innerWidth;
2908					}
2909				} );
2910			}
2911		} );
2912
2913		$( document ).on( 'click', '.porto-onepage-category.show-products .category-list .nav-link', function ( e ) {
2914			var $target = $( $( this ).attr( 'href' ) );
2915			if ( !$target.length ) {
2916				return;
2917			}
2918			e.preventDefault();
2919			if ( $( this ).closest( '.porto-onepage-category' ).hasClass( 'ajax-load' ) && !$target.hasClass( 'ajax-loaded' ) ) {
2920				$target.trigger( 'porto_load_category_products' );
2921			}
2922			$target.closest( '.porto-onepage-category' ).addClass( 'moving' );
2923			$( 'html, body' ).stop().animate( {
2924				scrollTop: $target.offset().top - theme.StickyHeader.sticky_height - theme.adminBarHeight() - theme.sticky_nav_height - 10
2925			}, 600, 'easeOutQuad', function () {
2926				$target.closest( '.porto-onepage-category' ).removeClass( 'moving' );
2927			} );
2928		} );
2929
2930		$( document ).on( 'porto_load_category_products', '.category-section', function () {
2931			var $target = $( this ), cat_id = $target.attr( 'id' ).replace( 'category-', '' );
2932			if ( $target.closest( '.porto-onepage-category' ).hasClass( 'loading' ) || $target.closest( '.porto-onepage-category' ).hasClass( 'moving' ) || $target.hasClass( 'ajax-loaded' ) ) {
2933				return false;
2934			}
2935			$target.css( 'min-height', 200 );
2936			$target.addClass( 'yith-wcan-loading' );
2937			if ( !$target.children( '.porto-loading-icon' ).length ) {
2938				$target.append( '<i class="porto-loading-icon"></i>' );
2939			}
2940			$target.closest( '.porto-onepage-category' ).addClass( 'loading' );
2941			var data = $target.closest( '.porto-onepage-category' ).find( '.ajax-form' ).serialize() + '&action=porto_woocommerce_shortcodes_products&category_description=true&category=' + cat_id + '&nonce=' + js_porto_vars.porto_nonce;
2942			$.ajax( {
2943				url: theme.ajax_url,
2944				data: data,
2945				type: 'post',
2946				success: function ( response ) {
2947					$target.addClass( 'ajax-loaded' );
2948					$target.append( $( response ).html() );
2949					$target.removeClass( 'yith-wcan-loading' );
2950					$( document ).trigger( 'yith-wcan-ajax-filtered' );
2951					$( window ).trigger( 'resize' );
2952					if ( scrollspyData ) {
2953						setTimeout( function () {
2954							scrollspyData.refresh();
2955						}, 300 );
2956					}
2957					$target.closest( '.porto-onepage-category' ).removeClass( 'loading' );
2958				}
2959			} );
2960		} );
2961
2962
2963		// cart page accordion
2964		$( '.cart-v2 .cart_totals .accordion-toggle.out' ).removeClass( 'out' );
2965		$( document ).ajaxComplete( function ( event, xhr, options ) {
2966			$( '.cart-v2 .cart_totals .accordion-toggle.out' ).each( function () {
2967				if ( $( $( this ).attr( 'href' ) ).length && $( $( this ).attr( 'href' ) ).is( ':hidden' ) ) {
2968					$( this ).removeClass( 'collapsed' );
2969					$( $( this ).attr( 'href' ) ).addClass( 'show' );
2970				}
2971			} );
2972		} );
2973
2974		// porto products filter element
2975		$( '.porto_products_filter_form .btn-submit' ).on( 'click', function ( e ) {
2976			e.preventDefault();
2977			var data = $( this ).closest( 'form' ).serializeArray(),
2978				submit_data = '';
2979			for ( var i in data ) {
2980				var param = data[ i ];
2981				if ( param.value ) {
2982					if ( submit_data ) {
2983						submit_data += '&';
2984					}
2985					submit_data += param.name + '=' + param.value;
2986					if ( 'min_price' == param.name ) {
2987						var max_price = $( this ).closest( 'form' ).find( '.porto_dropdown_price_range option:selected' ).data( 'maxprice' );
2988						if ( max_price ) {
2989							submit_data += '&max_price=' + max_price;
2990						}
2991					}
2992				}
2993			}
2994			location.href = $( this ).closest( 'form' ).attr( 'action' ) + '?' + submit_data;
2995		} );
2996
2997		// yith wishlist
2998		if ( $( '.wishlist_table.responsive' ).length ) {
2999			$( window ).on( 'resize', function () {
3000				var media = window.matchMedia( '(max-width: 768px)' );
3001				if ( media.matches ) {
3002					$( '.wishlist_table.responsive' ).addClass( 'mobile' );
3003				} else {
3004					$( '.wishlist_table.responsive' ).removeClass( 'mobile' );
3005				}
3006			} );
3007		}
3008
3009		// pre-order
3010		if ( js_porto_vars.pre_order ) {
3011			var porto_pre_order = {
3012				init: function () {
3013					this.$add_to_cart_btn = $( '.product-summary-wrap .single_add_to_cart_button' );
3014					this.add_to_cart_label = this.$add_to_cart_btn.html();
3015					$( '.product-summary-wrap form.variations_form' ).on( 'show_variation', function ( e, v, p ) {
3016						if ( v.porto_pre_order ) {
3017							porto_pre_order.$add_to_cart_btn.html( v.porto_pre_order_label );
3018							if ( v.porto_pre_order_date ) {
3019								$( this ).find( '.woocommerce-variation-description' ).append( v.porto_pre_order_date );
3020							}
3021						} else {
3022							porto_pre_order.$add_to_cart_btn.html( porto_pre_order.add_to_cart_label );
3023						}
3024					} ).on( 'hide_variation', function () {
3025						porto_pre_order.$add_to_cart_btn.html( porto_pre_order.add_to_cart_label );
3026					} );
3027				}
3028			};
3029			if ( $( 'div.product.skeleton-loading' ).length ) {
3030				$( 'div.product.skeleton-loading' ).on( 'skeleton-loaded', function () {
3031					porto_pre_order.init();
3032				} );
3033			} else {
3034				porto_pre_order.init();
3035			}
3036		}
3037
3038		// refresh yith wishlist
3039		if ( $( '#header .my-wishlist .wishlist-count' ).length ) {
3040			$( document.body ).on( 'added_to_wishlist removed_from_wishlist added_to_cart', function ( e ) {
3041				var $obj = $( '#header .my-wishlist .wishlist-count' );
3042				if ( $obj.text() ) {
3043					$.ajax( {
3044						type: 'POST',
3045						dataType: 'json',
3046						url: theme.ajax_url,
3047						data: {
3048							action: 'porto_refresh_wishlist_count',
3049							nonce: js_porto_vars.porto_nonce,
3050						},
3051						success: function ( response ) {
3052							if ( response || 0 === response ) {
3053								$obj.addClass( 'count-updating' ).text( Number( response ) );
3054								setTimeout( function () {
3055									$obj.removeClass( 'count-updating' );
3056								}, 1000 );
3057							}
3058						}
3059					} );
3060				}
3061			} );
3062		}
3063
3064		// fix contact form 7 role="alert" issue in cart page
3065		if ( $( document.body ).hasClass( 'woocommerce-cart' ) && $( '.wpcf7 .screen-reader-response' ).length ) {
3066			$( '.wpcf7 .screen-reader-response' ).attr( 'role', '' );
3067		}
3068
3069		// fix dokan search vendor
3070		$( '#dokan-store-listing-filter-form-wrap .store-search-input' ).on( 'keydown', function ( e ) {
3071			if ( e.which && event.which == 13 ) {
3072				$( this ).closest( 'form' ).find( '#apply-filter-btn' ).trigger( 'click' );
3073				e.preventDefault();
3074			}
3075		} );
3076
3077		// add spinner to block
3078		if ( $.fn.block ) {
3079			var funcBlock = $.fn.block;
3080			$.fn.block = function ( opts ) {
3081				if ( this.is( '.woocommerce-checkout' ) ) {
3082					this.append( '<div class="loader-container d-block"><div class="loader"><i class="porto-ajax-loader"></i></div></div>' );
3083				}
3084				funcBlock.call( this, opts );
3085			}
3086
3087			var funcUnblock = $.fn.unblock;
3088			$.fn.unblock = function ( opts ) {
3089				funcUnblock.call( this, opts );
3090				this.is( '.processing' ) || ( this.is( '.woocommerce-checkout' ) && this.children( '.loader-container' ).remove() );
3091				return this;
3092			}
3093		}
3094	} )( window.theme, jQuery );
3095
3096	// Sales Popup
3097	( function ( theme, $ ) {
3098		'use strict';
3099		theme = theme || {};
3100		if ( !js_porto_vars.sales_popup ) return;
3101		$.extend( theme, {
3102			salesPopup: {
3103				isCart: true,
3104				popupContainer: null,
3105				current: 0,
3106				products: [],
3107				worker: null,
3108				initialize: function () {
3109					if ( $( '.after-loading-success-message.style-3' ).length == 0 ) {
3110						$( 'body' ).append( '<div class="after-loading-success-message style-3 d-block"></div>' );
3111						this.isCart = false;
3112						this.popupContainer = $( '.after-loading-success-message.style-3' );
3113					}
3114					else {
3115						this.popupContainer = $( '.after-loading-success-message.style-3' );
3116						this.popupContainer.eq( 0 ).stop().show();
3117					}
3118
3119					this.popupContainer.on( 'click', '.sales-close', function () {
3120						var $obj = $( this ).closest( '.success-message-container' );
3121						$obj.removeClass( 'active' );
3122						setTimeout( function () {
3123							$obj.slideUp( 300, function () {
3124								$obj.remove();
3125							} );
3126						}, 350 );
3127					} );
3128					this.build();
3129					return this;
3130				},
3131				appendContent: function ( product ) {
3132					var message = js_porto_vars.sales_popup.title,
3133						link = product.link,
3134						date = product.date,
3135						image = product.image,
3136						price = product.price,
3137						title = product.title;
3138
3139					var $content = $( '<div class="sales-msg success-message-container"><p class="sales-popup-title">' + message +
3140						'</p><div class="msg-box mb-0"><div class="msg"><div class="product-name"><a href="' + link +
3141						'"><h3 class="product-title font-weight-bold line-height-sm mb-1">' + title + '</h3></a></div>' + '<span class="price text-primary">'
3142						+ price + '</span><p class="mt-1 mb-0' + ( date == 'not sale' ? ' d-none' : '' ) + '">' + date + '</p></div>
3142<img src="' + image + '" alt="' + title + '"/></div><button class="sales-close mfp-close"></button></div>' )
3143
3144					this.popupContainer.prepend( $content );
3145					setTimeout( function () {
3146						$content.addClass( 'active' );
3147					}, 150 );
3148					setTimeout( function () { $content.find( '.sales-close' ).trigger( 'click' ); }, 4000 );
3149				},
3150				build: function () {
3151					var self = this;
3152
3153					self.worker = new Worker( js_porto_vars.sales_popup.themeuri + '/inc/lib/woocommerce-sales-popup/worker.js' );
3154					self.worker.onmessage = function ( e ) {
3155						if ( e.data && e.data.title ) {
3156							self.appendContent( e.data );
3157						}
3158					};
3159					self.worker.postMessage( { init: true, vars: js_porto_vars.sales_popup, ajaxurl: theme.ajax_url, nonce: js_porto_vars.porto_nonce } );
3160					return self;
3161				}
3162			}
3163		} );
3164	} ).apply( this, [ window.theme, jQuery ] );
3165
3166	// Compare Popup
3167	( function ( theme, $ ) {
3168		'use strict';
3169		theme = theme || {};
3170		if ( !js_porto_vars.compare_popup ) return;
3171		$.extend( theme, {
3172			comparePopup: {
3173				isCart: true,
3174				popupContainer: null,
3175				$el: null,
3176				initialize: function ( $el ) {
3177					this.$el = $el;
3178					if ( $( '.after-loading-success-message.style-3' ).length == 0 ) {
3179						$( 'body' ).append( '<div class="after-loading-success-message style-3 d-block"></div>' );
3180						this.isCart = false;
3181						this.popupContainer = $( '.after-loading-success-message.style-3' );
3182					}
3183					else {
3184						this.popupContainer = $( '.after-loading-success-message.style-3' );
3185						this.popupContainer.eq( 0 ).stop().show();
3186					}
3187
3188					this.popupContainer.on( 'click', '.compare-close', function () {
3189						var $obj = $( this ).closest( '.success-message-container' );
3190						$obj.removeClass( 'active' );
3191						setTimeout( function () {
3192							$obj.slideUp( 300, function () {
3193								$obj.remove();
3194							} );
3195						}, 350 );
3196					} );
3197					this.build();
3198					return this;
3199				},
3200				build: function () {
3201					var self = this;
3202					if ( js_porto_vars.compare_popup ) {
3203						var self = this,
3204							isWishlistTable = $( '.wishlist_table' ).length > 0 ? true : false,
3205							$product = isWishlistTable ? self.$el.closest( 'tr' ) : self.$el.closest( '.product' ),
3206							message = typeof js_porto_vars.compare_popup_title == 'string' ? js_porto_vars.compare_popup_title : '',
3207							link = isWishlistTable ? $product.find( '.product-thumbnail a:first-child' ).attr( 'href' ) : ( $product.find( '.product-image>a:first-child' ).length > 0 ? $product.find( '.product-image>a:first-child' ).attr( 'href' ) : '#' ),
3208							image = isWishlistTable ? $product.find( '.product-thumbnail img' ).attr( 'src' ) : ( $product.find( '.product-inner .product-image img' ).length > 0 ? $product.find( '.product-inner .product-image img' ).attr( 'src' ) : $product.find( '.product-images .owl-item.active .img-thumbnail img' ).attr( 'src' ) ),
3209							price = isWishlistTable ? $product.find( '.product-price' ).html() : $product.find( '.price' ).html(),
3210							title = isWishlistTable ? $product.find( '.product-name a' ).text() : ( $product.find( '.woocommerce-loop-product__title' ).length > 0 ? $product.find( '.woocommerce-loop-product__title' ).text() : $product.find( '.product_title' ).text() );
3211
3212						if ( !image && $product.find( '.product-image img' ).length ) {
3213							image = $product.find( '.product-image img' ).attr( 'src' );
3214						}
3215						if ( !title && $product.find( '.product-image' ).length ) {
3216							title = $product.find( '.product-image' ).data( 'title' );
3217						}
3218						var $content = $( '<div class="compare-msg success-message-container"><p class="compare-popup-title">' + message +
3219							'</p><div class="msg-box mb-0"><div class="msg"><div class="product-name"><a href="' + link +
3220							'"><h3 class="product-title font-weight-bold line-height-sm mb-1">' + title + '</h3></a></div>' + '<span class="price text-primary">'
3221							+ price + '</span></div>
3221<img src="' + image + '" alt="' + title + '"/></div><button class="compare-close mfp-close"></button></div>' );
3222
3223						self.popupContainer.prepend( $content );
3224						setTimeout( function () {
3225							$content.addClass( 'active' );
3226						}, 150 );
3227						setTimeout( function () { $content.find( '.compare-close' ).trigger( 'click' ); }, 4000 );
3228					}
3229					return self;
3230				}
3231			}
3232		} );
3233	} ).apply( this, [ window.theme, jQuery ] );
3234	// Compare
3235	( function ( theme, $ ) {
3236		theme = theme || {};
3237		$.extend( theme, {
3238			porto_comapre_add_query_arg: function ( key, value ) {
3239				key = escape( key ); value = escape( value );
3240
3241				var s = document.location.search;
3242				var kvp = key + "=" + value;
3243
3244				var r = new RegExp( "(&|\\?)" + key + "=[^\&]*" );
3245
3246				s = s.replace( r, "$1" + kvp );
3247
3248				if ( !RegExp.$1 ) { s += ( s.length > 0 ? '&' : '?' ) + kvp; };
3249
3250				//again, do what you will here
3251				return s;
3252			}
3253		} );
3254		$( document ).ready( function () {
3255			$( 'body' ).on( 'click', '.wishlist_table a.compare.added', function ( e ) {
3256				e.preventDefault();
3257				$( 'body' ).trigger( 'yith_woocompare_open_popup', { response: theme.porto_comapre_add_query_arg( 'action', yith_woocompare.actionview ) + '&iframe=true' } );
3258			} );
3259			// Redefine "add to compare" function because they do not use async ajax.
3260			$( document )
3261				.off( 'click', '.product a.compare:not(.added)' )
3262				.on( 'click', '.product a.compare:not(.added), .wishlist_table a.compare:not(.added)', function ( e ) {
3263					e.preventDefault();
3264					if ( typeof theme.comparePopup != 'undefined' ) {
3265						theme.comparePopup.initialize( $( this ) );
3266					}
3267
3268					var button = $( this ),
3269						data = {
3270							action: yith_woocompare.actionadd,
3271							id: button.data( 'product_id' ),
3272							context: 'frontend'
3273						},
3274						widget_list = $( '.yith-woocompare-widget ul.products-list' );
3275
3276					button.addClass( 'added' );
3277					// do ajax
3278					$.ajax( {
3279						type: 'post',
3280						url: yith_woocompare.ajaxurl.toString().replace( '%%endpoint%%', yith_woocompare.actionadd ),
3281						data: data,
3282						dataType: 'json',
3283						success: function ( response ) {
3284
3285							// increase compare count
3286							$( '.yith-woocompare-open .compare-count' ).each( function () {
3287								this.innerHTML = parseInt( this.innerHTML ) + 1;
3288							} );
3289							var added_icon_html = '';
3290							if ( button.data( 'added_icon' ) ) {
3291								added_icon_html += '<i class="' + button.data( 'added_icon' ) + '"></i>';
3292							}
3293							button.attr( 'href', response.table_url )
3294								.html( !button.data( 'icon_pos' ) ? added_icon_html + yith_woocompare.added_label : yith_woocompare.added_label + added_icon_html );
3295							// add the product in the widget
3296							widget_list.html( response.widget_table );
3297						}
3298					} ).fail( function () {
3299						button.removeClass( 'added' );
3300					} );
3301				} );
3302		} );
3303		$( 'body' ).on( 'click', 'a.yith-woocompare-open, .product a.compare.added, .wishlist_table a.compare.added', function () {
3304			var scrollbarWidth = window.innerWidth - document.body.clientWidth;
3305			$( 'html' ).css( { 'overflow': 'hidden', 'margin-right': scrollbarWidth } );
3306		} );
3307		// remove margin-right
3308		$( 'body' ).on( 'click', '.yith_woocompare_colorbox #cboxClose, #cboxOverlay', function () {
3309			$( 'html' ).css( { 'overflow': '', 'margin-right': '' } );
3310		} );
3311		// decrease compare count
3312		$( 'body' ).on( 'yith_woocompare_open_popup', function () {
3313			setTimeout( function () {
3314				if ( $( 'body' ).find( 'iframe' ).length ) {
3315					var childWindow = $( 'body' ).find( '#cboxLoadedContent iframe' )[ 0 ].contentWindow;
3316					if ( childWindow.jQuery ) {
3317						childWindow.jQuery( childWindow ).on( 'yith_woocompare_product_removed', function () {
3318							$( '.yith-woocompare-open .compare-count' ).each( function () {
3319								this.innerHTML = Math.max( 0, parseInt( this.innerHTML ) - 1 );
3320							} );
3321						} );
3322					}
3323				}
3324			}, 2000 );
3325		} );
3326	} )( window.theme, window.jQuery );
3327
3328} )();
3329
3330function porto_woocommerce_init( $wrap ) {
3331	'use strict';
3332
3333	if ( !$wrap ) {
3334		$wrap = jQuery( document.body );
3335	}
3336	// Woo Widget Toggle
3337	( function ( $ ) {
3338
3339		if ( $.fn.themeWooWidgetToggle ) {
3340
3341			$( function () {
3342				$wrap.find( '.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 () {
3343					var $this = $( this ),
3344						opts;
3345
3346					var pluginOptions = $this.data( 'plugin-options' );
3347					if ( pluginOptions )
3348						opts = pluginOptions;
3349
3350					$this.themeWooWidgetToggle( opts );
3351				} );
3352			} );
3353
3354		}
3355
3356		// Woo Widget Accordion
3357		if ( $.fn.themeWooWidgetAccordion ) {
3358
3359			$( function () {
3360				$wrap.find( '.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 () {
3361					var $this = $( this ),
3362						opts;
3363
3364					var pluginOptions = $this.data( 'plugin-options' );
3365					if ( pluginOptions )
3366						opts = pluginOptions;
3367
3368					$this.themeWooWidgetAccordion( opts );
3369				} );
3370			} );
3371
3372		}
3373
3374		// Woo Products Slider
3375		if ( $.fn.themeWooProductsSlider ) {
3376
3377			$( function () {
3378				var $direct_carousels = $wrap.find( '.products-slider:not(.manual)' ).filter( function () {
3379					if ( $( this ).closest( '.porto-carousel:not(.owl-loaded)' ).length ) {
3380						return false;
3381					}
3382					return true;
3383				} );
3384				var $parent_carousel = $wrap.find( '.porto-carousel:not(.owl-loaded)' ).filter( function () {
3385					if ( $( this ).find( '.products-slider:not(.manual)' ).length ) {
3386						return true;
3387					}
3388					return false;
3389				} );
3390				if ( $parent_carousel.length ) {
3391					$parent_carousel.one( 'initialized.owl.carousel', function () {
3392						$( this ).find( '.products-slider:not(.manual)' ).each( function () {
3393							var $this = $( this );
3394							$this.themeWooProductsSlider( $this.data( 'plugin-options' ) );
3395						} );
3396					} );
3397				}
3398
3399				$direct_carousels.each( function () {
3400					var $this = $( this ),
3401						opts;
3402
3403					var pluginOptions = $this.data( 'plugin-options' );
3404					if ( pluginOptions )
3405						opts = pluginOptions;
3406
3407					setTimeout( function () {
3408						$this.themeWooProductsSlider( opts );
3409					}, 0 );
3410				} );
3411			} );
3412		}
3413
3414	} )( jQuery );
3415}
3416
3417function porto_woocommerce_variations_init( $parent_obj ) {
3418	'use strict';
3419
3420	theme.requestTimeout( function () {
3421		var form_variation = $parent_obj.find( 'form.variations_form:not(.vf_init)' );
3422		if ( form_variation.length && jQuery.fn.wc_variation_form ) {
3423			form_variation.each( function () {
3424				var data_a = jQuery._data( this, 'events' );
3425				if ( !data_a || !data_a[ 'show_variation' ] ) {
3426					jQuery( this ).wc_variation_form();
3427				}
3428			} );
3429		}
3430	}, 100 );
3431}
3432function porto_ajax_load_products( $obj, data, pagination_style, $ajax_tab_cache, id, group ) {
3433	'use strict';
3434	( function ( $ ) {
3435		if ( $obj.hasClass( 'loading' ) ) {
3436			return;
3437		}
3438		$obj.addClass( 'loading' );
3439		if ( 'load_more' != pagination_style ) {
3440			$obj.addClass( 'yith-wcan-loading' );
3441			if ( !$obj.children( '.porto-loading-icon' ).length ) {
3442				$obj.append( '<i class="porto-loading-icon"></i>' );
3443			}
3444		}
3445		if ( $ajax_tab_cache[ id ] == undefined ) {
3446			$ajax_tab_cache[ id ] = {};
3447		}
3448		$.ajax( {
3449			url: theme.ajax_url,
3450			data: data,
3451			type: 'post',
3452			success: function ( response ) {
3453				//cache
3454				if ( $( response ).length ) {
3455					$ajax_tab_cache[ id ][ group ] = $( response ).html();
3456				} else {
3457					$ajax_tab_cache[ id ][ group ] = '';
3458				}
3459				porto_ajax_load_products_success( $obj, response, pagination_style );
3460			},
3461			complete: function () {
3462				$obj.removeClass( 'loading' );
3463			}
3464		} );
3465	} )( jQuery );
3466}
3467
3468function porto_ajax_load_products_success( $obj, success, pagination_style ) {
3469	'use strict';
3470
3471	( function ( $ ) {
3472		if ( $obj.data( 'cur_page' ) && $( success ).find( 'ul.products' ).data( 'cur_page' ) ) {
3473			$obj.data( 'cur_page', $( success ).find( 'ul.products' ).data( 'cur_page' ) );
3474		}
3475		if ( 'load_more' == pagination_style ) {
3476			$obj.append( $( success ).find( 'ul.products' ).html() );
3477		} else {
3478			if ( $obj.hasClass( 'owl-carousel' ) ) {
3479				$obj.parent().css( 'min-height', $obj.parent().height() );
3480			}
3481			if ( $obj.hasClass( 'grid-creative' ) && typeof $obj.attr( 'data-
3481plugin-masonry' ) != 'undefined' ) {
3482				$obj.isotope( 'remove', $obj.children() );
3483				var newItems = $( success ).find( 'ul.products' ).children();
3484				$obj.append( newItems );
3485				$obj.isotope( 'appended', newItems );
3486				$obj.imagesLoaded( function () {
3487					$obj.isotope( 'layout' );
3488				} );
3489			} else {
3490				if ( $( success ).length ) {
3491					$obj.html( $( success ).find( 'ul.products' ).html() );
3492				} else {
3493					$obj.html( '' );
3494				}
3495			}
3496		}
3497
3498		if ( $obj.hasClass( 'owl-carousel' ) && $.fn.themeWooProductsSlider ) {
3499			$obj.trigger( 'destroy.owl.carousel' );
3500			theme.requestTimeout( function () {
3501				var pluginOptions = $obj.data( 'plugin-options' ), opts;
3502				if ( pluginOptions )
3503					opts = pluginOptions;
3504				$obj.data( '__wooProductsSlider', '' ).themeWooProductsSlider( opts );
3505				$obj.parent().css( 'min-height', '' );
3506			}, 100 );
3507		}
3508		if ( $obj.closest( '.porto-products' ).find( '.shop-loop-after' ).length ) {
3509			if ( $( success ).find( '.shop-loop-after' ).length ) {
3510				$obj.closest( '.porto-products' ).find( '.shop-loop-after' ).replaceWith( $( success ).find( '.shop-loop-after' ) );
3511			} else {
3512				$obj.closest( '.porto-products' ).find( '.shop-loop-after' ).remove();
3513			}
3514		}
3515		if ( typeof $obj.data( 'infinitescroll' ) != 'undefined' ) {
3516			var infinitescrollData = $obj.data( 'infinitescroll' );
3517			infinitescrollData.options.state.currPage = 1;
3518			$obj.data( 'infinitescroll', infinitescrollData );
3519		}
3520		$obj.removeClass( 'yith-wcan-loading' );
3521		if ( 'load_more' == pagination_style && typeof $obj != 'undefined' && typeof $obj.data( 'text' ) != 'undefined' ) {
3522			$obj.text( $obj.data( 'text' ) );
3523		}
3524		$( document ).trigger( "yith-wcan-ajax-filtered" );
3525	} )( jQuery );
3526}

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.