PageSourceSearch

https://amff.org/wp-content/themes/uncode/library/js/woocommerce-uncode.js?ver=2073694646

js amff.org collected 2026-10-02 04:16:20 UTC 39,528 bytes, 1,231 lines download raw bytes

1(function($) {
2	"use strict";
3
4	var UNCODE_WC = window.UNCODE_WC || {};
5	window.UNCODE_WC = UNCODE_WC;
6
7	function get_cart() {
8		var ajaxurl = '';
9
10		if (window.wc_add_to_cart_params != undefined) {
11			ajaxurl = wc_add_to_cart_params.ajax_url
12		}
13
14		if (window.woocommerce_params != undefined) {
15			ajaxurl = woocommerce_params.ajax_url
16		}
17
18		if (ajaxurl) {
19			$.post({
20				url: ajaxurl,
21				dataType: 'JSON',
22				data: {
23					action: 'woomenucart_ajax'
24				},
25				success: function(data, textStatus, XMLHttpRequest) {
26					$('.uncode-cart-dropdown').html(data.cart);
27					if (data != '') {
28						if ( SiteParameters.uncode_wc_popup_cart_qty ) {
29							if ($('.uncode-cart .badge, .mobile-shopping-cart .badge').length) {
30								$('.uncode-cart .badge, .mobile-shopping-cart .badge').html(data.articles);
31							} else {
32								$('.uncode-cart .cart-icon-container').append('<span class="badge init-product-counter">' + data.articles + '</span>'); //$('.uncode-cart .badge').html(data.articles);
33							}
34							$(document.body).trigger('uncode_get_cart', [data.articles]);
35						} else {
36							if ($('.uncode-cart .badge, .mobile-shopping-cart .badge').length) {
37								if (data.articles > 0) {
38									$('.uncode-cart .badge, .mobile-shopping-cart .badge').html(data.articles);
39									$('.uncode-cart .badge, .mobile-shopping-cart .badge').show();
40								} else {
41									$('.uncode-cart .badge, .mobile-shopping-cart .badge').hide();
42								}
43							} else {
44								$('.uncode-cart .cart-icon-container').append('<span class="badge">' + data.articles + '</span>'); //$('.uncode-cart .badge').html(data.articles);
45							}
46						}
47					}
48				}
49			});
50		}
51
52	}
53
54	function remove_from_cart() {
55		$(document).on('click', '.uncode-cart-dropdown a.remove', function(e){
56
57			var $remove = $(this),
58				product_id = $remove.attr("data-product_id"),
59				item_key = $remove.attr("data-item_key"),
60				$li = $remove.parents('.cart-item-list').eq(0).addClass('removing-item').animate({
61					opacity: .5
62				},150);
63
64			$.post({
65				dataType: 'json',
66				url: wc_add_to_cart_params.ajax_url,
67				data: {
68					action: "woomenucart_remove_ajax",
69					item_key: item_key
70				},
71				success: function(html){
72					$li.slideUp(200, function(){
73						get_cart();
74					});
75				}
76			});
77
78			return false;
79		});
80	}
81
82	function reset_product_image(event, variation) {
83		var $target = event.target,
84			$row = $target.closest('.row-parent', $row),
85			get_href = $('a.woocommerce-main-image', $row),
86			image_variable = $('> img', get_href),
87			getLightbox = typeof UNCODE.lightbox !== 'undefined' && !SiteParameters.lbox_enhanced ? UNCODE.lightboxArray[get_href.data('lbox')] : false;
88
89		if (SiteParameters.uncode_adaptive == true) {
90			image_variable.removeClass(['async-done', 'woocommerce-product-gallery__image-first__img']).addClass('adaptive-async');
91			image_variable.wc_reset_variation_attr( 'src' );
92			image_variable.wc_reset_variation_attr( 'data-path' );
93			image_variable.wc_reset_variation_attr( 'data-guid' );
94			UNCODE.adaptive();
95		}
96
97		if (getLightbox != undefined && getLightbox !== false) {
98			getLightbox.refresh();
99		} else if ( SiteParameters.lbox_enhanced ) {
100			get_href.closest('.woocommerce-product-gallery').trigger('more-items-loaded');
101		}
102	}
103
104	function change_images(event, variation) {
105		if ($(this).closest('.tmb-woocommerce').length > 0) {
106			return;
107		}
108
109		UNCODE.single_product_variation_already_changed = true;
110		if (variation.image_src !== '') {
111			var $target = event.target,
112				$row = $target.closest('.row-parent', $row),
113				get_href = $('a.woocommerce-main-image', $row),
114				$col_bg = $('.uncol-featured-image .background-inner', $row),
115				image_variable = $('> img', get_href),
116				image_thumb = variation.image.thumb_src,
117				gallery_thumb = variation.image.gallery_thumbnail_src,
118				image_srcset = variation.image.thumb_srcset,
119				getLightbox = typeof UNCODE.lightbox !== 'undefined' && !SiteParameters.lbox_enhanced ? UNCODE.lightboxArray[get_href.data('lbox')] : false;
120			get_href.data('options', "thumbnail: '" + variation.image_src + "'");
121			if (SiteParameters.uncode_adaptive == true) {
122				image_variable.wc_set_variation_attr( 'src', variation.image_src );
123				image_variable.wc_set_variation_attr( 'data-path', variation.uncode_image_path );
124				image_variable.wc_set_variation_attr( 'data-guid', variation.uncode_image_guid );
125				image_variable.removeClass(['async-done', 'woocommerce-product-gallery__image-first__img']).addClass('adaptive-async');
126				UNCODE.adaptive();
127			}
128			if (getLightbox != undefined && getLightbox !== false) {
129				getLightbox.refresh();
130			} else if ( SiteParameters.lbox_enhanced ) {
131				get_href.closest('.woocommerce-product-gallery').trigger('more-items-loaded');
132			}
133			$(window).trigger('focus');
134
135			var $woocommerce_product_gallery_nav = $('.woocommerce-product-gallery-nav');
136
137			if ($woocommerce_product_gallery_nav.length) {
138				var $first_thumb = $woocommerce_product_gallery_nav.find('.woocommerce-product-gallery__wrapper-nav li.woocommerce-product-gallery__first-thumb img', $row);
139				if ( SiteParameters.uncode_adaptive == true ) {
140					var data_crop = $first_thumb.attr('data-crop'),
141						data_singlew = $first_thumb.attr('data-singlew'),
142						data_singleh = $first_thumb.attr('data-singleh');
143
144					$first_thumb
145						.attr('src', gallery_thumb)
146						.attr('data-path', variation.uncode_image_path)
147						.attr('data-guid', variation.uncode_image_guid)
148						.attr('data-uniqueid', variation.data_uniqueid)
149						.attr('data-width', variation.data_width)
150						.attr('data-height', variation.data_height)
151						.attr('data-singlew', variation.data_singlew)
152						.attr('data-singleh', variation.data_singleh)
153						.attr('data-crop', variation.data_crop);
154
155					if (!$woocommerce_product_gallery_nav.hasClass('lateral-nav-wrapper')) {
156						$first_thumb.removeClass(['async-done', 'adaptive-fetching']).addClass('adaptive-async');
157						UNCODE.adaptive();
158					}
159				} else {
160					$first_thumb
161						.attr('src', gallery_thumb);
162					if ( image_srcset ) {
163						$first_thumb.attr('srcset', image_srcset);
164					}
165					$(window).trigger('woocommerce_variation_has_loaded');
166				}
167			}
168
169			if ( $col_bg.length ) {
170				var objImg = new Image(),
171					bg_img_src;
172				if ( $col_bg.hasClass( 'async-done') ) {
173					bg_img_src = variation.image_link;
174				} else {
175					bg_img_src = variation.image_src;
176				}
177				objImg.src = bg_img_src;
178				objImg.onload = function() {
179					$col_bg.animate({ opacity: 0 }, 100, function(){
180						$col_bg.css({'background-image':'url('+bg_img_src+')'});
181						$col_bg.animate({ opacity: 1 }, 250);
182					});
183				}
184			}
185		}
186	}
187
188	function reset_data(event) {
189		if ( UNCODE.single_product_variation_already_changed ) {
190			var $col_bg = $('.uncol-featured-image .background-inner'),
191				$first_thumb = $('.woocommerce-product-gallery__first-thumb img'),
192				bg_img_src,
193				bg_img_srcset,
194				objImg = new Image();
195
196			if ( $col_bg.length ) {
197				bg_img_src = $col_bg.attr('data-o_src');
198				objImg = new Image();
199				objImg.src = bg_img_src;
200				objImg.onload = function() {
201					$col_bg.animate({ opacity: 0 }, 100, function(){
202						$col_bg.css({'background-image':'url('+bg_img_src+')'});
203						$col_bg.animate({ opacity: 1 }, 250);
204					});
205				}
206			} else if ( $first_thumb.length ) {
207				bg_img_src = $first_thumb.attr('data-o_src');
208				bg_img_srcset = $first_thumb.attr('data-o_srcset');
209				objImg = new Image();
210				objImg.src = bg_img_src;
211				objImg.onload = function() {
212					$first_thumb
213						.attr('src', bg_img_src)
214						.attr('srcset', bg_img_srcset);
215					$(window).trigger('woocommerce_variation_has_loaded');
216				}
217			}
218		}
219	}
220
221	function check_variation_values(event) {
222		var $selects = $(event.currentTarget).find('select'),
223			checkSelectValues = false;
224		$selects.each(function(){
225			var $select = $(this);
226			if ( $select.val() !== '' ) {
227				checkSelectValues = true;
228			}
229		});
230
231		if ( checkSelectValues ) {
232			$(event.currentTarget).removeClass('hide-clear');
233		} else {
234			$(event.currentTarget).addClass('hide-clear');
235		}
236
237		setTimeout(function(){
238			$(window).trigger('woocommerce_variation_has_loaded');
239		}, 1250);
240	}
241
242	function reloadVariations() {
243		remove_from_cart();
244		$('body').on("added_to_cart wc_fragments_refreshed removed_from_cart", get_cart);
245		if (!$('body').hasClass('uncode-default-product-gallery')) {
246			$('.variations_form')
247				.on("show_variation", change_images)
248				.on("reset_data", reset_data)
249				.on("check_variations", check_variation_values)
250				.on('reset_image', reset_product_image);
251		}
252	}
253
254	$(document).ready(reloadVariations);
255	$(document).on('uncode-quick-view-loaded', reloadVariations);
256
257	function handleRatings() {
258		if ( $('#rating').length ) {
259			setTimeout(function(){
260				$('.comment-form-rating').each(function(){
261					var $wrap = $(this),
262						$stars = $('p.stars', $wrap).remove();
263					$( 'select[name="rating"]', $wrap ).hide().before( '<p class="stars"><span><a class="star-1" href="#">1</a><a class="star-2" href="#">2</a><a class="star-3" href="#">3</a><a class="star-4" href="#">4</a><a class="star-5" href="#">5</a></span></p>' );
264				});
265			}, 10);
266		}
267	}
268
269	$(document).ready(handleRatings);
270	$(document).on('vc-uncode_single_product_reviews', handleRatings);
271
272	$(document).on('vc-uncode_single_product_reviews', function(e, el) {
273		if ( el !== 'undefined' ) {
274			var $tabContainer = $(el).closest('.tab-container');
275			$tabContainer.addClass('wootabs');
276		}
277	} );
278
279	var scrollToReviews = function(){
280		if ( $('.wootabs, .wpb_accordion').length ) {
281
282			var hash = window.location.hash,
283				url = window.location.href,
284				$tabs = $( this ).find( 'ul.nav-tabs' ).first(),
285				$accordion = $( this ).find('.panel-group').first(),
286				scrollAction = false,
287				$tabs_wrapper = $tabs.closest('.wootabs'),
288				$both_wrapper,
289				$li, $panel, $click_trigger = false;
290
291			var scrollToReviewsInside = function( clicked ){
292
293				if ( $tabs.length && $('#reviews', $tabs_wrapper).length ) {
294					var tab_reviews = $('#reviews', $tabs_wrapper).first().closest('.tab-pane').attr('id');
295					$('[data-tab-id="' + tab_reviews + '"]', $tabs).addClass('reviews_tab');
296					$li = $('.reviews_tab', $tabs);
297					$both_wrapper = $tabs_wrapper;
298					$click_trigger = true;
299				} else if ( $accordion.length && $('#reviews', $accordion).length ) {
300					var tab_reviews = $('#reviews', $accordion).first().closest('.tab-pane').attr('id');
301					$panel = $('#reviews', $accordion).first().closest('.panel');
302					$li = $('.panel-title', $panel);
303					$both_wrapper = $accordion;
304					$click_trigger = true;
305				} else if ( $('div#reviews').length && clicked ) {
306					$both_wrapper = $('div#reviews');
307					scrollAction = true;
308				} else {
309					return false;
310				}
311
312				if ( $click_trigger && ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) ) {
313					$( 'a', $li ).click();
314					scrollAction = true;
315				} else if ( $click_trigger && ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) ) {
316					$( 'a', $li ).click();
317					scrollAction = true;
318				}
319
320				if ( scrollAction ) {
321					var body = $("html, body"),
322						bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop'],
323						delta = bodyTop - ($both_wrapper.length ? $both_wrapper.offset().top : 0),
324						getOffset = UNCODE.get_scroll_offset();
325					if ( typeof $both_wrapper.offset() === 'undefined' )
326						return;
327					scrollTo = $both_wrapper.offset().top - 27;
328					scrollTo -= getOffset;
329
330					var scrollSpeed = (SiteParameters.constant_scroll == 'on') ? Math.abs(delta) / parseFloat(SiteParameters.scroll_speed) : SiteParameters.scroll_speed;
331					if (scrollSpeed < 1000 && SiteParameters.constant_scroll == 'on') scrollSpeed = 1000;
332
333					if (scrollSpeed == 0) {
334						body.scrollTop((delta > 0) ? scrollTo - 0.1 : scrollTo);
335					} else {
336						body.animate({
337							scrollTop: (delta > 0) ? scrollTo - 0.1 : scrollTo
338						}, scrollSpeed, 'easeInOutQuad');
339					}
340				} else {
341					return false;
342				}
343			};
344
345			scrollToReviewsInside( false );
346
347			$('a.woocommerce-review-link').on('click', function(e) {
348				e.preventDefault();
349				hash = '#reviews';
350				scrollToReviewsInside( true );
351			});
352
353		}
354	}
355	$(document).ready(scrollToReviews);
356
357	var qtyPlusMinus = function(){
358		$('.qty-inset:not(.qty-inset-active)').each(function(){
359			var $qtyInsets = $(this).addClass('qty-inset-active'),
360				$input = $('input.qty', $qtyInsets),
361				$minus = $('.qty-minus', $qtyInsets),
362				$plus = $('.qty-plus', $qtyInsets),
363				step = parseFloat( $input.attr('step') ),
364				min = parseFloat( $input.attr('min') ),
365				max = parseFloat( $input.attr('max') ),
366				value = parseFloat($input.val());
367
368			if ( isNaN(step) ) {
369				step = 1;
370			}
371
372			if ( isNaN(min) ) {
373				min = 1;
374			}
375
376			if ( isNaN(value) ) {
377				value = 0;
378				$input.val( value );
379			}
380
381			$minus.on('click', function () {
382				if (UncodeWCParameters.activate_input_check_on_click) {
383					step = parseFloat( $input.attr('step') );
384					min = parseFloat( $input.attr('min') );
385					max = parseFloat( $input.attr('max') );
386					if ( isNaN(step) ) {
387						step = 1;
388					}
389					if ( isNaN(min) ) {
390						min = 1;
391					}
392				}
393
394				value = parseFloat( $input.val() ) - step;
395				if ( value < min ) {
396					value = min;
397				}
398				$input.val( value ).trigger( 'change' );
399			});
400
401			$plus.on('click', function () {
402				if (UncodeWCParameters.activate_input_check_on_click) {
403					step = parseFloat( $input.attr('step') );
404					min = parseFloat( $input.attr('min') );
405					max = parseFloat( $input.attr('max') );
406					if ( isNaN(step) ) {
407						step = 1;
408					}
409					if ( isNaN(min) ) {
410						min = 1;
411					}
412				}
413
414				value = parseFloat( $input.val() ) + step;
415				if ( !isNaN(max) && value > max ) {
416					value = max;
417				}
418				$input.val( value ).trigger( 'change' );
419			});
420		});
421	};
422
423	var resizeCartRow = function(){
424		if ($('form.woocommerce-cart-form').length > 0) {
425			window.dispatchEvent(new CustomEvent('vc-resize'));
426		}
427	};
428
429	$(document.body).on('updated_cart_totals', qtyPlusMinus);
430	$(document.body).on('updated_cart_totals', resizeCartRow);
431	$(document).ready(qtyPlusMinus);
432	$(document).on('vc-frontend:vc_button', qtyPlusMinus);
433
434	var woocommerce_product_gallery = function() {
435		$( 'body:not(.single-uncodeblock) .woocommerce-product-gallery' ).each( function() {
436			if ($('body').hasClass('uncode-default-product-gallery')) {
437				return;
438			}
439
440			var $slider = $(this);
441
442			UNCODE_WC.product_gallery($slider);
443		});
444	}
445
446	UNCODE_WC.product_gallery = function($slider) {
447		var $parent = $slider.closest('.uncode-wrapper').length ? $slider.closest('.uncode-wrapper') : $slider.closest('.uncont'),
448			cols = parseFloat( $slider.attr('data-columns') ),
449			dots = $parent.attr('data-dots') == 'true',
450			gutter = $parent.length && typeof $parent.attr('data-gutter') !== 'undefined' ? parseFloat( $parent.attr('data-gutter') ) : 18,
451			$main = $('.woocommerce-product-gallery__wrapper.owl-carousel', $parent),
452			$stack = $('.woocommerce-layout-images-stack-lateral .woocommerce-product-gallery__wrapper', $parent),
453			mainL = $main.find('.woocommerce-product-gallery__image').length,
454			$thumbs = $('.woocommerce-product-gallery__wrapper-nav:not(.lateral-nav)', $parent),
455			$thumbs_nav = $('.woocommerce-product-gallery__wrapper-nav', $parent),
456			$navTh = $('.woocommerce-product-gallery__thumb', $thumbs_nav).attr('tabindex', 0),
457			thumbsL = $thumbs.find('li').length;
458
459		$navTh.each(function(key, val){
460			$(val).attr('aria-label', SiteParameters.uncode_slide_label + ' ' + (key+1));
461		});
462
463		if ($.fn.owlCarousel) {
464			if ( mainL > 1 && $slider.hasClass('owl-carousel-wrapper') ) {
465				$main.owlCarousel({
466					items: 1,
467					autoHeight: true,
468					rtl: $('body').hasClass('rtl') ? true : false,
469					responsiveRefreshRate: 200,
470					responsive: {
471						0: {
472							dots: $('.woocommerce-product-gallery__wrapper-nav.lateral-nav', $parent).length || dots === true
473						},
474						960: {
475							dots: dots
476						}
477					}
478				}).on('changed.owl.carousel', function(event) {
479					if (event.namespace && event.property.name === 'position') {
480						var target = event.relatedTarget.relative(event.property.value, true);
481						var data = $thumbs.data('owl.carousel');
482						if ( ! $('.owl-item', $thumbs).eq( target ).hasClass('active') ) {
483							$thumbs.owlCarousel( 'to', target, 300, true );
484						}
485					}
486				});
487				$main.on('translate.owl.carousel', function(event) {
488					$(event.currentTarget).addClass('owl-translating');
489				});
490				$main.on('translated.owl.carousel', function(event) {
491					$(event.currentTarget).removeClass('owl-translating');
492				});
493				$thumbs.on('initialized.owl.carousel', function(event) {
494					$thumbs.closest('.woocommerce-product-gallery-nav-wrapper').css({
495						opacity: 1
496					});
497				}).owlCarousel({
498					items: cols,
499					margin: gutter,
500					autoHeight: true,
501					nav: true,
502					rtl: $('body').hasClass('rtl') ? true : false,
503					mouseDrag: cols < thumbsL,
504					navText: ['<div class="owl-nav-container btn-default btn-hover-nobg"><i class="fa fa-fw fa-angle-left"></i></div>', '<div class="owl-nav-container btn-default btn-hover-nobg"><i class="fa fa-fw fa-angle-right"></i></div>'],
505					responsiveRefreshRate: 100,
506				})
507				$(window).on('resize load uncode-quick-view-first-hover woocommerce_variation_has_loaded', function () {
508					setTimeout(function(){
509						$main.trigger('refresh.owl.carousel');
510						$thumbs.trigger('refresh.owl.carousel');
511
512						var product_div = $main.closest('div.woocommerce-product-gallery--with-variation-gallery');
513
514						if (!product_div.length > 0) {
515							if (!$('.owl-item', $main).eq(0).hasClass('active')) {
516								$main.owlCarousel( 'to', 0, 300, true );
517							}
518							if (!$('.owl-item', $thumbs).eq(0).hasClass('active')) {
519								$thumbs.owlCarousel( 'to', 0, 300, true );
520							}
521						}
522
523						$('.owl-dot', $main).each(function(key, val){
524							$(val).attr('aria-label', SiteParameters.uncode_slide_label + ' ' + (key+1));
525						});
526						$('.owl-dot', $thumbs).each(function(key, val){
527							$(val).attr('aria-label', SiteParameters.uncode_slide_label + ' ' + (key+1));
528						});
529					}, 300);
530				});
531			}
532		}
533
534		var scrollBody = function(index) {
535			$('.woocommerce-product-gallery__thumb', $thumbs_nav).removeClass('is-selected');
536			$('.woocommerce-product-gallery__thumb', $thumbs_nav).eq(index).addClass('is-selected');
537
538			var top_gutter = parseInt($stack.closest('.row').css('padding-top'));
539
540			var getSection = $('.woocommerce-product-gallery__image', $stack).eq(index),
541				scrollTo;
542
543			if (getSection == undefined) return;
544
545			var body = $("html, body"),
546				bodyTop = document.documentElement['scrollTop'] || document.body['scrollTop'],
547				delta = bodyTop - ($('.woocommerce-product-gallery__image', $stack).eq(index).length ? $('.woocommerce-product-gallery__image', $stack).eq(index).offset().top : 0),
548				getOffset = UNCODE.get_scroll_offset(index);
549			if ( typeof getSection.offset() === 'undefined' ) {
550				return;
551			}
552			scrollTo = getSection.offset().top;
553
554			if  ( !( $('.menu-desktop-transparent').length && UNCODE.wwidth > UNCODE.mediaQuery ) && !( $('.menu-mobile-transparent').length && UNCODE.wwidth <= UNCODE.mediaQueryMobile ) ) {
555				var shrink = typeof $('.navbar-brand').data('padding-shrink') !== 'undefined' ?  $('.navbar-brand').data('padding-shrink')*2 : 36;
556				if ( $('.menu-sticky .menu-container:not(.menu-hide)').length && $('.menu-shrink').length ) {
557					scrollTo += UNCODE.menuHeight - ( $('.navbar-brand').data('minheight') + shrink );
558				}
559
560				if ( $('.menu-sticky .menu-container:not(.menu-hide)').length && ! $('.menu-shrink').length && $('.body').hasClass('vmenu') ) {
561					if ( index === 0 ) {
562						scrollTo = 0;
563					} else {
564						scrollTo -= $('.menu-sticky .menu-container').outerHeight();
565					}
566				} else {
567					scrollTo -= getOffset;
568				}
569			}
570
571			scrollTo -= top_gutter;
572
573			var scrollSpeed = (SiteParameters.constant_scroll == 'on') ? Math.abs(delta) / parseFloat(SiteParameters.scroll_speed) : SiteParameters.scroll_speed;
574			if (scrollSpeed < 1000 && SiteParameters.constant_scroll == 'on') scrollSpeed = 1000;
575
576			if (index != 0) {
577				UNCODE.scrolling = true;
578			}
579
580			if (scrollSpeed == 0) {
581				body.scrollTop((delta > 0) ? scrollTo - 0.1 : scrollTo);
582				UNCODE.scrolling = false;
583			} else {
584				body.on("scroll wheel DOMMouseScroll mousewheel touchmove", function(){
585					$(this).stop();
586				}).stop(true,false).animate({
587					scrollTop: (delta > 0) ? scrollTo - 0.1 : scrollTo
588				}, scrollSpeed, 'easeInOutCubic', function(){
589					UNCODE.scrolling = false;
590				});
591			}
592
593		};
594
595		var changeThumbActive = function(section, index) {
596			var newSection = $('.woocommerce-product-gallery__thumb', $thumbs_nav).eq(index);
597			if (newSection.length) {
598				$('.woocommerce-product-gallery__thumb', $thumbs_nav).removeClass('is-selected');
599				newSection.addClass('is-selected');
600			}
601		}
602
603		$('.woocommerce-product-gallery__image', $stack).each(function(index, val) {
604			new Waypoint({
605				context: UNCODE.isUnmodalOpen ? document.getElementById('unmodal-content') : window,
606				element: val,
607				handler: function(direction) {
608					changeThumbActive(this.element, index);
609				},
610			});
611		});
612
613		$thumbs_nav.on( 'click', '.woocommerce-product-gallery__thumb', function(e){
614			e.preventDefault();
615			var number = $(this).index();
616			if ( $main.length ) {
617				number = $(this).closest('.owl-item').index();
618				if ( number < 0 ) {
619					number = $(this).index();
620				}
621				$main.owlCarousel( 'to', number, 300, true );
622			} else if ( $stack.length ) {
623				scrollBody( number );
624			}
625		});
626
627		var uncodeZoom = function(){
628			if ($.fn.zoom && $('body').hasClass('wc-zoom-enabled') ) {
629				var $zoomTrgt = $('.woocommerce-product-gallery__image', $slider);
630
631				if ( $('.thumbnails', $slider).length )
632					$zoomTrgt = $zoomTrgt.first();
633
634				$zoomTrgt.trigger( 'zoom.destroy' );
635				$zoomTrgt.zoom();
636
637				var checkForZoom = function(){
638
639					if ( $parent.hasClass( 'no-zoom-mobile' ) && UNCODE.wwidth < 960 ) {
640						$zoomTrgt.trigger( 'zoom.destroy' ).addClass('mouse-moving');
641						$('.zoom-overlay', $zoomTrgt).remove();
642						return false;
643					}
644					$('.woocommerce-product-gallery__image').each(function(){
645						var $wrap = $(this),
646							$zoomImg = $('.zoomImg', $wrap);
647
648						if (UNCODE.isMobile || !$zoomImg.length) {
649							$wrap.addClass('mouse-moving');
650						}
651					});
652
653					var galleryWidth = $zoomTrgt.width(),
654						zoom_options = {
655							touch: true,
656							callback: function(){
657								$('.woocommerce-product-gallery__image').each(function(){
658									var $wrap = $(this),
659										$zoomImg = $('.zoomImg', $wrap),
660										$overZoom = $('.zoom-overlay', $wrap),
661										$imageIL = $('a[data-lbox]', $wrap),
662										$carousel = $wrap.closest('.owl-carousel');
663
664									$wrap.prepend($zoomImg);
665									if (UNCODE.isMobile || !$zoomImg.length) {
666										$wrap.addClass('mouse-moving');
667										$zoomImg.css({
668											'visibility':'hidden'
669										});
670									}
671
672									/* Make work everything on touch events */
673									var onlongtouch,
674										timer,
675										now,
676										touchduration = 500,
677										startX = 0, startY, newX, newY;
678
679									$wrap.parent().on('mousemove.zoom', function(){
680										if ( ! $wrap.hasClass('mouse-moving') ) {
681											if ( startX == 0 ) {
682												startX = event.clientX;
683												startY = event.clientY;
684											}
685											newX = event.clientX;
686											newY = event.clientY;
687											if ( Math.abs( newX - startX ) > 50 && Math.abs( newY - startY ) > 50 ) {
688												$wrap.addClass('mouse-moving');
689											}
690										}
691									});
692
693									$overZoom.on('touchstart.zoom', function (e) {
694										now = new Date().getTime();
695									}).on('touchmove.zoom', function (e) {
696										setTimeout(function(){
697											$zoomImg.css({
698												'visibility':'visible'
699											});
700										}, 100);
701									}).on('touchend.zoom', function (e) {
702										var newTap = new Date().getTime();
703										if ( newTap - now < 75 && ! $('body').hasClass('ilightbox-noscroll') ) {
704											$imageIL.trigger('itap.iL');
705										}
706										if (UNCODE.isMobile) {
707											$zoomImg.css({
708												'visibility':'hidden'
709											});
710										}
711									});
712
713								});
714							}
715						};
716
717					if ( 'ontouchstart' in window ) {
718						zoom_options.on = 'click';
719					}
720
721					$zoomTrgt.trigger( 'zoom.destroy' );
722					$zoomTrgt.each(function(){
723						var $thisTrgt = $(this),
724							$img = $('img', $thisTrgt);
725
726						if ( $img.data( 'large_image_width' ) > galleryWidth ) {
727							$thisTrgt.zoom(zoom_options);
728						} else {
729							$thisTrgt.trigger( 'zoom.destroy' );
730						}
731
732					});
733
734				};
735				checkForZoom();
736
737				var setCheckForZoom;
738				$(window).on( 'resize', function(){
739					clearTimeout(setCheckForZoom);
740					setCheckForZoom = setTimeout( checkForZoom, 500 );
741				});
742			}
743		};
744		uncodeZoom();
745		window.addEventListener('load', uncodeZoom);
746	}
747
748	woocommerce_product_gallery();
749
750	$(window).on('unmodal-open', function(){
751		$('#unmodal-content .woocommerce-product-gallery__image').removeClass('mouse-moving');
752	})
753	$(document).on('unmodal-close', function(){
754		$('#unmodal-content .woocommerce-product-gallery__image').removeClass('mouse-moving');
755	})
756
757	/************************************************************
758	 * Redirect to custom empty cart page
759	 ************************************************************/
760
761	$(document.body).on('wc_cart_emptied', redirect_to_custom_empty_cart);
762
763	function redirect_to_custom_empty_cart() {
764		if (UncodeWCParameters.empty_cart_url !== '') {
765			window.location.replace(UncodeWCParameters.empty_cart_url);
766		}
767	}
768
769	/************************************************************
770	 * Make the variation price inherit the font family from main price
771	************************************************************/
772
773	function variation_price_font() {
774
775		var $forms = $('form.variations_form');
776
777		$forms.each(function(){
778			var $form = $(this);
779
780			$form.on('woocommerce_variation_has_changed wc_variation_form', function(){
781				var $var_price = $('.woocommerce-variation-price .woocommerce-Price-amount'),
782					$row = $form.closest('.vc_row'),
783					$main_price = $('.heading-text .woocommerce-Price-amount', $row);
784
785				if ( $main_price.length ) {
786					var $price_wrap = $main_price.closest('.heading-text'),
787						$price_nest = $('> *:first-child', $price_wrap),
788						font_class = $price_nest.attr('class').split(' '),
789						i;
790
791					for ( i = 0; i < font_class.length; i++ ) {
792						if ( font_class[i].indexOf('font') !== -1 && font_class[i].indexOf('fontsize') === -1 ) {
793							$var_price.addClass( font_class[i] );
794						}
795					}
796				}
797			});
798		});
799	}
800
801	$(document).ready(function() {
802		variation_price_font();
803	});
804
805	/************************************************************
806	 * Show minicart when adding something
807	************************************************************/
808
809	var cartShow, cartHover,
810		sideCart_scrollTop = $('html, body').scrollTop();;
811
812	var minicart_notify = function(){
813		var $body = $('body');
814
815		if ( ! $body.hasClass('minicart-notification') ) {
816			return false;
817		}
818
819		var $sidecart = $('#uncode_sidecart'),
820			$miniCart = $('.menu-smart .uncode-cart-dropdown'),
821			$smartMenu = $miniCart.closest('.menu-smart');
822
823		$miniCart.on('hover', function(){
824			clearTimeout(cartHover);
825		});
826
827		var show_added_to_cart = function(e){
828
829			clearTimeout(cartShow);
830			clearTimeout(cartHover);
831
832			if ( $sidecart.length && ( ! ( $body.hasClass('uncode-sidecart-mobile-disabled') && UNCODE.wwidth <= UNCODE.mediaQuery ) ) ) {
833				$sidecart.imagesLoaded().done( function( instance ) {
834					setTimeout(function(){
835						sideCart_scrollTop = $('html, body').scrollTop();
836						$body.addClass('uncode-sidecart-open');
837						$(window).trigger('uncode-sidecart-open');
838						$('html, body').scrollTop(sideCart_scrollTop);
839					}, 500);
840				});
841			}
842
843			var show_added_to_cart_timeout = function(){
844				cartShow = setTimeout(function(){
845					$miniCart.imagesLoaded().done( function( instance ) {
846						$smartMenu.smartmenus('itemActivate', $('.uncode-cart > a'));
847						cartHover = setTimeout(function(){
848							$smartMenu.smartmenus('menuHideAll');
849						}, 4000);
850					});
851				}, 500);
852			};
853
854			if ( UNCODE.wwidth >= 960 ) {
855				if ( e == 'uncode-wc-added-to-cart' ) {
856					show_added_to_cart_timeout();
857				} else {
858					$( document.body ).on( 'wc_fragments_loaded', function(){
859						show_added_to_cart_timeout();
860					});
861				}
862			}
863		};
864
865		if ( $('body').hasClass('uncode-wc-disable-added-to-cart-trigger')) {
866			$( document.body ).on( 'added_to_cart', function() {
867				setTimeout(function(){
868					$(document.body).trigger('wc_fragment_refresh');
869				}, 500);
870			} );
871		} else {
872			$( document.body ).on( 'added_to_cart', show_added_to_cart );
873		}
874
875		$(document).ready(function() {
876			if ( $('body').hasClass('uncode-wc-added-to-cart')) {
877				show_added_to_cart('uncode-wc-added-to-cart');
878			}
879		});
880
881	};
882
883	minicart_notify();
884
885	/************************************************************
886	 * View Cart Button
887	************************************************************/
888	$( document.body ).on( 'wc_cart_button_updated', function(e, $button){
889		if ( $(document.body).hasClass('minicart-notification') || wc_add_to_cart_params == undefined ) {
890			return false;
891		}
892
893		$button
894			.addClass('added_and_noted')
895			.removeClass('ajax_add_to_cart')
896			.find('.added_to_cart')
897			.text( wc_add_to_cart_params.i18n_view_cart )
898			.on('click', function(e){
899				e.preventDefault();
900				window.location.href = wc_add_to_cart_params.cart_url;
901				return false;
902			});
903	});
904
905	/************************************************************
906	 * Side Cart
907	************************************************************/
908	var init_sidecart = function(){
909		var $body = $('body.uncode-sidecart-enabled');
910		if ( ! $body.length ) {
911			return false;
912		}
913
914		var $cart_icon = $('.mobile-shopping-cart, .uncode-cart.menu-item-link > a'),
915			$sidecart = $('#uncode_sidecart'),
916			$view_cart = $('a.wc-forward:not(.checkout)', $sidecart).removeClass('btn-sm'),
917			$checkout = $('a.checkout', $sidecart).removeClass('btn-sm').addClass('btn-flat'),
918			$overlay = $('#uncode_sidecart_overlay'),
919			$close_cart = $('.close-mini-cart', $sidecart),
920			sidecart_hover = false;
921
922		$cart_icon.off('click').on('click', function( e ){
923			if ( $sidecart.length && ! ( $(this).closest('.overlay').length && UNCODE.wwidth > UNCODE.mediaQuery ) && ( ! ( $body.hasClass('uncode-sidecart-mobile-disabled') && UNCODE.wwidth <= UNCODE.mediaQuery ) ) ) {
924				e.preventDefault();
925				e.stopPropagation();
926				sideCart_scrollTop = $('html, body').scrollTop();
927				$body.addClass('uncode-sidecart-open');
928				$(window).trigger('uncode-sidecart-open');
929				$('html, body').scrollTop(sideCart_scrollTop);
930			}
931		});
932
933		$sidecart.on('mouseover',function(){
934			sidecart_hover = true;
935		}).on('mouseout', function(){
936			sidecart_hover = false;
937		});
938
939		$body.on('click', function( e ){
940			if ( $body.hasClass('uncode-sidecart-open') && !sidecart_hover ) {
941				$body.removeClass('uncode-sidecart-open');
942				$(window).trigger('uncode-sidecart-closed');
943				$('html, body').scrollTop(sideCart_scrollTop);
944			}
945		});
946
947		$close_cart.on('click', function( e ){
948			e.preventDefault();
949			$body.removeClass('uncode-sidecart-open');
950			$(window).trigger('uncode-sidecart-closed');
951			$('html, body').scrollTop(sideCart_scrollTop);
952		});
953	};
954	$(document).ready(function(){
955		init_sidecart();
956	});
957	$( document.body ).on("wc_fragments_refreshed added_to_cart removed_from_cart", function(){
958		init_sidecart();
959		requestTimeout( init_sidecart, 1 );
960	});
961
962	var sidecart_size = function(){
963		var $body = $('body.uncode-sidecart-enabled'),
964			$widget_cart = $('.widget_shopping_cart_content'),
965			$mini_cart_item = $('.mini_cart_item', $widget_cart);
966
967		if ( $widget_cart.length ) {
968			$mini_cart_item.each(function(){
969				var $this = $(this),
970 					$img_product = $('.attachment-woocommerce_thumbnail', $this),
971 					imgH = $img_product.height();
972
973 				$this.css({
974 					'min-height': imgH+6
975 				})
976
977			});
978		}
979		if ( $body.length ) {
980
981			var $sidecart = $('#uncode_sidecart'),
982				$cart_header = $('.woocommerce-mini-cart-header', $sidecart),
983				headerH = $cart_header.outerHeight(),
984				$cart_footer = $('.woocommerce-mini-cart-footer', $sidecart),
985				footerH = $cart_footer.outerHeight(),
986				$cart_body = $('.woocommerce-mini-cart-body', $sidecart);
987
988			$cart_body.css({
989				'padding-top':headerH,
990				'padding-bottom':footerH
991			});
992
993		}
994	};
995	$(document).ready(function(){
996		var setCTA;
997		sidecart_size();
998		requestTimeout(function(){
999			$(window).on( 'resize', function(){
1000				clearRequestTimeout(setCTA);
1001				setCTA = requestTimeout( sidecart_size, 100 );
1002			});
1003		}, 400);
1004	});
1005	$( document.body ).on("wc_fragments_refreshed added_to_cart removed_from_cart", function(){
1006		sidecart_size();
1007		requestTimeout( sidecart_size, 1 );
1008	});
1009
1010	/************************************************************
1011	 * Quick view
1012	 ************************************************************/
1013
1014	var modal_quick_view_content = $('.quick-view-content');
1015	var last_viewed_product_id;
1016
1017	$(document).off('click', '.quick-view-button').on('click', '.quick-view-button', function() {
1018		var _this = $(this);
1019		var product_id = _this.data('post-id');
1020		var post_type = _this.data('post-type');
1021		var post_url = _this.attr('data-post-url');
1022		var single_variation_atts = _this.attr('data-single-variation');
1023
1024		// Empty modal
1025		if (modal_quick_view_content.length > 0) {
1026			modal_quick_view_content.html('');
1027		}
1028
1029		var data = {
1030			action: 'uncode_load_ajax_quick_view',
1031			post_id: product_id,
1032			post_type: post_type,
1033			post_url: post_url,
1034		};
1035
1036		if (single_variation_atts) {
1037			var variation_atts_obj = JSON.parse(single_variation_atts)
1038
1039			for (var att_key in variation_atts_obj) {
1040				if (variation_atts_obj[att_key]) {
1041					data['attribute_' + att_key] = variation_atts_obj[att_key];
1042				}
1043			}
1044		}
1045
1046		// Get quick view content via AJAX
1047		$.ajax({
1048			url: woocommerce_params.ajax_url,
1049			data: data,
1050			type: 'post',
1051			error: function(data) {
1052				if (SiteParameters.enable_debug == true) {
1053					// This console log is disabled by default
1054					// So nothing is printed in a typical installation
1055					//
1056					// It can be enabled for debugging purposes setting
1057					// the 'uncode_enable_debug_on_js_scripts' filter to true
1058					console.log('AJAX error on quick view response');
1059				}
1060			},
1061			success: function(response) {
1062				if (response && response.success === false) {
1063					if (SiteParameters.enable_debug == true) {
1064						// This console log is disabled by default
1065						// So nothing is printed in a typical installation
1066						//
1067						// It can be enabled for debugging purposes setting
1068						// the 'uncode_enable_debug_on_js_scripts' filter to true
1069						if (response.data.error) {
1070							console.log(response.data.error);
1071						} else {
1072							console.log('Unknown error on quick view response');
1073						}
1074					}
1075				} else {
1076					var html = response.data.html;
1077
1078					if (modal_quick_view_content.length > 0) {
1079						modal_quick_view_content.html(html);
1080					}
1081
1082					last_viewed_product_id = product_id;
1083
1084					modal_quick_view_content.imagesLoaded().done( function( instance ) {
1085						$(document).trigger('uncode-unmodal-show-content');
1086						$(document).trigger('uncode-quick-view-loaded');
1087						window.dispatchEvent(new CustomEvent('uncode-quick-view-loaded'));
1088
1089						setTimeout(function(){
1090							modal_quick_view_content.one('mousemove', function(){
1091								window.dispatchEvent(new CustomEvent('uncode-quick-view-first-hover'));
1092							});
1093						}, 10);
1094					});
1095				}
1096			}
1097		});
1098
1099		return false;
1100	});
1101
1102	$(document).on('uncode-quick-view-loaded', function() {
1103		var form_variation = modal_quick_view_content.find('.variations_form');
1104
1105		form_variation.each(function() {
1106			$(this).wc_variation_form();
1107		});
1108
1109		form_variation.trigger('check_variations');
1110		form_variation.trigger('reset_image');
1111
1112		if( typeof $.fn.wc_product_gallery !== 'undefined' ) {
1113			modal_quick_view_content.find('.woocommerce-product-gallery').each(function(){
1114				$(this).wc_product_gallery();
1115			});
1116		}
1117
1118		$( '#unmodal-content' ).on( 'change', '.quantity .qty', function() {
1119			jQuery( this ).closest('form.cart').find('.add_to_cart_button').attr( 'data-quantity', jQuery( this ).val() );
1120		});
1121
1122		woocommerce_product_gallery();
1123		variation_price_font();
1124		qtyPlusMinus();
1125
1126		UNCODE.preventDoubleTransition();
1127		UNCODE.utils();
1128		if (typeof UNCODE.share !== 'undefined') {
1129			UNCODE.share();
1130		}
1131		if (typeof UNCODE.tooltip !== 'undefined') {
1132			UNCODE.tooltip();
1133		}
1134		if (typeof UNCODE.counters !== 'undefined') {
1135			UNCODE.counters();
1136		}
1137		if (typeof UNCODE.countdowns !== 'undefined') {
1138			UNCODE.countdowns();
1139		}
1140		if (typeof UNCODE.tabs !== 'undefined') {
1141			UNCODE.tabs();
1142		}
1143		if (typeof UNCODE.collapse !== 'undefined') {
1144			UNCODE.collapse();
1145		}
1146		if (typeof UNCODE.okvideo !== 'undefined') {
1147			UNCODE.okvideo();
1148		}
1149		if (typeof UNCODE.backgroundSelfVideos !== 'undefined') {
1150			UNCODE.backgroundSelfVideos();
1151		}
1152		UNCODE.tapHover();
1153		if (typeof UNCODE.isotopeLayout !== 'undefined') {
1154			UNCODE.isotopeLayout();
1155		}
1156		if (typeof UNCODE.justifiedGallery !== 'undefined') {
1157			UNCODE.justifiedGallery();
1158		}
1159		if (typeof UNCODE.cssGrid !== 'undefined') {
1160			UNCODE.cssGrid();
1161		}
1162		if (typeof UNCODE.lightbox !== 'undefined' && !SiteParameters.lbox_enhanced) {
1163			UNCODE.lightbox();
1164		}
1165		if (typeof UNCODE.lightgallery !== 'undefined' && SiteParameters.lbox_enhanced) {
1166			UNCODE.lightgallery();
1167		}
1168		if (typeof UNCODE.carousel !== 'undefined') {
1169			UNCODE.carousel($('body'));
1170		}
1171		UNCODE.lettering();
1172		UNCODE.animations();
1173		UNCODE.stickyElements();
1174		if (typeof UNCODE.twentytwenty !== 'undefined') {
1175			UNCODE.twentytwenty();
1176		}
1177		UNCODE.disableHoverScroll();
1178		if (typeof uncode_progress_bar !== 'undefined') {
1179			uncode_progress_bar();
1180		}
1181		if (typeof UNCODE.filters !== 'undefined') {
1182			UNCODE.filters();
1183		}
1184		if (typeof UNCODE.ajax_filters !== 'undefined') {
1185			UNCODE.ajax_filters();
1186		}
1187		if (typeof UNCODE.widgets !== 'undefined') {
1188			UNCODE.widgets();
1189		}
1190
1191		$(document).trigger('yith_wcwl_init');
1192	});
1193
1194	/************************************************************
1195	 * Trigger fragments
1196	 ************************************************************/
1197	if ( SiteParameters.update_wc_fragments == true ) {
1198		$(document).ready(function() {
1199			$(document.body).trigger('wc_fragment_refresh');
1200		});
1201	}
1202
1203	/************************************************************
1204	 * Cart badge
1205	 ************************************************************/
1206	$(document).ready(function() {
1207		if ( SiteParameters.uncode_wc_popup_cart_qty ) {
1208			$(document.body).on('wc_fragments_loaded', function(){
1209				$('.cart-icon-container .badge').removeClass('init-product-counter');
1210			})
1211			.on('uncode_get_cart', function(e, data){
1212				if ( $('.cart-icon-container .badge').text() !== '' || ( data > 0 ) ) {
1213					$('.cart-icon-container .badge').addClass('init-product-counter');
1214				} else {
1215					$('.cart-icon-container .badge').removeClass('init-product-counter');
1216				}
1217			});
1218		}
1219	});
1220
1221	var clearZoomSet;
1222	$(window).on('load', function(){
1223		clearTimeout(clearZoomSet);
1224		clearZoomSet = setTimeout(function(){
1225			$('.zoomImg').each(function(){
1226				$(this).removeAttr('role');
1227			});
1228		}, 1);
1229	});
1230
1231})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.