PageSourceSearch

https://peppur.com/wp-content/themes/kapee/assets/js/functions.js?ver=1.6.23

js peppur.com collected 2026-10-10 01:50:34 UTC 145,068 bytes, 4,518 lines download raw bytes

1/*
2 * Theme js functions file.
3 */
4 
5var $ 				= jQuery.noConflict(),
6	kapeeOwlParam 	= kapeeOwlParam || {},
7	kapee_options 	= kapee_options || {}; 
8(function($) { 
9	
10    "use strict";
11	
12	var kapee 		= kapee || {};
13	
14	kapee.kapeePreLoader = function() {
15		// Preloader
16		var loader = $( '.kapee-site-preloader' );
17		if ( loader.length ) {
18			$( window ).on( 'beforeunload', function() {
19				loader.fadeIn( 500, function() {
20					loader.fadeIn( 100 )
21				});
22			});
23			
24			$( window ).on('load', function () {
25            loader.fadeOut( 800 );
26			});
27		}
28	}
29	
30	kapee.init = function() {
31		kapee.$doc          	= $(document);
32		kapee.$html    			= $('html');
33		kapee.$body 			= $(document.body);
34		kapee.$window 			= $(window);
35		kapee.$windowWidth 		= $(window).width();
36		kapee.$windowHeight 	= $(window).height();
37		kapee.ajaxXHR 			= null;
38		kapee.isPostLoading 	= false;
39		kapee.$tooltip 			= $('.product-buttons a,.whishlist-button a');
40		kapee.$swatches 		= kapee.$doc.find( 'div.kapee-swatches-wrap' );
41		kapee.$swatchForm 		= kapee.$doc.find( 'form.kapee-swatches-wrap.variations_form' );
42				
43		this.isCheckRTL();
44		this.mobileDevice();
45		this.BrowserDetection();
46		this.skeletonEffect();
47		this.backToTop();
48		this.imagelazyload();
49		this.reinitLazyload();
50		this.initNanoScroller();
51		this.initMagnaficPopup();
52		this.newsLetterPopup();	
53		this.kapeeMegamenu();
54		this.mobileMenu();
55		this.promoBar();		
56		this.stickyHeader();		
57		this.StickyHeaderScrollUP();		
58		this.stickySidebar();
59		this.canvasSidebar();
60		this.openMiniSearch();
61		this.widgetMenuToggle();
62		this.widgetToggle();
63		this.footerWidgetCollapse();
64		this.widgetMaxLimitItem();
65		this.kapeeOwlCarousel();
66		this.MasonryGrid();
67		this.postGalleryCarousel();
68		this.loadmorePosts();
69		this.socialShare();
70		this.portfolioFilters();
71		this.portfolioLoadMore();
72		
73		//Woocommerce
74		this.productLiveSearch();
75		this.swapLoginSignupFrom();
76		this.userLoginSignupPopup();
77		this.miniCartWidget();		
78		this.addToWishlist();
79		this.wishlistCount();		
80		this.addToCompare();		
81		//this.compareCount();
82		//this.removeToCompare();
83		//this.preventComparelink();
84		this.ProductLoopQuantityField();
85		this.addToCart();
86		this.addToCartAjax();		
87		this.stickyAddToCart();		
88		this.productQuickView();
89		this.productShowFilter();
90		this.productShowHideFilters();
91		this.productFilterAjax();	
92		this.productHover();	
93		this.productSwatch();
94		this.variationsImageChange();
95		this.initAjaxLoad();
96		this.loadmoreProducts();
97		this.tooltip();
98		this.productGallerySlider();
99		this.productImageZoom();
100		this.productPhotoSwipe();
101		this.productSaleCountdown();
102		this.productReviewLink();
103		this.productPriceSummary();
104		this.getProductSizeChart();
105		this.getAjaxBlock();
106		this.getProductTermsConditions();
107		this.productQuantityPlusMinus();
108		this.productQuickShop();
109		this.productBoughtTogetherInit();
110		this.wooProductTabsAccordian();
111		this.wooProductTabsToggle();		
112		this.wooCheckoutStep();
113		this.resetVariations();
114		this.variationChangeevent();
115		this.wcfm_vendor();
116		this.MiniCartUpdateQuantity();
117		this.autoCartUpdate();
118		this.checkoutUpdateQuantity();
119		this.getVisitorCount();
120		this.askQuestionsForm();
121		
122		//Elements
123		this.kapeeEqualTabsHeight();
124		this.kapeeTabEffect();
125		this.kapeeAjaxTab();
126		this.kapeeResponsiveTab();
127		this.kapeeProgressbar();
128		this.kapeeCounterUp();
129		this.imageGaleryMasonry();
130		this.BackgroundParallax();
131		
132	};
133	
134	kapee.isCheckRTL = function(){
135		/*
136		* If check is site RTL
137		*/		
138		$('html[dir="rtl"] body').addClass('rtl');
139		var kapee_rtl = false;
140		if($('body,html').hasClass('rtl')){ 
141			kapee_rtl =  true;
142		}	
143		
144		return kapee_rtl;
145	};
146	
147	kapee.mobileDevice = function() {
148		var window_size = jQuery('body').innerWidth();
149		if(window_size < 991){
150			jQuery('body').addClass('kapee-mobile-device');
151		}else{
152			jQuery('body').removeClass('kapee-mobile-device');
153		}
154		 kapee.$window.on('resize', function () {
155			var window_size = jQuery('body').innerWidth();
156			if(window_size < 991){
157				jQuery('body').addClass('kapee-mobile-device');
158			}else{
159				jQuery('body').removeClass('kapee-mobile-device');
160			}
161		}); 
162	};
163	
164	kapee.BrowserDetection = function () {
165		//Check if browser is IE
166		if (navigator.userAgent.search("MSIE") >= 0) {
167			jQuery('body').addClass('browser-msie');
168		}
169		//Check if browser is Chrome
170		else if (navigator.userAgent.search("Chrome") >= 0) {
171			jQuery('body').addClass('browser-chrome');
172		}
173		//Check if browser is Firefox 
174		else if (navigator.userAgent.search("Firefox") >= 0) {
175			jQuery('body').addClass('browser-firefox');
176		}
177		//Check if browser is Safari
178		else if (navigator.userAgent.search("Safari") >= 0 && navigator.userAgent.search("Chrome") < 0) {
179			jQuery('body').addClass('browser-safari');
180		}
181		//Check if browser is Opera
182		else if (navigator.userAgent.search("Opera") >= 0) {
183			jQuery('body').addClass('browser-opera');
184		}
185	};	
186	
187	kapee.skeletonEffect = function(){
188		//*******************************************************************
189		//* Skeleton Effect
190		//********************************************************************/
191		if( !kapee_options.skeleton_effect ){ return;}
192		if( kapee.$body.hasClass( 'kapee-skeleton' ) ) {
193			kapee.$body.removeClass( 'kapee-skeleton' );
194		}		
195	};
196	
197	kapee.backToTop = function(){
198		//*******************************************************************
199		//* Back to top button 
200		//********************************************************************/
201		var el = $('.kapee-back-to-top');
202		kapee.$window.on('scroll',function(){				
203			if(el.length > 0){
204				if( kapee.$window.scrollTop() > 150 ){
205					el.fadeIn(400);	
206				}else{
207					el.fadeOut(400);	
208				}	
209			}	
210		});
211		
212		el.on('click', function (e) {
213				$('html,body').animate({scrollTop:0}, 600);	
214				return false;
215		});				
216	};
217	
218	kapee.imagelazyload = function(){
219		if ( kapee.$body.find('.lazy').length > 0 && kapee_options.lazy_load ) {
220			var lazy_args = [];
221			lazy_args.afterLoad      = function (element) {
222				element.removeClass('lazy');
223				element.removeClass('loading');
224				element.addClass('lazy-loaded');
225			};
226			lazy_args.effect         = "fadeIn";
227			lazy_args.enableThrottle = true;
228			lazy_args.throttle       = 250;
229			lazy_args.effectTime     = 1000;
230			lazy_args.threshold      = 0;
231			kapee.$body.find('.lazy').lazy(lazy_args);		
232			
233			
234		}
235	};
236	
237	kapee.reinitLazyload = function(){
238		if ( !kapee_options.lazy_load )  return;
239		$(document).on('shown.bs.tab', 'a[data-toggle="tab"]', function (e) {
240			kapee.imagelazyload();			
241		});
242		$(document).on('removed_from_cart wc_fragments_refreshed updated_checkout', function (e) {
243			kapee.imagelazyload();			
244		});
245		$(window).bind('mousewheel DOMMouseScroll', function(event){
246			if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) {
247				//alert('up');
248			}
249			else {
250				kapee.imagelazyload();		
251			}
252		});
253	}
254	
255	kapee.initNanoScroller = function() {
256		/*
257		* Nano Scroller
258		*/		
259		if( $(window).width() < 1024 ) return;
260		$(".kapee-scroll").nanoScroller({
261			paneClass: 'kapee-scroll-pane',
262			sliderClass: 'kapee-scroll-slider',
263			contentClass: 'kapee-scroll-content',
264			preventPageScrolling: false
265		});
266
267		$( 'body' ).on( 'wc_fragments_refreshed wc_fragments_loaded added_to_cart', function() {
268			$(".widget_shopping_cart .kapee-scroll").nanoScroller({
269				paneClass: 'kapee-scroll-pane',
270				sliderClass: 'kapee-scroll-slider',
271				contentClass: 'kapee-scroll-content',
272				preventPageScrolling: false
273			});
274		} );
275		
276		$('.sidebar-inner .kapee-scroll').nanoScroller({ destroy: true });
277	}
278	
279	kapee.initMagnaficPopup = function (){		
280		
281		var wordpress_galery = $(document).find('.gallery');
282		wordpress_galery.each(function(index){
283			var current_gallery = $(this);
284			$(current_gallery).magnificPopup({
285			delegate: 'img',
286			type: 'image',
287			removalDelay: 500,
288			callbacks: {
289				beforeOpen: function() {
290					this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
291					this.st.mainClass = 'mfp-with-zoom mfp-img-mobile';
292				},
293				elementParse: function(item) {  item.src = item.el.attr('src'); }
294			},
295			image: {
296				verticalFit: true
297			},
298			gallery: {
299				enabled: true,
300				navigateByImgClick: true
301			},
302		});
303			
304		});
305		
306		$('.product-360-degree-btn a').magnificPopup({
307		  type: 'inline',
308		  midClick: true,
309		  mainClass: 'mfp-fade'
310		});
311		
312		init_magnificpopup('.portfolios-list','a.project-zoom');
313		init_magnificpopup('.kapee-gallery-carousel','.owl-item:not(.cloned) a');
314		init_magnificpopup('.kapee-portfolio-image:not(.kapee-gallery-carousel)','.kapee-post-gallery__image a');
315		init_magnificpopup('.related.portfolios .kapee-carousel','.owl-item:not(.cloned) a.project-zoom');
316		init_magnificpopup('.kapee-portfolios-carousel','.owl-item:not(.cloned) a.project-zoom');
317		init_magnificpopup('.kapee-image-gallery.image-gallery-normal-grid','a');
318		init_magnificpopup('.kapee-image-gallery.image-gallery-masonry-grid','a');
319		init_magnificpopup('.kapee-image-gallery.image-gallery-carousel','.owl-item:not(.cloned) a');
320		
321		function init_magnificpopup(container,delegate){
322			
323			var container_wrap = $(document).find(container);
324			
325			if( typeof('container_wrap') !== 'undefined' && container_wrap != '' ) {
326				container_wrap.each(function(index){
327					var portfolio_item = $(this);
328					$(portfolio_item).magnificPopup({
329						delegate    : delegate,
330						type: 'image',
331						removalDelay: 500,
332						callbacks: {
333							beforeOpen: function() {
334								this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
335								this.st.mainClass = 'mfp-with-zoom mfp-img-mobile';
336							}
337						},
338						image: {
339							verticalFit: true
340						},
341						gallery: {
342							enabled: true,
343							navigateByImgClick: false
344						},
345					});
346					
347				});
348			}
349		}
350		
351		$('.link-popup').magnificPopup({
352			type: 'image',
353			removalDelay: 500,
354			callbacks: {
355				beforeOpen: function() {
356					this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
357					this.st.mainClass = 'mfp-with-zoom mfp-img-mobile';
358				}
359			},
360			image: {
361				verticalFit: true
362			},
363		});
364		
365		var $ombed_vids = $(".kapee-video-popup");		
366		if( $ombed_vids.length > 0 ) {			
367			$ombed_vids.each(function () {
368				var $mfp_popup_link_non_html5 = $(this);
369
370				$($mfp_popup_link_non_html5).magnificPopup({
371					disableOn: 320,
372					type: 'iframe',
373					mainClass: 'mfp-fade product-video-popup',
374					removalDelay: 160,
375					preloader: false,
376					fixedContentPos: false,
377					iframe: {
378						patterns: {
379							youtube: {
380								index: 'youtube.com/',
381								id: function(url) {
382									var m = url.match(/[\\?\\&]v=([^\\?\\&]+)/);
383									if ( !m || !m[1] ) return null;
384									return m[1];
385								},
386								src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
387							},
388							youtu: {
389								index: 'youtu.be',
390								id: '/',
391								src: '//www.youtube.com/embed/%id%?autoplay=1&rel=0'
392							},
393							vimeo: {
394								index: 'vimeo.com/',
395								id: function(url) {
396									var m = url.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);
397									if ( !m || !m[5] ) return null;
398									return m[5];
399								},
400								src: '//player.vimeo.com/video/%id%?autoplay=1'
401							},
402						}
403					}
404				});
405			});
406		}		
407    };
408	
409	kapee.newsLetterPopup = function(){		
410		
411		var popup_enable 		= kapee_options.newsletter_args.popup_enable,
412			popup_display_on 	= kapee_options.newsletter_args.popup_display_on,
413			popup_delay 		= kapee_options.newsletter_args.popup_delay,
414			x_scroll 			= kapee_options.newsletter_args.popup_x_scroll,
415			show_for_mobile 	= parseInt(kapee_options.newsletter_args.show_for_mobile),
416			popup_exit 			= false,
417			startinterval 		= false,
418			newsletter_key 		= 'kapee_newsletter_closed_' + kapee_options.newsletter_args.version,
419			popup_closed 		= Cookies.get( newsletter_key ),
420			$news_letter_wrap 	= $('.kapee-newsletter-popup'),
421			from_button         = false;
422		
423		if( ! $news_letter_wrap.length ) {
424			return false;
425		}
426		
427		//yith-woocompare
428		if( jQuery(document).find('#yith-woocompare').length > 0 ){
429			return false;
430		}
431		
432		
433		if( ! popup_enable || kapee_options.maintenance_mode || ( ! show_for_mobile && $(window).width() < 768 ) ){
434			return false; 
435		}
436		
437		//newsletter popup opened from button on click by user
438		//it must be enabled even if with 'do-not-show' cookie saved
439		var newsletter_btn = $('.header-newsletter');
440		newsletter_btn.on('click',function(){
441			from_button = true;
442			show_popup();
443		});
444		
445		
446		if( popup_closed == 'do-not-show' ) {
447			return false; 
448		}
449		
450		if( popup_display_on == 'exit' ){
451			jQuery(document).on('mouseleave', function (e) {
452				show_popup();
453			});
454		}else if( popup_display_on == 'scroll' ){
455
456            jQuery(window).scroll(function () {
457                var h = jQuery(document).height() - jQuery(window).height();
458                var sp = jQuery(window).scrollTop();
459                var p = parseInt(sp / h * 100);
460
461                if (p >= x_scroll) {
462                   show_popup();                
463                }
464            });
465        }else{
466			if( popup_delay ){
467				setTimeout(function(){show_popup(); }, popup_delay * 1000);	
468			}else{
469				show_popup();
470			}			         
471        }
472		
473		$news_letter_wrap.find('.mc4wp-form').submit(function () {
474            Cookies.set( newsletter_key , 'do-not-show', { expires: parseInt(kapee_options.newsletter_args.show_in_next_days), path: '/' });
475        });
476		
477		function show_popup() {			
478			// popup must open everytime if the user clicked to open it
479			if(popup_exit && !from_button){
480				return;
481			}
482			popup_exit = true;
483			
484			$.magnificPopup.open({
485				type: 'inline',
486				removalDelay: 500,
487				items: {
488					src: '.kapee-newsletter-popup' ,					
489				},
490				callbacks: {
491					open: function () {
492						var popupWrap = $( '.kapee-newsletter-popup' );
493						popupWrap.addClass('animate__animated animate__fadeInLeft');						
494						
495						// donotshow div element must be hidden if the user clicked to open popup
496						if (from_button)
497							$('#newsletter-donotshow').parent('div').hide();
498					},							
499					beforeClose: function() {
500						var popupWrap = $( '.kapee-newsletter-popup' );
501						popupWrap.removeClass('animate__fadeInLeft').addClass('animate__fadeOutRight');
502					}, 
503					close: function() {
504						this.content.removeClass('animate__animated animate__fadeOutRight'); 
505						// check box click
506						if($('#newsletter-donotshow:checked') && $('#newsletter-donotshow:checked').val() == 'do-not-show'){
507							Cookies.set( newsletter_key , 'do-not-show', { expires: parseInt(kapee_options.newsletter_args.show_in_next_days), path: '/' });
508						}						
509						
510						// we restore the default visibility of donotshow div element if the user clicked to open popup
511						if (from_button) {
512							$('#newsletter-donotshow').parent('div').show();
513							from_button = false;
514						}
515					}
516				},				
517			});
518		}
519	};
520	
521	kapee.wowAnimation = function() {
522		// WOW ANIMATION
523		if($('.wow').length > 0)
524		{
525			var wow = new WOW(
526			{
527			  boxClass:     'wow',      // animated element css class (default is wow)
528			  animateClass: 'animated', // animation css class (default is animated)
529			  offset:       50,          // distance to the element when triggering the animation (default is 0)
530			  mobile:       false       // trigger animations on mobile devices (true is default)
531			});
532			wow.init();	
533		}	
534	}
535	
536	kapee.kapeeMegamenu = function(){
537		
538		var main_menu_wrap 				= $('.main-navigation').find('ul.menu');
539		
540		main_menu_wrap.on('mouseover', ' > li.kapee-megamenu-dropdown', function(e) {
541			setOffset( $(this) );
542		});
543		jQuery(window).resize(function() {
544			main_menu_wrap.on('mouseover', ' > li.kapee-megamenu-dropdown', function(e) {
545				setOffset( $(this) );
546			});
547		});
548
549		var setOffset = function( li ) {
550
551			var megaMenuWrapper 		= li.find(' > .kapee-megamenu-wrapper'),
552				megaMenuHolder 			= li.find(' .kapee-megamenu-holder');
553			
554			megaMenuWrapper.attr('style', '');
555
556			var container	 			= $('.site-header .container'),
557				containerWidth 			= container.outerWidth(),
558				containerOffsetLeft 	= container.offset().left + 15,
559				containerPaddingLeft 	= parseInt(container.css('padding-left')),
560				containerPaddingRight 	= parseInt(container.css('padding-right')),
561				viewportWidth 		  	= containerWidth - containerPaddingLeft - containerPaddingRight;
562				
563			if( li.hasClass( 'kapee-megamenu-item-full-width' ) ) { 
564				megaMenuHolder.css({
565					width: viewportWidth
566				});
567			}
568			
569			var	megaMenuWrapperWidth	= megaMenuWrapper.outerWidth(),
570				megaMenuWrapperOffset	= megaMenuWrapper.offset();		
571				
572			if( ! megaMenuWrapperWidth || ! megaMenuWrapperOffset ) return;
573			
574			var mega_menu_wrapOffsetRight = viewportWidth - megaMenuWrapperOffset.left - megaMenuWrapperWidth;
575			
576			if( $('body').hasClass('rtl') && mega_menu_wrapOffsetRight + megaMenuWrapperWidth + containerOffsetLeft >= viewportWidth && ( li.hasClass( 'kapee-megamenu-dropdown' ) ) ) {
577				
578				var toLeft = mega_menu_wrapOffsetRight + megaMenuWrapperWidth - viewportWidth + containerOffsetLeft;
579				megaMenuWrapper.css({
580					right: - toLeft
581				}); 
582
583			}else if( megaMenuWrapperOffset.left + megaMenuWrapperWidth - containerOffsetLeft >= viewportWidth && ( li.hasClass( 'kapee-megamenu-dropdown' ) ) ) {
584				
585				var toRight = megaMenuWrapperOffset.left + megaMenuWrapperWidth - viewportWidth - containerOffsetLeft;
586				megaMenuWrapper.css({
587					left: - toRight
588				}); 
589			}				
590		};	
591	}
592	
593	kapee.mobileMenu = function(){
594		/*
595		* Mobile menu
596		*/
597		
598		//Menu wrapper
599		$(document).on('click', '.mobile-nav-tabs li', function(e) {
600			if(!$(this).hasClass("active")){
601				var cn=$(this).data("menu");
602				$(this).parent().find(".active").removeClass("active");
603				$(this).addClass("active");
604				$(".mobile-nav-content").removeClass("active").fadeOut(300);
605				$(".mobile-"+cn+"-menu").addClass("active").fadeIn(300);
606			}
607		});
608		
609		//Menu
610		var $mobileMenu 	= $('.kapee-mobile-menu'),
611			$closeSidebar 	= $('.kapee-mask-overaly');
612		$( '.mobile-navbar .navbar-toggle,.mobile-element .navbar-toggle' ).on( 'click', function ( e ) {
613			e.preventDefault();			
614			if ( ! $mobileMenu.hasClass('opened') ) {
615				$mobileMenu.addClass('opened');
616				$closeSidebar.addClass('opened');
617			}
618		});
619		
620		kapee.$body.on('click', '.kapee-mask-overaly, .kapee-mobile-menu .close-sidebar', function (e) {
621			if ( $mobileMenu.hasClass( 'opened' ) ) {
622				$mobileMenu.removeClass('opened');
623				$closeSidebar.removeClass('opened');
624			}
625		});
626		
627		$( '.mobile-main-menu li.menu-item-has-children' ).append( '<span class="menu-toggle"></span>' );
628		
629		$mobileMenu.on('click', '.menu-item-has-children > .menu-toggle', function (e) {
630			e.preventDefault();
631
632			$(this).closest('li').siblings().find('ul').slideUp();
633			$(this).closest('li').siblings().removeClass('active');
634			$(this).closest('li').siblings().find('li').removeClass('active');
635
636			$(this).closest('li').children('ul').slideToggle();
637			$(this).closest('li').toggleClass('active');
638
639		});
640		
641		kapee.$body.on('click', '.kapee-mask-overaly', function (e) {
642			if ( $mobileMenu.hasClass( 'opened' ) ) {
643				$mobileMenu.removeClass('opened');
644				$closeSidebar.removeClass('opened');
645			}
646		});
647		
648		kapee.$window.on('resize', function () {
649			if ( kapee.$window.width() > 991 ) {
650				if ( $mobileMenu.hasClass( 'opened' ) ) {
651					$mobileMenu.removeClass('opened');
652					$closeSidebar.removeClass('opened');
653				}
654			}
655		});
656	};
657	
658	kapee.promoBar = function(){
659		/*
660		 * Promo Bar
661		 */
662		var $promo_bar 			= $( '.kapee-promo-bar' ),
663			$siteWrapper 		= $( '.site-wrapper' ),
664			$siteHeader 		= $( '.site-header' ),
665			$stickyElements 	= $( '.header-sticky' ),
666			position_type 		= $promo_bar.attr('data-position_type'),
667			position 			= $promo_bar.attr('data-position'),
668			promo_barHeight 	= $promo_bar.outerHeight(),
669			adminBarHeight 		= $('#wpadminbar').outerHeight();
670			
671		if( position == 'top' && position_type == 'fixed'){
672			$siteWrapper.css({'margin-top' : promo_barHeight + 'px'});
673		}
674		// Set a cookie and hide Promo bar when the dismiss button is clicked
675		var promo_bar_key = 'kapee_promo_bar_close';
676		$( '.promo-bar-close' ).on( 'click', function( event ) {
677			event.preventDefault();
678			if( $(this).hasClass('promo-bar-dismiss') ) {
679				Cookies.set( promo_bar_key, true, { path: '/' ,expires: parseInt(kapee_options.show_promobar_in_next_days)} );
680			}
681			if( position == 'top' && position_type == 'fixed'){
682				$siteWrapper.css({'margin-top' : '0px'});
683			}
684			if( position == 'top' && position_type == 'fixed'){
685				if(adminBarHeight){
686					if( $siteHeader.hasClass('header-sticked')){
687					$stickyElements.css({
688					'top': adminBarHeight+'px'
689				});
690				}
691				}else{
692					if( $siteHeader.hasClass('header-sticked')){
693							$stickyElements.css({
694							'top': '0px'
695						});
696						}
697				}
698			}
699			$promo_bar.slideUp('slow',function(){ $(this).remove();});
700			
701		});
702	};
703	
704	kapee.stickyHeader = function(){
705		//*******************************************************************
706		//*  Sticky Header.
707		//*******************************************************************/
708		var $header 		= $( '.site-header' ),
709			$stickyElements = $( '.header-sticky' ),
710			$firstSticky 	= $stickyElements.first(),
711			headerHeight 	= $header.outerHeight(),
712			$window 		= $(window),
713			isSticked 		= false,
714			adminBarHeight 	= $('#wpadminbar').outerHeight(),
715			stickShowAfter 	= headerHeight + 5;
716			
717			 $(window).on( 'scroll' , function () {
718				var windowSize = $(window).width();
719				kapee.promoBar();
720				//Disable sticky in desktop
721				if( windowSize > 992 && ( ! kapee_options.sticky_header ) ){
722					return false; 
723				}
724				
725				// Disable sticky in tablet
726				if( windowSize <= 992 && windowSize > 480 && ( ! kapee_options.sticky_header_tablet ) ){
727					return false;
728				}
729				
730				//Disable sticky in mobile
731				if( windowSize <= 480 && ( ! kapee_options.sticky_header_mobile ) ){
732					return false;
733				}
734				var stickyOffset	= stickShowAfter;
735				var currentScroll 	= $(this).scrollTop();
736				if ( currentScroll > stickyOffset ) {					
737					stickHeader();
738					if( $( '.header-sticky .categories-menu-wrapper' ).hasClass( 'opened-categories' ) ){
739						$( '.header-sticky .categories-menu-wrapper' ).removeClass( 'opened-categories' );
740					}
741				} else {
742					unstickHeader();
743				}
744			});
745			
746			function stickHeader() {
747				if ( isSticked ){ return; }
748				isSticked = true;
749				$header.addClass( 'header-sticked' );
750				var $promo_bar 		= $( '.kapee-promo-bar' ),
751				position_type = $promo_bar.attr('data-position_type'),
752				position = $promo_bar.attr('data-position'),
753				promo_barHeight 	= $promo_bar.outerHeight(),
754				adminBarHeight 	= $('#wpadminbar').outerHeight();
755				
756				if( position == 'top' && position_type == 'fixed'){
757					if(adminBarHeight){
758						adminBarHeight = parseInt(adminBarHeight) + parseInt(promo_barHeight);
759					}else{
760						adminBarHeight =  parseInt(promo_barHeight);
761					}
762				}
763				$stickyElements.css({
764					'top': adminBarHeight+'px'
765				});
766			}
767
768			function unstickHeader() {
769				if ( !isSticked ) {  return; }
770
771				isSticked = false
772				$header.removeClass( 'header-sticked' );
773				$stickyElements.css({
774					'top': 0
775				});
776			}
777	};
778	
779	kapee.StickyHeaderScrollUP = function(){
780		/*
781		* Sticky header on ScrollUp
782		*/		
783		if ( ! kapee_options.sticky_header ||  ! kapee_options.sticky_header_scroll_up) { return; }
784				
785		var origPosition = $(window).scrollTop();
786
787		$(window).scroll(function(e) {
788			var currentScroll = $(window).scrollTop();
789
790			if( currentScroll > origPosition ) {
791				$('.site-header').removeClass( 'scroll-up' ).addClass( 'scroll-down' );
792			} else {
793				$('.site-header').removeClass( 'scroll-down' ).addClass( 'scroll-up' );
794			}
795
796			origPosition = currentScroll;
797		});
798	};
799	
800	kapee.stickySidebar = function(){
801		/*
802		 *  Sticky Sidebar.
803		 */
804		if ( ! kapee_options.sticky_sidebar ) { return; }
805		
806		if ( typeof ( $.fn.stick_in_parent ) != 'undefined' ) {
807			$(document).ready(function(){
808				if( $( window ).width() <= 768  ) { return; }
809				
810				var sticky_sidebar = $( '#secondary .sidebar-inner' );	
811				var offset = 15;
812				
813				if ( $( '#header .header-sticky' )[0] ) {
814					offset = $( '#header .header-sticky' ).height() + 30;
815				}
816				
817				sticky_sidebar.stick_in_parent({ offset_top: offset });
818				
819				$( window ).resize(function() {
820					if ( $( window ).width() <= 768 ) {
821						sticky_sidebar.trigger( 'sticky_kit:detach' );					
822					}else{
823						sticky_sidebar.stick_in_parent({
824							offset_top: offset
825						});
826					}
827				});
828			});
829		}
830	};
831	
832	kapee.canvasSidebar = function(){
833		//*******************************************************************
834		//*  Canvas Sidebar.
835		//*******************************************************************/
836		
837		var sidebar_canvas 		= $( '.kapee-canvas-sidebar .kp-canvas-sidebar, .kapee-mobile-navbar .kp-canvas-sidebar' );
838		var secondary = $( '#secondary' );
839        var closeSidebar 	= $( '.kapee-mask-overaly' );
840		
841		sidebar_canvas.on('click', function(e) {
842			e.preventDefault();
843			
844			if ( ! secondary.hasClass('opened') ) {
845				secondary.addClass('opened');
846				setTimeout(function() {kapee.imagelazyload();}, 1000);
847				closeSidebar.addClass('opened');
848			}					
849		});
850		
851		kapee.$body.on('click', '.kapee-mask-overaly, .close-sidebar', function (e) {
852			e.preventDefault();
853			secondary.removeClass('opened');
854			closeSidebar.removeClass('opened');
855		});	
856		
857		kapee.$window.on('resize', function () {
858			if ( kapee.$window.width() > 767 ) {
859				if ( secondary.hasClass( 'opened' ) ) {
860					secondary.removeClass('opened');
861					closeSidebar.removeClass('opened');
862				}
863			}
864		});
865		
866	};
867	
868	kapee.openMiniSearch = function(){
869		//*******************************************************************
870		//* openMiniSearch
871		//*******************************************************************/
872		//if ( !kapee_options.sidebar_canvas_mobile ) return;
873		var sidebar_canvas 		= $('.header-mini-search > a');
874		var search_popup = $('.kapee-search-popup');
875       var closeSidebar 	= $('.kapee-search-popup .close-sidebar');
876		
877		sidebar_canvas.on('click', function(e) {
878			e.preventDefault();
879			
880			if ( ! search_popup.hasClass('opened') ) {
881				search_popup.addClass('opened');
882				//closeSidebar.addClass('opened');
883			}					
884		});
885		
886		closeSidebar.on('click', function(e) {
887			e.preventDefault();
888			
889			if ( search_popup.hasClass('opened') ) {
890				search_popup.removeClass('opened');
891			}					
892		});
893		
894		/* kapee.$body.on('click', '.kapee-mask-overaly, .close-sidebar', function (e) {
895			e.preventDefault();
896			
897			//closeSidebar.removeClass('opened');
898		});	 */
899		
900	};
901	
902	kapee.widgetMenuToggle = function(){
903		//*******************************************************************
904		//* Widget Menu Toggle
905		//*******************************************************************/
906		
907		if( kapee_options.widget_menu_toggle) {
908			/* Wordpress Menu widget */
909			$('#secondary .widget .menu-item > a').each(function(){
910				if( $(this).siblings('ul.sub-menu').length > 0 ) {
911					var $childIndicator = $('<span class="child-indicator"></span>');
912
913					$(this).siblings('.sub-menu').hide();
914					$('.current-menu-item > .sub-menu').show();
915					$('.current-menu-parent > .sub-menu').show();
916					if($(this).siblings('.sub-menu').is(':visible')){
917						$childIndicator.addClass( 'open-item' );
918					}
919
920					$childIndicator.on( 'click', function(){
921						$(this).parent().siblings('.sub-menu').toggle( 'fast', function(){
922							if($(this).is(':visible')){
923								$childIndicator.addClass( 'open-item' );
924							}else{
925								$childIndicator.removeClass( 'open-item' );
926							}
927						});
928						return false;
929					});
930					$(this).append($childIndicator);
931				}
932			});
933			
934			/* Product/Category widget */
935			$('#secondary .widget .cat-item > a').each(function(){
936				if( $(this).siblings('ul.children').length > 0 ) {
937					var $childIndicator = $('<span class="child-indicator"></span>');
938
939					$(this).siblings('.children').hide();
940					$('.current-cat > .children').show();
941					$('.current-cat-parent > .children').show();
942					if($(this).siblings('.children').is(':visible')){
943						$childIndicator.addClass( 'open-item' );
944					}
945
946					$childIndicator.on( 'click', function(){
947						$(this).parent().siblings('.children').toggle( 'fast', function(){
948							if($(this).is(':visible')){
949								$childIndicator.addClass( 'open-item' );
950							}else{
951								$childIndicator.removeClass( 'open-item' );
952							}
953						});
954						return false;
955					});
956					
957					if( ! $(this).find('.child-indicator').length > 0 ){
958						$(this).append($childIndicator);
959					}
960				}
961			});
962		}		
963	};
964	
965	kapee.widgetToggle = function(){
966		//*******************************************************************
967		//* Widget Menu Toggle
968		//*******************************************************************/		
969		if( kapee_options.widget_toggle) {
970			$( document ).find('.widget-area .widget').addClass('widget-toggle').removeClass('closed');
971			$( document ).on( 'click', '.widget-area .widget .widget-title, .dokan-widget-area .widget .widget-title', function(e) {
972				//$(this).unbind();
973				e.stopImmediatePropagation();
974				if ($(this).next().is(':visible')){
975                    $(this).parent().addClass('closed');
976                } else {
977                    $(this).parent().removeClass('closed');
978                }
979                $(this).next().stop().slideToggle(200);
980			});			
981		}
982	};
983	
984	kapee.footerWidgetCollapse = function(){
985		//*******************************************************************
986		//* Footer Widget Collapse
987		//*******************************************************************/	
988		if ($(window).width() > 576) {
989			return;
990		}
991		$( document ).on( 'click', '.kapee-mobile-device .footer-widget-collapse .widget .widget-title', function(e) {
992			var $title = $(this);
993			var $widget = $title.parent();
994			var $content = $widget.find('> *:not(.widget-title)');
995
996			if ($widget.hasClass('footer-widget-opened')) {
997				$widget.removeClass('footer-widget-opened');
998				$content.stop().slideUp(200);
999			} else {
1000				$widget.addClass('footer-widget-opened');
1001				$content.stop().slideDown(200);
1002			}
1003					
1004		});
1005				
1006	};
1007	
1008	kapee.widgetMaxLimitItem = function(){
1009		//*******************************************************************
1010		//* Widget Hide Max Limit Item
1011		//*******************************************************************/
1012		if( kapee_options.widget_hide_max_limit_item) {
1013			var js_translate_text = kapee_options.js_translate_text;
1014			$('.widget .widget-title + ul').hideMaxListItems({
1015				'max': kapee_options.number_of_show_widget_items,
1016				'speed': 500,
1017				'moreText': js_translate_text.show_more,
1018				'lessText': js_translate_text.show_less
1019			});
1020		}
1021	};
1022	
1023	kapee.kapeeOwlCarousel = function() { 
1024		/*
1025		 * Owl carousel slider
1026		 */
1027
1028		if ( kapeeOwlParam.length === 0 || typeof kapeeOwlParam.owlCarouselArg === 'undefined' ) {
1029			return; 
1030		}
1031		
1032		function add_owl_overlayclass(){
1033			$('.owl-stage-outer .product-wrapper').mouseenter(function(){
1034			var slider_elemnt = $(this).closest('.products.kapee-carousel');
1035			slider_elemnt.find('.owl-stage-outer').addClass('overlay');
1036		}).mouseleave(function(){
1037			var slider_elemnt = $(this).closest('.products.kapee-carousel');
1038			slider_elemnt.find('.owl-stage-outer').removeClass('overlay');
1039		});
1040		}
1041		setTimeout(function() {add_owl_overlayclass()}, 1000);
1042		$.each( kapeeOwlParam.owlCarouselArg, function ( id, owlCarouselArg ) {
1043			
1044			var loop 				= ( owlCarouselArg.slider_loop ) ? true : false,
1045				autoplay 			= ( owlCarouselArg.slider_autoplay ) ? true : false,							
1046				autoplayHoverPause 	= ( autoplay && owlCarouselArg.slider_autoplayHoverPause ) ? true : false,
1047				autoplaytimeout 	= owlCarouselArg.slider_autoplaytimeout,
1048				smartspeed 			= parseInt(owlCarouselArg.slider_smartspeed),
1049				
1050				rewind 				= ( owlCarouselArg.slider_rewind ) ? true : false,
1051				nav 				= ( owlCarouselArg.slider_nav ) ? true : false,		
1052				nav_mobile			= ( owlCarouselArg.slider_nav_mobile ) ? true : false,			
1053				center 				= ( owlCarouselArg.slider_center ) ? true : false,				
1054				dots 				= ( owlCarouselArg.slider_dots ) ? true : false,
1055				autoHeight 			= ( owlCarouselArg.slider_autoHeight ) ? true : false,
1056				touchDrag			= ( owlCarouselArg.slider_touchDrag ) ? true : false,
1057				touchDrag_mobile	= ( owlCarouselArg.slider_touchDrag_mobile ) ? true : false,
1058				animateIn 			= owlCarouselArg.slider_animatein,
1059				animateOut 			= owlCarouselArg.slider_animateout,
1060				margin 				= owlCarouselArg.slider_margin,
1061				rs_extra_large 		= ( owlCarouselArg.rs_extra_large > 0 ) ? parseInt( owlCarouselArg.rs_extra_large ) : 5,
1062				rs_large 			= ( owlCarouselArg.rs_large > 0 ) ? parseInt( owlCarouselArg.rs_large ) : 4,
1063				rs_medium 			= ( owlCarouselArg.rs_medium > 0 ) ? parseInt( owlCarouselArg.rs_medium ) : 3,
1064				rs_small 			= ( owlCarouselArg.rs_small > 0 ) ? parseInt( owlCarouselArg.rs_small  ): 2,
1065				rs_extra_small 		= ( owlCarouselArg.rs_extra_small > 0 ) ? parseInt( owlCarouselArg.rs_extra_small ) : 2,
1066				numItems 			= null,
1067				slider_element 		= null;
1068				
1069			if($('#'+id).hasClass('kapee-carousel')){
1070				numItems 			= $( '#'+id ).children().length;
1071				slider_element 		= $( '#'+id );
1072			}else{
1073				numItems 			= $( '#'+id).find( '.kapee-carousel').children().length;
1074				slider_element 		= $( '#'+id ).find( '.kapee-carousel');
1075			}
1076				
1077			slider_element.owlCarousel({				
1078				autoplay			: autoplay,
1079				autoplayHoverPause	: autoplayHoverPause,
1080				autoplayTimeout		: autoplaytimeout,
1081				smartSpeed 			: smartspeed,
1082				rewind				: rewind,				
1083				nav					: nav,
1084				center				: center,
1085				navText				: ['',''],
1086				dots				: dots,
1087				autoHeight			: autoHeight,
1088				touchDrag			: touchDrag,				
1089				animateIn			: animateIn,
1090				animateOut			: animateOut,
1091				margin				: margin,
1092				rtl 				: ( kapee.isCheckRTL() ) ? true : false,
1093				responsive			: {
1094					0:{
1095						items	: rs_extra_small,
1096						loop	: ( numItems >= rs_extra_small && loop ) ? true : false,
1097						nav		: nav_mobile,
1098						mouseDrag: false,
1099						touchDrag: touchDrag_mobile						
1100					},
1101					576:{
1102						items	: rs_small,
1103						loop	: ( numItems >= rs_small && loop ) ? true : false,
1104						nav		: nav_mobile,
1105						mouseDrag: false,
1106						touchDrag: touchDrag_mobile	
1107					},
1108					768:{
1109						items	: rs_medium,
1110						loop	: ( numItems >= rs_medium && loop) ? true : false,
1111						nav		: nav_mobile,
1112					},
1113					992:{
1114						items	: rs_large,
1115						loop	: ( numItems >= rs_large && loop) ? true : false,
1116					},					
1117					1200:{
1118						items 	: rs_extra_large,
1119						loop	: ( numItems >= rs_extra_large && loop) ? true : false,
1120					}
1121				},
1122				onInitialized: function(){
1123					slider_element.addClass('owl-theme');
1124				}
1125			}).on('changed.owl.carousel', function(event) {
1126				kapee.imagelazyload();
1127			}).on('translated.owl.carousel', function(event) {
1128				kapee.imagelazyload();
1129			});
1130		} );	
1131	};
1132	
1133	kapee.MasonryGrid = function (){
1134		
1135		/*
1136		* Init Masonry grid
1137		*/
1138		
1139		if($( '.articles-list.masonry-grid' ).length){
1140			 kapee.$body.imagesLoaded(function () {
1141				kapee.$body.find('.articles-list.masonry-grid').isotope({
1142					itemSelector: '.post',
1143					layoutMode: 'masonry'
1144				});
1145			});			
1146		}
1147	};
1148	
1149	kapee.postGalleryCarousel = function (){
1150		/*
1151		*  Post Gallery Carousel
1152		*/
1153		$('.kapee-gallery-carousel').owlCarousel({
1154			loop			: true,
1155			autoplay 		: false,
1156			autoplayTimeout : 3000,
1157			rtl 			: ( kapee.isCheckRTL() ) ? true : false,
1158			//rewind		: true,
1159			smartSpeed		: 750,
1160			nav 			: true,
1161			navText			: ['',''],
1162			dots			: true,		
1163			items			: 1
1164		});
1165		$( '.kapee-gallery-carousel').addClass('owl-theme owl-center');
1166	};
1167	
1168	kapee.loadmorePosts = function(){
1169		
1170		$('.kapee-blog-load-more .kapee-load-more').on('click',function(){
1171			
1172			var load_more_btn = $(this);
1173			var page = parseInt(load_more_btn.attr('data-page'));
1174			var attr = load_more_btn.attr('data-attribute');
1175			var post_wrap = load_more_btn.closest('.kapee-element').find('.articles-list');
1176            var wrap_id = load_more_btn.closest('.kapee-element').attr('id');
1177			var data = {
1178				action: 'kapee_loadmore_posts',
1179				nonce: kapee_options.nonce,
1180				attr: attr,
1181				page: page,
1182			};
1183			if(load_more_btn.hasClass('process')){ return false;}
1184			kapee.loadAjaxPost(load_more_btn,data,post_wrap,wrap_id);
1185		});
1186		var animationFrame = function () {
1187			$('.kapee-blog-load-more a.infinity-scroll').each(function (i, val) {
1188				var load_more_btn = $(this);
1189				var page = parseInt(load_more_btn.attr('data-page'));
1190				var attr = load_more_btn.attr('data-attribute');
1191				var post_wrap = load_more_btn.closest('.kapee-element').find('.articles-list');
1192				var wrap_id = load_more_btn.closest('.kapee-element').attr('id');
1193				var bottomOffset = post_wrap.offset().top + post_wrap.height() - $(window).scrollTop();
1194				if (bottomOffset < window.innerHeight && bottomOffset > 0) {
1195					if(load_more_btn.hasClass('process')){ 
1196						kapee.isPostLoading = true;
1197					}else{
1198						kapee.isPostLoading = false;
1199					}
1200					var page = parseInt(load_more_btn.attr('data-page'));
1201					if(!load_more_btn.hasClass('kapee-loadmore-disabled')){ 
1202						load_more_btn.trigger('click');
1203					}
1204				}
1205			});
1206		}
1207		
1208		var scrollHandler = function () {
1209			requestAnimationFrame(animationFrame);
1210		};                    
1211		$(window).scroll(scrollHandler);
1212	}
1213	
1214	kapee.socialShare = function (){
1215		/*
1216		* Social Share
1217		*/
1218		kapee.$doc.on('click', '.social-print', function(){
1219			window.print();
1220			return false;
1221		});
1222
1223		/*
1224		 * Open Share buttons in a popup
1225		 */
1226		kapee.$doc.on('click', '.social-share a', function(){
1227			var link = jQuery(this).attr('href');
1228			if( link != '#' ){
1229				window.open( link, 'TIEshare', 'height=450,width=760,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0' );
1230				return false;
1231			}
1232		});
1233	};
1234	
1235	kapee.portfolioFilters = function (){
1236		
1237		/*
1238		* Portfolio Filters
1239		*/
1240		
1241		if ( ! $('.portfolios-list').length > 0 ) return;
1242		var $layoutMode='masonry';
1243		
1244		if($( '.portfolios-list' ).length){
1245			$( '.portfolios-list' ).each(function(){
1246				if($( this ).hasClass('simple-grid') ){
1247					$layoutMode='fitRows';
1248				}
1249				var portfolio_container = $( this );
1250				// initialize Masonry after all images have loaded
1251                portfolio_container.imagesLoaded(function() {
1252					portfolio_container.isotope({
1253						itemSelector: '.portfolio-post-loop',
1254						isOriginLeft: ! $('body').hasClass('rtl'),
1255						layoutMode: $layoutMode
1256					});
1257				 });
1258			});
1259			
1260		}
1261		
1262		$('.filter-categories').on('click', 'a', function(e) {
1263			e.preventDefault();
1264			
1265			var $portfolio_container = $(this).closest('.portfolio-filter').next('.portfolios-list');
1266			if($portfolio_container.hasClass('simple-grid') ){
1267				$layoutMode='fitRows';
1268			}	
1269			$('.filter-categories').find('.active').removeClass('active');
1270			$(this).addClass('active');
1271			var filterValue = $(this).attr('data-filter');
1272			$portfolio_container.isotope({
1273				filter		: filterValue,
1274				layoutMode	: $layoutMode,
1275			});
1276			//return false;
1277		});
1278		
1279	};
1280	
1281	kapee.portfolioLoadMore = function () {
1282		
1283		$('.kapee-portfolio-load-more .kapee-load-more').on('click',function(){
1284						
1285			var $this = $(this),
1286				portfolio_wrap = $this.parent().parent().parent().find('.portfolios-list'),
1287				data_attr = $this.parent().data(),
1288				atts = data_attr.attribute,
1289				page = parseInt($this.parent().attr('data-page')),
1290				load_more_label = data_attr.load_more_label,
1291				loading_finished_msg = data_attr.loading_finished_msg;
1292				$this.addClass('request-running');
1293			if($this.hasClass('kapee-loadmore-disabled')){
1294				return;
1295			}
1296			$this.html('<span class="loading"> '+kapee_options.js_translate_text.loading_txt+'</span>');
1297			var data = {
1298					attr: atts,
1299					page: page,
1300					nonce: kapee_options.nonce,
1301					action: 'kapee_loadmore_portfolios',
1302				};
1303		
1304			$.ajax({
1305				url: kapee_options.ajax_url,
1306				data: data,
1307				dataType: 'json',
1308				method: 'POST',
1309				success: function (response) {
1310
1311					var portfolio_items = $(response.html);
1312					if (portfolio_items) {
1313						if (portfolio_wrap.hasClass('masonry-grid')) {
1314							// initialize Masonry after all images have loaded
1315							portfolio_wrap.append(portfolio_items).isotope('appended', portfolio_items);
1316							portfolio_wrap.imagesLoaded().progress(function () {
1317								portfolio_wrap.isotope('layout');								
1318							});
1319						} else {
1320							portfolio_wrap.append(portfolio_items);
1321						}						
1322					}
1323					if ($.trim(response.show_bt) == '0') {
1324						$this.addClass('disabled kapee-loadmore-disabled').html(loading_finished_msg);
1325					} else {
1326						$this.parent().attr('data-page', page + 1);					
1327						$this.html(load_more_label);
1328					}
1329
1330				},
1331				error: function (response) {
1332					console.log('ajax error');
1333				},
1334				complete: function () {
1335					kapee.isPostLoading = false;
1336					kapee.imagelazyload();
1337					kapee.initMagnaficPopup();			
1338					$this.removeClass('request-running');	
1339				},
1340			});
1341					
1342		});
1343		
1344		
1345		var animationFrame = function () {
1346			$('.kapee-portfolio-load-more a.infinity-scroll').each(function (i, val) {
1347				var $this = $(this),
1348				portfolio_wrap = $this.parent().parent().parent().find('.portfolios-list');
1349				var bottomOffset = portfolio_wrap.offset().top + portfolio_wrap.height() - $(window).scrollTop();
1350				if (bottomOffset < window.innerHeight && bottomOffset > 0) {
1351					if($this.hasClass('request-running')){ 
1352						kapee.isPostLoading = true;
1353					}else{
1354						kapee.isPostLoading = false;
1355					}
1356					
1357					if(!$this.hasClass('kapee-loadmore-disabled')){ 
1358						if(!kapee.isPostLoading){
1359							kapee.isPostLoading = true;
1360							$this.trigger('click');
1361						}
1362					}
1363				}
1364			});
1365		}
1366		
1367		var scrollHandler = function () {
1368			requestAnimationFrame(animationFrame);
1369		};                    
1370		$(window).scroll(scrollHandler);
1371		
1372	};
1373	
1374	// Kapee product live search
1375	kapee.productLiveSearch = function () {
1376		
1377		if ( ! kapee_options.product_ajax_search ) { return false; }
1378		
1379		$('.trending-search-results').hide();
1380		 var serviceUrl = kapee_options.ajax_url + '?action=kapee_ajax_search';
1381		$('.kapee-ajax-search').each(function(){
1382			
1383			var append 				= $(this).find('.search-results-wrapper'),
1384				container 			= $(this),
1385				search_categories 	= $(this).find('.categories-filter'),
1386				product_cat 		= '';
1387
1388			if (search_categories.length && search_categories.val() !== '') {
1389				product_cat = search_categories.val();
1390			}
1391		
1392			$(this).find('.search-field').keyup(function(){
1393				 var search_text = $(this).val();
1394				 if(search_text.length < 3){
1395					$('.trending-search-results').show();
1396				 }else{
1397					 $('.trending-search-results').hide();
1398				 }
1399			});
1400			 $(this).find('.search-field').focus(function() {
1401				 var search_text = $(this).val();
1402				 if(search_text.length < 3){
1403					$('.trending-search-results').show();
1404				 }else{
1405					 $('.trending-search-results').hide();
1406				 }
1407			});
1408			$(this).find('.search-field').focusout(function() {
1409				//$('.trending-search-results').hide();
1410			});
1411			 $(this).find('.search-field').devbridgeAutocomplete({
1412				minChars        : 3,
1413				appendTo        : append,
1414				triggerSelectOnValidInput: false,
1415				serviceUrl      : serviceUrl,
1416				type            : 'POST',
1417				params 			: { 'product_cat' : product_cat,nonce: kapee_options.nonce },
1418				onSearchStart   : function () { 
1419					container.find('.search-submit').removeClass('kapee-spinner');
1420					container.find('.search-submit').addClass('kapee-spinner');
1421					$('.trending-search-results').hide();
1422				},
1423				/* onSelect        : function (suggestion) {
1424					if (suggestion.id != -1) {
1425						window.location.href = suggestion.url;
1426					} 						
1427				}, */
1428				onSearchComplete: function () { 
1429					container.find('.search-submit').removeClass('kapee-spinner');
1430				},
1431				beforeRender: function (container) {					
1432					$(container).removeAttr('style');
1433				},
1434				formatResult: function (suggestion, currentValue) {
1435					
1436						var pattern = '(' + $.Autocomplete.utils.escapeRegExChars(currentValue) + ')';
1437						var html = '';
1438						if (suggestion.id != -1) {
1439							html += '<a href="'+suggestion.url+'" title="'+ suggestion.value +'">';
1440						} 
1441						if(suggestion.img) html += '<img class="search-image" src="'+suggestion.img+'">';
1442						html += '<div class="search-name">'+suggestion.value.replace(new RegExp(pattern, 'gi'), '<strong>$1<\/strong>')+'</div>';
1443						if(suggestion.price) html += '<span class="search-price">'+suggestion.price+'</span>';
1444						if(suggestion.rating) html += '<span class="search-rating">'+suggestion.rating+'</span>';
1445						if (suggestion.id != -1) {
1446							html += '</a>';
1447						} 
1448						return html;
1449					}
1450			});
1451
1452			  if( search_categories.length ){
1453					var searchForm = $(this).find('.search-field').devbridgeAutocomplete();
1454
1455					search_categories.on( 'change', function( e ){
1456
1457						if( search_categories.val() != '' ) {
1458							product_cat = search_categories.val();
1459							searchForm.setOptions({
1460								params : { 'product_cat' : product_cat, nonce: kapee_options.nonce }
1461								
1462							});
1463						} else{
1464							searchForm.setOptions({
1465								params : { 'product_cat' : '', nonce: kapee_options.nonce }
1466							});
1467						}
1468
1469						// update suggestions
1470						searchForm.hide();
1471						searchForm.onValueChange();
1472					});
1473				}
1474		 });
1475		 
1476		/* Hide .trending-search-results */
1477		$(document).mouseup(function (e){
1478			var container = $(".kapee-ajax-search");			
1479			if (!container.is(e.target) && container.has(e.target).length === 0){				
1480				$(".trending-search-results").hide();				
1481			}
1482		}); 
1483	};
1484	
1485	kapee.swapLoginSignupFrom = function () {
1486		/*
1487		* Swap Login Signup Form
1488		*/
1489		var userSignup 	= $('.new-signup');
1490		var userSignin	= $('.user-signin');
1491		
1492		userSignup.on('click', function(e) {
1493			e.preventDefault();	
1494			$('.customer-login').removeClass('active')
1495			$('.customer-signup').addClass('active');
1496			
1497		});
1498		userSignin.on('click', function(e) {
1499			e.preventDefault();
1500			$('.customer-signup').removeClass('active');
1501			$('.customer-login').addClass('active');
1502			
1503		});
1504	}
1505	
1506	kapee.userLoginSignupPopup = function () {
1507		/*
1508		* User Login Signup Popup
1509		*/
1510
1511		if( !kapee_options.login_register_popup || $('body').hasClass('woocommerce-account') || $('body').hasClass('woocommerce-checkout') )  return false;
1512		
1513		$('.customer-signinup').magnificPopup({
1514			type: 'inline',
1515			preloader: false,			
1516			removalDelay: 500,
1517			items: {
1518				src: '#kapee-signin-up-popup' ,					
1519			},
1520			//mainClass: 'animated bounceIn',
1521			callbacks: {
1522				 beforeOpen: function() {
1523                //$('body').css('overflow', 'hidden');
1524            },
1525				open: function() {
1526					var closeSidebar 	= $('.kapee-mask-overaly');
1527					var mobileSidebar = $('.kapee-mobile-menu');
1528					closeSidebar.removeClass('opened');
1529					mobileSidebar.removeClass('opened');
1530					$('.kapee-signin-up-popup').addClass('animate__animated animate__fadeInLeft');
1531					//$('html').css('overflow', 'hidden').css('margin-right', '0');
1532				},
1533				beforeClose: function() {
1534						var popupWrap = $( '.kapee-signin-up-popup' );
1535						popupWrap.removeClass('animate__fadeInLeft').addClass('animate__fadeOutRight');
1536						 //$('body').css('overflow', 'auto');
1537					}, 
1538				close: function() {
1539					$('.kapee-signin-up-popup').removeClass('animate__animated animate__fadeOutRight');
1540					$('.kapee-signin-up-popup').find('.signin-up-error-message').remove();
1541					//$('html').css('overflow', 'auto').css('margin-right', '0');
1542				}
1543			} 
1544		});	
1545	};
1546	
1547	kapee.miniCartWidget = function () {
1548		/*
1549		 * Mini Cart Widget Sidebar
1550		 */
1551		 
1552		if ( ! kapee_options.header_minicart_popup ) { return false; }
1553
1554		var headerCart 		= $('.header-cart');
1555		var miniCartSidebar = $('.kapee-minicart-slide');
1556        var closeSidebar 	= $('.kapee-mask-overaly');
1557		var mobileSidebar 	= $('.kapee-mobile-menu');
1558		
1559		
1560		headerCart.on('click', function(e) {
1561			
1562			if( $('body').hasClass('woocommerce-cart') || $('body').hasClass('woocommerce-checkout') ) { return; };
1563			
1564			e.preventDefault();
1565			kapee.imagelazyload();
1566			if ( ! miniCartSidebar.hasClass('opened') ) {
1567				miniCartSidebar.addClass('opened');
1568				closeSidebar.addClass('opened');				
1569			}
1570			setTimeout(function(){
1571			 kapee.imagelazyload();
1572			}, 200);
1573
1574			
1575		});
1576		
1577		kapee.$body.on('click', '.kapee-mask-overaly, .close-sidebar', function (e) {
1578			e.preventDefault();
1579			miniCartSidebar.removeClass('opened');
1580			closeSidebar.removeClass('opened');
1581			mobileSidebar.removeClass('opened');
1582		});	
1583		 
1584		kapee.$doc.keyup( function( e ) {
1585            if ( e.keyCode === 27 ) {
1586				miniCartSidebar.removeClass('opened');
1587				closeSidebar.removeClass('opened');
1588			}
1589        });
1590	};
1591	
1592	kapee.addToWishlist = function(){
1593		/*
1594		* Add wishlist loader
1595		*/
1596       kapee.$body.on("click", ".add_to_wishlist", function() {
1597			// Bootstrap tooltips hide
1598			var tooltip_hide = ('.yith-wcwl-add-to-wishlist a');			
1599			$(tooltip_hide).tooltip('hide');
1600			
1601            $(this).addClass("loading");
1602        });
1603	}
1604	
1605	kapee.wishlistCount = function(){
1606		/*
1607		* Ajax Count Wishlist Product
1608		*/
1609		
1610		var kapee_ajax_wishlist_count = function() {
1611			$.ajax({
1612				type: 'POST',
1613				url: yith_wcwl_l10n.ajax_url,
1614				data      : {
1615					action	: 'kapee_ajax_wishlist_count',
1616					nonce   : kapee_options.nonce,
1617				},
1618				beforeSend: function () {
1619				},
1620				complete  : function () {
1621				},			
1622				success   : function (data) {
1623					$('span.header-wishlist-count').html(data);
1624					kapee.tooltip();
1625				}
1626			});
1627		};
1628		$('body').on( 'added_to_wishlist removed_from_wishlist', kapee_ajax_wishlist_count );
1629	};
1630	
1631	kapee.addToCompare = function () {
1632		
1633		/*
1634		* Add to compare list
1635		*/
1636		var button = $("a.compare:not(.added)");
1637
1638        kapee.$body.on("click", "a.compare:not(.added)", function() {
1639            $(this).addClass("loading");
1640        });
1641
1642       $(window).on( 'yith_woocompare_open_popup yith_woocompare_product_added', function () {	
1643			kapee.$body.find('.compare').removeClass('loading');	   
1644			$.ajax({
1645				type: 'POST',
1646				url: kapee_options.ajax_url,
1647				data      : {
1648					action: 'kapee_ajax_compare_count',
1649					nonce	: kapee_options.ajax_nonce,
1650				},
1651				beforeSend: function () { 
1652				},
1653				complete  : function () { 
1654				},	
1655				success: function (data) { 
1656					$('span.header-compare-count').html(data);
1657					kapee.tooltip();
1658				},
1659				error: function(errorThrown){
1660					//alert(errorThrown);
1661			   } 
1662			});
1663		});
1664		
1665		window.updateCompareCount = function(count) {
1666			const $compareCount = $('span.header-compare-count');
1667			if ($compareCount.length) {
1668				$compareCount.html(count);
1669			}
1670		};
1671		
1672		$(window).on( 'yith_woocompare_product_removed', function () {	
1673			   
1674			$.ajax({
1675				type: 'POST',
1676				url: kapee_options.ajax_url,
1677				data      : {
1678					action: 'kapee_ajax_compare_count',
1679					nonce	: kapee_options.ajax_nonce,
1680				},
1681				beforeSend: function () { 
1682				},
1683				complete  : function () { 
1684				},	
1685				success: function (data) { 
1686					const count = $.trim(data);
1687					if (window.parent && typeof window.parent.updateCompareCount === 'function') {
1688						window.parent.updateCompareCount(count);
1689					}else{
1690						const $compareCount = $('span.header-compare-count');
1691						if ($compareCount.length) {
1692							$compareCount.html(count);
1693						}
1694					}
1695					kapee.tooltip();
1696				},
1697				error: function(errorThrown){
1698					//alert(errorThrown);
1699			   } 
1700			});
1701		});
1702		
1703		
1704	}
1705	
1706	kapee.removeToCompare = function () {
1707		/*
1708		* Remove to compare list
1709		*/
1710		kapee.$body.on("click", ".compare-list tr.remove a", function() {			
1711            $(this).addClass('loading');
1712        });
1713	}
1714	
1715	
1716	
1717	kapee.compareCount = function(){
1718		/*
1719		 * Ajax Count Compare Product
1720		 */
1721		
1722		$('body').on( 'yith_woocompare_open_popup woocompare_open_popup_mod', function () {				
1723			$.ajax({
1724				type: 'POST',
1725				url: kapee_options.ajax_url,
1726				data      : {
1727					action: 'kapee_ajax_compare_count',
1728					nonce	: kapee_options.ajax_nonce,
1729				},
1730				beforeSend: function () { 
1731				},
1732				complete  : function () { 
1733				},	
1734				success: function (data) { 
1735					$('span.header-compare-count').html(data);
1736					kapee.tooltip();
1737				},
1738				error: function(errorThrown){
1739					//alert(errorThrown);
1740			   } 
1741			});
1742		});
1743
1744		$(window).on('yith_woocompare_product_removed', function () {
1745			$('body').trigger('woocompare_open_popup_mod');
1746		});
1747		
1748		//Remove product in compare product widget
1749		$('.yith-woocompare-widget').on('click', 'li a.remove, a.clear-all', function (e) {
1750
1751			e.preventDefault();
1752			var product_id = $(this).data('product_id');
1753			
1754			$.ajax({
1755				type: 'POST',
1756				url: kapee_options.ajax_url,
1757				data      : {
1758					action	: 'kapee_ajax_compare_count',
1759					nonce	: kapee_options.ajax_nonce,
1760					id		: product_id
1761				},
1762				beforeSend: function () { 
1763				},
1764				complete  : function () { 
1765				},	
1766				success: function (data) { 
1767					$('label.compare-count').html(data);
1768					kapee.tooltip();
1769				},
1770				error: function(errorThrown){
1771					//alert(errorThrown);
1772			   } 
1773			});
1774
1775		});
1776	};
1777	
1778	kapee.ProductLoopQuantityField = function () {
1779		/*
1780		* Product Quantity Field
1781		*/		
1782		
1783		$(".woocommerce .product-buttons").on("change input", ".quantity .qty", function () {
1784		  var add_to_cart_button = $(this).parents(".product").find(".add_to_cart_button");
1785		  add_to_cart_button.attr("data-quantity", $(this).val());
1786		});
1787		$(".woocommerce .product-buttons").on("keypress", ".quantity .qty", function (e) {
1788		  if ((e.which || e.keyCode) === 13) {
1789			$(this).parents(".product").find(".add_to_cart_button").trigger("click");
1790		  }
1791		});
1792	}
1793	
1794	kapee.addToCart = function () {
1795		/*
1796		 *  Adding to cart
1797		 */
1798		 $('body').on('added_to_cart', function(event, fragments, cart_hash) {
1799			if( $('.header-cart').length > 0 ) {
1800				if (kapee_options.product_open_cart_mini == '1') {
1801					$('.header-cart').trigger('click');
1802				}
1803			}
1804		 });
1805		 
1806		 $( document.body ).on( 'updated_cart_totals', function(){
1807			setTimeout(function(){
1808			 kapee.imagelazyload();
1809			}, 200);
1810		});
1811	};
1812	
1813	kapee.addToCartAjax = function () {
1814		/*
1815		 *  Adding to cart Ajax
1816		 */
1817		if ( ! kapee_options.product_add_to_cart_ajax ) { return; }
1818		
1819		$('.single_add_to_cart_button').addClass('single_add_to_cart_ajax_button');
1820		 kapee.$body.find('form.cart').on('click', '.single_add_to_cart_button', function (e) {
1821			 
1822			var $productWrapper = $(this).parents('.single-product-page');
1823            if ($productWrapper.hasClass('product-type-external')) return;          
1824
1825            var $form = $(this).closest('form.cart'),
1826                $singleBtn =  $(this),
1827				product_id = $form.find('input[name=add-to-cart]').val() || $singleBtn.val();
1828			if ($singleBtn.hasClass('disabled')) {
1829				return;
1830			}
1831            if ($singleBtn.hasClass('quick-buy-proceed')) {
1832				return;
1833			}
1834			if ($form.length > 0) {
1835                e.preventDefault();
1836            } else {
1837                return;
1838            }
1839			var data = {
1840				action			: 'kapee_ajax_add_to_cart',
1841				'add-to-cart'	: product_id,
1842				nonce   		: kapee_options.nonce,
1843			};
1844
1845			$form.serializeArray().forEach(function (element) {
1846				data[element.name] = element.value;
1847			});
1848			if ($singleBtn.hasClass('loading')) {
1849				return;
1850			}
1851			$singleBtn.addClass('loading');
1852			
1853			$(document.body).trigger('adding_to_cart', [$singleBtn, data]);
1854			$.ajax({
1855				type: 'post',
1856				url: kapee_options.ajax_url,
1857				data: data,
1858				beforeSend: function (response) {
1859					$singleBtn.removeClass('added').removeClass('not-added');
1860				},
1861				success: function (response) {
1862					if (response.error & response.product_url) {
1863					  window.location = response.product_url;
1864					  return;
1865					} else {
1866						if (typeof wc_add_to_cart_params !== 'undefined') {
1867							if (wc_add_to_cart_params.cart_redirect_after_add === 'yes') {
1868								window.location = wc_add_to_cart_params.cart_url;
1869								return;
1870							}
1871						}					
1872						
1873						// Show notices
1874                        if( response.notices.indexOf( 'error' ) > 0 ) {
1875                            $('.woocommerce-notices-wrapper').empty().append(response.notices);
1876							$singleBtn.addClass('not-added').removeClass('loading');
1877                        } else {
1878                            if (kapee_options.product_open_cart_mini == '1') {
1879								$('.header-cart').trigger('click');
1880							}
1881							$singleBtn.addClass('added').removeClass('loading');
1882                            $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $singleBtn]);
1883                        }
1884						
1885					}
1886				},
1887			});
1888			
1889		});
1890	};
1891	
1892	kapee.stickyAddToCart = function(){
1893		/*
1894		* Sticky Add To Cart Bottom Button
1895		*/	
1896		
1897		if ( ! $('body').hasClass( 'single-product' ) || $('.kapee-sticky-add-to-cart').length == 0 || $(window).width() < 992 || $('.entry-summary form .single_add_to_cart_button').length == 0 ) {
1898			return;
1899		}
1900		
1901		$('body').on( 'click', '.kapee-sticky-add-to-cart .button', function (event) {
1902			event.preventDefault();			
1903			if( $(this).hasClass('variable') || $(this).hasClass('grouped') ){				
1904				$('html, body').animate({
1905					scrollTop: $(".variations").offset().top - 70
1906				}, 1000);
1907			}else{
1908				$(this).addClass('loading');
1909				$( '.entry-summary .single_add_to_cart_button' ).click();
1910				event.stopPropagation();				
1911			}
1912		});
1913		
1914		$(document.body).on( 'added_to_cart', function () {			
1915			$('.kapee-sticky-add-to-cart .button').removeClass('loading');
1916		});
1917		
1918		var cartButtonOffset = $('.entry-summary form .single_add_to_cart_button').offset().top;
1919		
1920		$(window).scroll(function(e) {			
1921			var documentHeight = $(document).height();
1922			var windowHeight = $(this).height();
1923			var scrollTop = $(this).scrollTop();
1924			var bottomscroll = parseInt( windowHeight + scrollTop ) + 100;
1925			
1926			if ( scrollTop > cartButtonOffset ) {
1927				$('.kapee-sticky-add-to-cart').slideDown();
1928				$('.kapee-back-to-top').addClass('sticky-add-cart');
1929			} else if ( scrollTop < cartButtonOffset) {
1930				$('.kapee-sticky-add-to-cart').slideUp(); //Hide on bottom
1931				$('.kapee-back-to-top').removeClass('sticky-add-cart');
1932			}
1933		});
1934		/* $(window).scroll(function(e) {			
1935			var documentHeight = $(document).height();
1936			var windowHeight = $(this).height();
1937			var scrollTop = $(this).scrollTop();
1938			var bottomscroll = parseInt( windowHeight + scrollTop ) + 100;
1939			
1940			if ( scrollTop > cartButtonOffset && bottomscroll < documentHeight && bottomscroll !== documentHeight ) {
1941				$('.kapee-sticky-add-to-cart').slideDown();
1942				$('.kapee-back-to-top').addClass('sticky-add-cart');
1943			} else if ( scrollTop < cartButtonOffset || bottomscroll > documentHeight || bottomscroll === documentHeight ) {
1944				$('.kapee-sticky-add-to-cart').slideUp(); //Hide on bottom
1945				$('.kapee-back-to-top').removeClass('sticky-add-cart');
1946			}
1947		}); */
1948		
1949	};
1950	
1951	kapee.productQuickView = function () {
1952		/*
1953		* Product Quickview
1954		*/
1955		kapee.$doc.on("click", ".quickview-btn", function(e) {
1956            e.preventDefault();
1957			var $btn = $(this),pid;
1958			if($btn.hasClass('loading')) return;
1959			$btn.addClass('loading');
1960			var pid           = $btn.attr( 'data-id' );
1961			$.ajax( {
1962				url    : kapee_options.ajax_url,
1963				data   : {
1964					action	: 'kapee_product_quick_view',
1965					pid   	: pid,
1966					nonce   : kapee_options.nonce,
1967				},
1968				timeout: 10000,
1969				success: function( response ) {
1970					$.magnificPopup.open({
1971						alignTop: true,
1972						removalDelay: 500,
1973						overflowY: 'scroll',
1974						items: {
1975						  src: '<div class="animate__animated animate__fadeInLeft kapee-quick-view woocommerce">' + response + '</div>', 
1976						  type: 'inline'
1977						},
1978						callbacks: {
1979							open: function () {
1980														
1981							},
1982							close: function () {
1983								kapee.singlePageSwatch();
1984							},
1985							beforeClose: function() {
1986								var quickViewWrap = $( '.kapee-quick-view' );
1987								quickViewWrap.addClass('animate__fadeOutRight');
1988							},
1989						},
1990					});
1991					
1992					if( $('.woocommerce-product-gallery').find( '.single-product-gallery' ).length > 0 ) {
1993						$( '.single-product-gallery' ).not( '.slick-initialized' ).slick({
1994							slidesToShow	: 1,
1995							slidesToScroll	: 1,
1996							rtl				: ( kapee.isCheckRTL() ) ? true : false,
1997						});
1998					}
1999					$('.woocommerce-product-gallery__image a').on('click', function(e){
2000						e.preventDefault();
2001					});
2002					setTimeout(function() {
2003						var form_variation = $( '.product-quick-view' ).find( '.variations_form' );
2004						if ( form_variation.length > 0 ) {
2005							form_variation.trigger( 'check_variations' );
2006							form_variation.trigger( 'reset_image' );						
2007							form_variation.wc_variation_form();
2008							form_variation.find( 'select' ).change();
2009							kapee.singlePageSwatch();							
2010						}
2011					}, 1000);
2012					
2013					
2014					$btn.removeClass( 'loading' );
2015					
2016					kapee.addToCartAjax();
2017					kapee.productQuickShop();
2018					kapee.tooltip();
2019					kapee.imagelazyload();
2020					
2021				},
2022				error  : function( error ) {
2023					console.log( error );
2024					$btn.removeClass( 'loading' );
2025				},
2026
2027			} );
2028        });
2029	}
2030	
2031	kapee.productShowFilter = function () {
2032		$('.product-show .show-number').on('change', function () {
2033			 if ( !kapee.$body.hasClass('kapee-catalog-ajax-filter') ) {
2034				$( this ).closest( 'form' ).submit();
2035			}
2036      });
2037	}
2038	
2039	// Get price js slider
2040	kapee.priceSlider = function () {
2041		// woocommerce_price_slider_params is required to continue, ensure the object exists
2042		if (typeof woocommerce_price_slider_params === 'undefined') {
2043			return false;
2044		}
2045		
2046		if (!$('#main-content').find('.widget_price_filter').length) {
2047			return false;
2048		}
2049		
2050		// Get markup ready for slider
2051		$('input#min_price, input#max_price').hide();
2052		$('.price_slider, .price_label').show();
2053
2054		// Price slider uses jquery ui
2055		var min_price = $('.price_slider_amount #min_price').data('min'),
2056			max_price = $('.price_slider_amount #max_price').data('max'),
2057			current_min_price = parseInt(min_price, 10),
2058			current_max_price = parseInt(max_price, 10);
2059
2060		if ($('.price_slider_amount #min_price').val() != '') {
2061			current_min_price = parseInt($('.price_slider_amount #min_price').val(), 10);
2062		}
2063		if ($('.price_slider_amount #max_price').val() != '') {
2064			current_max_price = parseInt($('.price_slider_amount #max_price').val(), 10);
2065		}
2066
2067		$(document.body).on('price_slider_create price_slider_slide', function (event, min, max) {
2068			if (woocommerce_price_slider_params.currency_pos === 'left') {
2069
2070				$('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + min);
2071				$('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + max);
2072
2073			} else if (woocommerce_price_slider_params.currency_pos === 'left_space') {
2074
2075				$('.price_slider_amount span.from').html(woocommerce_price_slider_params.currency_symbol + ' ' + min);
2076				$('.price_slider_amount span.to').html(woocommerce_price_slider_params.currency_symbol + ' ' + max);
2077
2078			} else if (woocommerce_price_slider_params.currency_pos === 'right') {
2079
2080				$('.price_slider_amount span.from').html(min + woocommerce_price_slider_params.currency_symbol);
2081				$('.price_slider_amount span.to').html(max + woocommerce_price_slider_params.currency_symbol);
2082
2083			} else if (woocommerce_price_slider_params.currency_pos === 'right_space') {
2084
2085				$('.price_slider_amount span.from').html(min + ' ' + woocommerce_price_slider_params.currency_symbol);
2086				$('.price_slider_amount span.to').html(max + ' ' + woocommerce_price_slider_params.currency_symbol);
2087
2088			}
2089
2090			$(document.body).trigger('price_slider_updated', [min, max]);
2091		});
2092		if ( typeof $.fn.slider !== 'undefined' ) {
2093			$('.price_slider').slider({
2094				range  : true,
2095				animate: true,
2096				min    : min_price,
2097				max    : max_price,
2098				values : [current_min_price, current_max_price],
2099				create : function () {
2100
2101					$('.price_slider_amount #min_price').val(current_min_price);
2102					$('.price_slider_amount #max_price').val(current_max_price);
2103
2104					$(document.body).trigger('price_slider_create', [current_min_price, current_max_price]);
2105				},
2106				slide  : function (event, ui) {
2107
2108					$('input#min_price').val(ui.values[0]);
2109					$('input#max_price').val(ui.values[1]);
2110
2111					$(document.body).trigger('price_slider_slide', [ui.values[0], ui.values[1]]);
2112				},
2113				change : function (event, ui) {
2114
2115					$(document.body).trigger('price_slider_change', [ui.values[0], ui.values[1]]);
2116				}
2117			});
2118		}
2119	};
2120	
2121	kapee.productShowHideFilters = function () {
2122		$('.archive.woocommerce').on('click','.kapee-product-filter-btn',function(e) {
2123			var $this = $(this),
2124			filter_content = $('#kapee-filter-widgets');
2125			$this.toggleClass("active");
2126			filter_content.toggleClass('active');
2127			filter_content.slideToggle('slow');			
2128      });
2129	}
2130	
2131	kapee.productFilterAjax = function () {
2132		if (!kapee.$body.hasClass('kapee-catalog-ajax-filter')) {
2133			return;
2134		}
2135		/* Price range filter*/
2136		$(document.body).on('price_slider_change', function (event, ui) {
2137			var form = $('.price_slider').closest('form').get(0),
2138			$form = $(form),
2139			url = $form.attr('action') + '?' + $form.serialize();
2140			$(document.body).trigger('kapee_shop_filter_ajax', url, $(this));
2141		});
2142		kapee.$body.on('click', '.widget_product_categories ul a, .widget_rating_filter ul a, .widget_layered_nav_filters ul a, .widget_product_tag_cloud a', function (e) {
2143            e.preventDefault();
2144            var url = $(this).attr('href');
2145            $(document.body).trigger('kapee_shop_filter_ajax', url, $(this));
2146        });
2147		kapee.$body.on('click','.products-view a',function(e) {			
2148			e.preventDefault();
2149			var $this = $(this),
2150			url = $this.attr('href');			
2151			$this.siblings().removeClass("active");
2152			$this.addClass('active');
2153			$(document.body).trigger('kapee_shop_filter_ajax', url, $this);
2154		});
2155		
2156		/* Shop paginataion filter*/
2157		$('.archive.woocommerce').on('change','.product-show .show-number',function(e) {			
2158			e.stopPropagation();
2159			var $this = $(this);
2160			var url = window.location.href.replace(/&per_page(=[^&]*)?|^per_page(=[^&]*)?&?/g, '').replace(/\?per_page(=[^&]*)?|^per_page(=[^&]*)?&?/g, '?').replace(/\?$/g, '');
2161
2162			if (url.indexOf('?') !== -1) {
2163				url = url + ('&per_page=' + $this.val());
2164			} else {
2165				url = url + ('?per_page=' + $this.val());
2166			}			
2167			$(document.body).trigger('kapee_shop_filter_ajax', url, $this);
2168		});
2169		
2170		/* Shop paginataion filter*/
2171		$( document ).on( 'click', '.kapee-pagination .page-numbers:not(.current)', function(e) {
2172			e.preventDefault();
2173			var $this = $(this);
2174			var url = $this.attr('href');
2175			
2176			$(document.body).trigger('kapee_shop_filter_ajax', url, $this);
2177		});
2178		
2179		$('.archive.woocommerce').find('.woocommerce-ordering').off('change');
2180		$('.archive.woocommerce').on('change','.woocommerce-ordering',function(e) {
2181			var $this = $(this);
2182			var $select = $(e.currentTarget).find('.orderby');
2183			var url = window.location.href.replace(/&orderby(=[^&]*)?|^orderby(=[^&]*)?&?/g, '').replace(/\?orderby(=[^&]*)?|^orderby(=[^&]*)?&?/g, '?').replace(/\?$/g, '');
2184
2185			if (url.indexOf('?') !== -1) {
2186				url = url + ('&orderby=' + $select.val());
2187			} else {
2188				url = url + ('?orderby=' + $select.val());
2189			}
2190			$(document.body).trigger('kapee_shop_filter_ajax', url, $this);
2191		});
2192		
2193				
2194		/* Sorting filter*/
2195		$('.archive.woocommerce').on('click','.kapee_widget_product_sorting li',function(e) {
2196			e.preventDefault();
2197			var $this = $(this);
2198			var element = $this.find('a');
2199			var url = $this.find('a').attr('href');
2200			$this.siblings().removeClass("chosen");
2201			if($this.hasClass('chosen')){
2202                $this.removeClass('chosen');
2203            }else{
2204                $this.addClass('chosen');
2205            };
2206			
2207			$(document.body).trigger('kapee_shop_filter_ajax', url, element);
2208			
2209		});
2210		/* Clear filter*/
2211		$('.archive.woocommerce').on('click','.widget_layered_nav_filters a, .kapee-clear-filters-wrapp a',function(e) {
2212			e.preventDefault();
2213			var $this = $(this);
2214			
2215			var url = $this.attr('href');
2216			
2217			$(document.body).trigger('kapee_shop_filter_ajax', url, $this);
2218			
2219		});
2220		/* Attribute/Rating filter*/
2221		$('.archive.woocommerce').on('click','.widget_layered_nav li,.widget_rating_filter li,.widget_layered_nav_filters li',function(e) {
2222			e.preventDefault();
2223			var $this = $(this);
2224			var element = $this.find('a');
2225			var url = $this.find('a').attr('href');
2226			
2227			if($this.hasClass('chosen')){
2228                $this.removeClass('chosen');
2229            }else{
2230                $this.addClass('chosen');
2231            };
2232			
2233			$(document.body).trigger('kapee_shop_filter_ajax', url, element);
2234			
2235		});
2236		
2237		$(document.body).on('kapee_shop_filter_ajax', function (e, url, element) {
2238
2239			var $page_title = $('#page-title'),
2240				$product_container = $('#main-content .products-wrap'),
2241			    $main_content = $('#main-content');
2242				
2243			$('#kapee-filter-widgets').slideUp(200);
2244			if ($product_container.length > 0) {
2245				var position = $('.products').offset().top - 200;
2246				$('html, body').stop().animate({
2247						scrollTop: position
2248					},
2249					1200
2250				);
2251			}
2252			
2253			if ('?' == url.slice(-1)) {
2254				url = url.slice(0, -1);
2255			}
2256
2257			url = url.replace(/%2C/g, ',');
2258
2259			history.pushState(null, null, url);
2260
2261			$(document.body).trigger('kapee_ajax_filter_before_send_request', [url, element]);
2262
2263			if (kapee.ajaxXHR) {
2264				kapee.ajaxXHR.abort();
2265			}
2266	
2267			kapee.ajaxXHR = $.get(url, function (res) {
2268				//$main_content.replaceWith($(res).find('#main-content'));
2269               $page_title.replaceWith($(res).find('#page-title').clone());
2270				var content_res = $(res).find('#main-content').html(),
2271				page_title_res = $(res).find('#page-title').html();
2272				$main_content.html('').append(content_res);
2273				//$page_title.html('').append(page_title_res);
2274				$(document.body).trigger('kapee_ajax_filter_request_end', [res, url]);
2275			}, 'html');
2276		});
2277		
2278		$(document.body).on('kapee_ajax_filter_before_send_request', function () {
2279			
2280			var $product_container = $('#main-content .products-wrap');
2281			if( kapee_options.skeleton_effect ){
2282				$product_container.parent().addClass('kapee-skeleton');
2283			}else{
2284					$product_container.addClass('products_overlay');
2285				$product_container.append('<div class="kapee_product_loading loading"></div>');
2286			}
2287			$('#secondary').removeClass('opened');
2288			$('.kapee-mask-overaly').removeClass('opened');
2289			
2290		});
2291		
2292		$(document.body).on('kapee_ajax_filter_request_end', function () {
2293			kapee.priceSlider();
2294			kapee.kapeeOwlCarousel();
2295			kapee.initAjaxLoad();
2296			kapee.tooltip();
2297			kapee.imagelazyload();
2298			kapee.widgetToggle();
2299			kapee.widgetMenuToggle();
2300			kapee.widgetMaxLimitItem();
2301			kapee.canvasSidebar();
2302			kapee.stickySidebar();
2303			kapee.swatchInLoop();
2304			kapee.productQuickView();
2305			kapee.ProductLoopQuantityField();
2306			kapee.addToCompare();
2307			$(document).trigger('yith_wcwl_reload_fragments'); /* Fixed wishlist icon afer ajax*/
2308			$('.kapee-mask-overaly').removeClass('opened');
2309		});
2310	}
2311	
2312	kapee.productHover = function (){
2313		/*
2314		* productHover
2315		*/
2316		$('.product-style-4.grid-view .product').mouseenter(function(){
2317			var product_elemnt = $(this);
2318			var  product_info_elemnt = product_elemnt.find('.product-info');
2319			var variations_elemnt = product_elemnt.find('.product-variations');
2320			var variations_height = variations_elemnt.height();			
2321			if(variations_height && variations_height > 0){				
2322				product_info_elemnt.css('transform', 'translate3d(0px, -'+variations_height+'px, 0px)');
2323			} 
2324		}).mouseleave(function(){
2325			var product_elemnt = $(this);
2326			var  product_info_elemnt = product_elemnt.find('.product-info');
2327			if(product_info_elemnt){
2328				product_info_elemnt.css('transform', 'translate3d(0px, 0px, 0px)');
2329			}
2330			
2331		});
2332	};
2333	
2334	kapee.productSwatch = function(){
2335		this.singlePageSwatch();
2336		this.swatchInLoop();
2337	}
2338	kapee.singlePageSwatch = function () {
2339		
2340		var variationForm;
2341		if( kapee.$doc.find( '.kapee-quick-view form.kapee-swatches-wrap.variations_form' ).length && !kapee.$doc.find( '.kapee-quick-view' ).hasClass( 'animate__fadeOutRight' ) ){
2342			variationForm 	= kapee.$doc.find( '.kapee-quick-view form.kapee-swatches-wrap.variations_form' );
2343		}else{
2344			variationForm 	= kapee.$doc.find( 'form.kapee-swatches-wrap.variations_form' );
2345		}
2346		var self 			= this,					
2347			$term 			= variationForm.find( '.swatch-term' ),
2348			$activeTerm 	= variationForm.find( '.swatch-term:not(.swatch-disabled)' );
2349		self.$swatchForm	= variationForm;
2350		
2351		$activeTerm.off( 'click' ).on( 'click', function () {
2352
2353			var $this 		= $( this ),
2354				term 		= $this.attr( 'data-term' ),
2355				attr 		= $this.parent().attr( 'data-attribute' ),
2356				$selectbox 	= self.$swatchForm.find( 'select#' + attr );
2357
2358			if ( $this.hasClass( 'swatch-disabled' ) ) {
2359				return false;
2360			}
2361
2362			$selectbox.val( term ).trigger( 'change' );
2363			$this.closest('.kapee-swatches').find( '.swatch-selected' ).removeClass( 'swatch-selected' );
2364			$this.addClass( 'swatch-selected' );
2365		} );
2366
2367		self.$swatchForm.on( 'woocommerce_update_variation_values',
2368			function () {
2369				
2370				self.$swatchForm.find( 'select' ).each( function () {
2371					var $this 		= $( this );
2372					var $swatch 	= $this.parent().parent().find( '.kapee-swatches' );
2373					
2374					$swatch.find( '.swatch-term' ).removeClass( 'swatch-enabled' ).addClass( 'swatch-disabled' );
2375
2376					$this.find( 'option.enabled' ).each( function () {
2377						var val 	= $( this ).val();
2378						$swatch.find(
2379							'.swatch-term[data-term="' + val + '"]' ).removeClass( 'swatch-disabled' ).addClass( 'swatch-enabled' );
2380					} );
2381				} );
2382			} );
2383
2384		self.$swatchForm.on( 'reset_data', function () {
2385			
2386		// load default value
2387		$term.each( function () {
2388			var $this = $( this ),
2389				term = $this.attr( 'data-term' ),
2390				attr = $this.parent().attr( 'data-attribute' ),
2391				$selectbox = self.$swatchForm.find( 'select#' + attr ),
2392				val = $selectbox.val();				
2393			if ( val != '' && term == val ) {				
2394				$( this ).addClass( 'swatch-selected' );
2395			}else{
2396				$( this ).removeClass( 'swatch-selected' );
2397			}
2398		} );
2399		
2400		} );
2401
2402	}
2403	kapee.swatchInLoop = function(){
2404		var self 			= this,
2405		swatchesInLoop 		= kapee.$doc.find( 'div.kapee-swatches-wrap' );
2406		self.$swatches 		= swatchesInLoop;
2407		self.$swatches.each( function () {
2408			var $swatches 	= $( this ),
2409			$term 			= $swatches.find(
2410				'.swatch-term:not(.swatch-disabled)' ),
2411			$resetBtn 		= $swatches.find(
2412				'.reset_variations--loop' ),
2413			$product 		= $swatches.closest('.product'),
2414			variationData 	= $.parseJSON(
2415			$swatches.attr( 'data-product_variations' ) );
2416			
2417			if ( $swatches.find( '.kapee-swatches' ).length == 0 ) {
2418				$swatches.addClass( 'swatch-empty' );
2419			}
2420			
2421			$term.unbind( 'click' ).on( 'click', function () {
2422
2423				var $this = $( this );
2424
2425				if ( $this.hasClass( 'swatch-disabled' ) ) {
2426					return false;
2427				}
2428
2429				var term = $this.attr( 'data-term' );				
2430				
2431				$product.find( '.swatch-term' ).removeClass( 'swatch-disabled swatch-enabled' );
2432				$this.parent().find( '.swatch-term.swatch-selected' ).removeClass( 'swatch-selected' );
2433
2434				if ( $this.hasClass( 'swatch-selected' ) ) {
2435					$this.parent().removeClass( 'swatch-activated' );
2436					$product.removeClass( 'swatch-product-swatched' );
2437
2438					if ( !$product.find( '.swatch-selected' ).length ) {
2439						$resetBtn.trigger( 'click' );
2440					}
2441				} else {
2442					$this.parent().addClass( 'swatch-activated' );
2443					$this.addClass( 'swatch-selected' );
2444
2445					$product.addClass( 'swatch-product-swatched' );
2446					//$resetBtn.show();
2447				}
2448				
2449				var attributes 			= self.getChosenAttributes(
2450					$swatches ),
2451					currentAttributes 	= attributes.data;
2452				if ( attributes.count === attributes.chosenCount ) {
2453					self.updateAttributes( $swatches, variationData );
2454
2455					var matching_variations = self.findMatchingVariations(
2456						variationData, currentAttributes ),
2457						variation = matching_variations.shift();
2458
2459					if ( variation ) {
2460						// Found variation
2461						self.foundVariation( $swatches, variation );
2462					} else {
2463						
2464						$resetBtn.trigger( 'click' );
2465					}
2466				} else {
2467					
2468					self.updateAttributes( $swatches, variationData );
2469				} 
2470
2471			} );
2472			
2473			$resetBtn.unbind( 'click' ).on( 'click', function () {
2474
2475				$product.removeClass( 'swatch-product-swatched' );
2476
2477				$swatches.removeAttr( 'data-variation_id' );
2478				$swatches.find( '.swatch-swatch' ).removeClass( 'swatch-activated' );
2479				$swatches.find( '.swatch-term' ).removeClass(
2480					'swatch-enabled swatch-disabled swatch-selected' );
2481				
2482				// reset image
2483				self.variationsImageUpdate( false, $product );
2484
2485				$( this ).hide();
2486
2487				return false;
2488			} );					
2489		});
2490	};
2491	
2492	kapee.getChosenAttributes = function ( $swatches ) {
2493
2494		var data = {},
2495			count = 0,
2496			chosen = 0,
2497			$swatch = $swatches.find( '.kapee-swatches' );
2498
2499		$swatch.each( function () {
2500				var attribute_name = 'attribute_' +
2501						$( this ).attr( 'data-attribute' ),
2502					value = $( this ).find( '.swatch-term.swatch-selected' ).attr( 'data-term' ) || '';
2503
2504				if ( value.length > 0 ) {
2505					chosen++;
2506				}
2507
2508				count++;
2509				data[ attribute_name ] = value;
2510			//}
2511		} );
2512
2513		return {
2514			'count': count,
2515			'chosenCount': chosen,
2516			'data': data,
2517		};
2518	}
2519	
2520	kapee.updateAttributes = function ( $swatches, variationData ) {
2521
2522		var self = this,
2523			attributes = self.getChosenAttributes( $swatches ),
2524			currentAttributes = attributes.data,
2525			available_options_count = 0,
2526			$swatch = $swatches.find( '.kapee-swatches' );
2527
2528		$swatch.each( function ( idx, el ) {
2529
2530			var current_attr_sw = $( el ),
2531				current_attr_name = 'attribute_' +
2532					current_attr_sw.attr(
2533						'data-attribute' ),
2534				selected_attr_val = current_attr_sw.find(
2535					'.swatch-term.swatch-selected' ).attr( 'data-term' ),
2536				selected_attr_val_valid = true,
2537				checkAttributes = $.extend( true, {},
2538					currentAttributes );
2539			
2540			checkAttributes[ current_attr_name ] = '';
2541			
2542			var variations = self.findMatchingVariations(
2543				variationData, checkAttributes );
2544			
2545			// Loop through variations.
2546			for (var num in variations) {
2547				if ( typeof variations[ num ] !== 'undefined' ) {
2548					var variationAttributes = variations[ num ].attributes;
2549
2550					for (var attr_name in variationAttributes) {
2551						if ( variationAttributes.hasOwnProperty(
2552								attr_name ) ) {
2553							var attr_val = variationAttributes[ attr_name ],
2554								variation_active = '';
2555							
2556							if ( attr_name === current_attr_name ) {
2557								if ( variations[ num ].variation_is_active ) {
2558									variation_active = 'enabled';
2559								}
2560								
2561								if ( attr_val ) {
2562									// available
2563									current_attr_sw.find(
2564										'.swatch-term[data-term="' + attr_val + '"]' ).addClass( 'swatch-' + variation_active );
2565								}
2566								else {
2567									// apply for all swatches
2568									current_attr_sw.find( '.swatch-term' ).addClass( 'swatch-' + variation_active );
2569								}
2570							}
2571						}
2572					}
2573				}
2574			}
2575
2576			available_options_count = current_attr_sw.find(
2577				'.swatch-term.swatch-enabled' ).length;
2578
2579			if ( selected_attr_val && (
2580					available_options_count === 0 || current_attr_sw.find(
2581						'.swatch-term.swatch-enabled[data-term="' +
2582						self.addSlashes( selected_attr_val ) + '"]' ).length ===
2583					0
2584				) ) {
2585				selected_attr_val_valid = false;
2586			}
2587
2588			// Disable terms not available
2589			current_attr_sw.find( '.swatch-term:not(.swatch-enabled)' ).addClass( 'swatch-disabled' );
2590
2591			// Choose selected value.
2592			if ( selected_attr_val ) {
2593				// If the previously selected value is no longer available,
2594				// fall back to the placeholder (it's going to be there).
2595				if ( !selected_attr_val_valid ) {
2596					current_attr_sw.find( '.swatch-term.swatch-selected' ).removeClass( 'swatch-selected' );
2597				}
2598			}
2599			else {
2600				current_attr_sw.find( '.swatch-term.swatch-selected' ).removeClass( 'swatch-selected' );
2601			}
2602		} );
2603	}
2604	
2605	kapee.addSlashes = function ( string ) {
2606		string = string.replace( /'/g, '\\\'' );
2607		string = string.replace( /"/g, '\\\"' );
2608		return string;
2609	}
2610
2611	kapee.findMatchingVariations = function ( variationData, settings ) {
2612		var matching = [];
2613		for (var i = 0; i < variationData.length; i++) {
2614			var variation = variationData[ i ];
2615
2616			if ( this.isMatch( variation.attributes, settings ) ) {
2617				matching.push( variation );
2618			}
2619		}
2620		return matching;
2621	}
2622
2623	kapee.isMatch = function ( variation_attributes, attributes ) {
2624		var match = true;
2625		for (var attr_name in variation_attributes) {
2626			if ( variation_attributes.hasOwnProperty( attr_name ) ) {
2627				var val1 = variation_attributes[ attr_name ];
2628				var val2 = attributes[ attr_name ];
2629				if ( val1 !== undefined && val2 !== undefined &&
2630					val1.length !== 0 && val2.length !== 0 &&
2631					val1 !== val2 ) {
2632					match = false;
2633				}
2634			}
2635		}
2636		return match;
2637	}
2638
2639	kapee.foundVariation = function ( $swatches, variation ) {
2640
2641		var self = this,
2642		$product = $swatches.closest( '.product' );
2643		// add variation id
2644		$swatches.attr( 'data-variation_id', variation.variation_id );
2645
2646		// update image
2647		self.variationsImageUpdate( variation, $product );
2648		
2649	}
2650
2651	/**
2652	 * Stores a default attribute for an element so it can be reset later
2653	 */
2654	kapee.setVariationAttr = function ( $el, attr, value ) {
2655		if ( undefined === $el.attr( 'data-o_' + attr ) ) {
2656			$el.attr( 'data-o_' + attr, (
2657				!$el.attr( attr )
2658			) ? '' : $el.attr( attr ) );
2659		}
2660		if ( false === value ) {
2661			$el.removeAttr( attr );
2662		}
2663		else {
2664			$el.attr( attr, value );
2665		}
2666	}
2667
2668	/**
2669	 * Reset a default attribute for an element so it can be reset later
2670	 */
2671	kapee.resetVariationAttr = function ( $el, attr ) {
2672		if ( undefined !== $el.attr( 'data-o_' + attr ) ) {
2673			$el.attr( attr, $el.attr( 'data-o_' + attr ) );
2674		}
2675	}
2676
2677	kapee.variationsImageUpdate = function ( variation, $product ) { 
2678
2679		var self = this,
2680			$product_img = $product.find( 'img.front-image' );
2681		
2682		if ( variation && variation.image_src && variation.image.src && variation.image_src.length > 1 ) {			
2683			self.setVariationAttr( $product_img, 'src',
2684				variation.image_src[ 0 ] );
2685			self.setVariationAttr( $product_img, 'srcset',
2686				variation.image_srcset );
2687			self.setVariationAttr( $product_img, 'sizes',
2688				variation.image_sizes );
2689		} else {
2690			self.resetVariationAttr( $product_img, 'src' );
2691			self.resetVariationAttr( $product_img, 'srcset' );
2692			self.resetVariationAttr( $product_img, 'sizes' );
2693		}
2694	}
2695	
2696	kapee.variationsImageChange = function(){
2697		/**
2698		 * Sets product images for the chosen variation
2699		 */
2700		$.fn.wc_variations_image_update = function( variation ) {
2701			var $form             = this,
2702				$product          = $form.closest( '.product' ),
2703				$product_gallery  = $product.find( '.images' ),
2704				$gallery_img      = $product.find( '.single-product-thumbnails .slick-slide[data-slick-index="0"] img' ),
2705				$product_img_wrap = $product_gallery.find( '.woocommerce-product-gallery__image, .woocommerce-product-gallery__image--placeholder' ).eq( 0 ),
2706				$product_img      = $product_img_wrap.find( '.wp-post-image' ),
2707				$product_link     = $product_img_wrap.find( 'a' ).eq( 0 );
2708
2709			if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) {
2710				$product_img.wc_set_variation_attr( 'src', variation.image.src );
2711				$product_img.wc_set_variation_attr( 'height', variation.image.src_h );
2712				$product_img.wc_set_variation_attr( 'width', variation.image.src_w );
2713				$product_img.wc_set_variation_attr( 'srcset', variation.image.srcset );
2714				$product_img.wc_set_variation_attr( 'sizes', variation.image.sizes );
2715				$product_img.wc_set_variation_attr( 'title', variation.image.title );
2716				$product_img.wc_set_variation_attr( 'alt', variation.image.alt );
2717				$product_img.wc_set_variation_attr( 'data-src', variation.image.full_src );
2718				$product_img.wc_set_variation_attr( 'data-large_image', variation.image.full_src );
2719				$product_img.wc_set_variation_attr( 'data-large_image_width', variation.image.full_src_w );
2720				$product_img.wc_set_variation_attr( 'data-large_image_height', variation.image.full_src_h );
2721				$product_img_wrap.wc_set_variation_attr( 'data-thumb', variation.image.src );
2722				$gallery_img.wc_set_variation_attr( 'src', variation.image.gallery_thumbnail_src );
2723				$gallery_img.wc_set_variation_attr( 'srcset', variation.image.gallery_thumbnail_src );
2724				$product_link.wc_set_variation_attr( 'href', variation.image.full_src );
2725			} else {
2726				$product_img.wc_reset_variation_attr( 'src' );
2727				$product_img.wc_reset_variation_attr( 'width' );
2728				$product_img.wc_reset_variation_attr( 'height' );
2729				$product_img.wc_reset_variation_attr( 'srcset' );
2730				$product_img.wc_reset_variation_attr( 'sizes' );
2731				$product_img.wc_reset_variation_attr( 'title' );
2732				$product_img.wc_reset_variation_attr( 'alt' );
2733				$product_img.wc_reset_variation_attr( 'data-src' );
2734				$product_img.wc_reset_variation_attr( 'data-large_image' );
2735				$product_img.wc_reset_variation_attr( 'data-large_image_width' );
2736				$product_img.wc_reset_variation_attr( 'data-large_image_height' );
2737				$product_img_wrap.wc_reset_variation_attr( 'data-thumb' );
2738				$gallery_img.wc_reset_variation_attr( 'src' );
2739				$gallery_img.wc_reset_variation_attr( 'srcset' );
2740				$product_link.wc_reset_variation_attr( 'href' );
2741			}
2742			
2743			window.setTimeout( function() {
2744				//$product_gallery.trigger( 'woocommerce_gallery_init_zoom' );
2745				$form.wc_maybe_trigger_slide_position_reset( variation );
2746				kapee.productImageZoom();
2747				$( window ).trigger( 'resize' );
2748			}, 20 );
2749		};
2750	};
2751	
2752	kapee.initAjaxLoad = function(){ 
2753		var button = $( '.kapee-ajax-load' );
2754
2755		button.each( function( i, val ) {
2756			var _option = $( this ).data();
2757			
2758			if ( _option !== undefined ) {
2759				var page      = _option.total_page,
2760					container = _option.container,
2761					container_element = _option.container_element,
2762					layout    = _option.layout,
2763					load_more_label    = _option.load_more_label,
2764					loading_finished_msg    = _option.loading_finished_msg,
2765					loading_msg    = kapee_options.js_translate_text.loading_txt,					
2766					isLoading = false,
2767					anchor    = $( val ).find( 'a' ),
2768					next      = $( anchor ).attr( 'href' ),
2769					i         = 2;
2770
2771				if ( layout == 'load-more-button' ) {
2772					$( val ).on( 'click', 'a', function( e ) {
2773						e.preventDefault();
2774						anchor = $( val ).find( 'a' );
2775						next   = $( anchor ).attr( 'href' );
2776
2777						$( anchor ).html( '<span class="loading"> '+loading_msg+'</span>' );
2778						
2779						getData();
2780					});
2781				}  else if( layout == 'infinity-scroll' ) {
2782					var waiting = false,
2783						endScrollHandle;
2784						kapee.$window.on('scroll', function () {
2785							
2786							if (kapee.$body.find('.infinity-scroll').is(':in-viewport')) {
2787								
2788								kapee.$body.find('.infinity-scroll a').trigger('click');
2789							}
2790						}).trigger('scroll');
2791						
2792						kapee.$body.on('click', '.kapee-pagination a.button', function (e) {
2793							if ( waiting ) {
2794								return;
2795							}
2796							waiting = true;
2797							e.preventDefault();
2798							
2799							var $el = $(this);
2800							$el.html( '<span class="loading"> '+loading_msg+'</span>' );
2801							if ($el.data('requestRunning')) {
2802								return;
2803							}
2804
2805							$el.data('requestRunning', true);
2806
2807							var $pagination = $el.closest('.kapee-pagination'),								
2808								container = _option.container,
2809								container_element = _option.container_element,
2810								$products = $pagination.prev('.'+container),
2811								href = $el.attr('href');
2812							
2813							
2814							$.get(
2815								href,
2816								function (response) {
2817									
2818									var content = $(response).find('#primary .'+ container).children('.'+container_element),
2819										$pagination_html = $(response).find('.kapee-pagination').html();
2820
2821									$pagination.html($pagination_html);
2822
2823									if ($('.masonry-grid').length > 0) {
2824							
2825										$products.append(content).isotope( 'appended', content );
2826										$products.imagesLoaded().progress(function() {
2827											$products.isotope('layout');
2828										});
2829									
2830									}else{
2831										$products.append(content);
2832									}
2833						
2834									$pagination.find('a').data('requestRunning', false);
2835									waiting = false;
2836									kapee.initMagnaficPopup();
2837									//kapee.priceSlider();
2838									kapee.kapeeOwlCarousel();
2839									kapee.tooltip();
2840									kapee.imagelazyload();
2841									kapee.widgetToggle();
2842									kapee.widgetMenuToggle();
2843									kapee.widgetMaxLimitItem();
2844									kapee.canvasSidebar();
2845									kapee.stickySidebar();
2846									kapee.swatchInLoop();
2847									kapee.productQuickView();
2848									kapee.ProductLoopQuantityField();
2849									kapee.addToCompare();
2850									$(document.body).trigger('kapee_shop_ajax_loading_end');
2851								}
2852							);
2853						});
2854					/* var animationFrame = function() {
2855						anchor = $( val ).find( 'a' );
2856						next   = $( anchor ).attr( 'href' );
2857
2858						var bottomOffset = $( '.' + container ).offset().top + $( '.' + container ).height() - $( window ).scrollTop();
2859
2860						if ( bottomOffset < window.innerHeight && bottomOffset > 0 && ! isLoading ) {
2861							if ( ! next )
2862								return;
2863							isLoading = true;
2864							if ( page >= i ) {
2865								$( anchor ).html( '<span class="loading"> '+loading_msg+'</span>' );
2866								getData();
2867							}
2868						}
2869					}
2870
2871					var scrollHandler = function() {
2872						requestAnimationFrame( animationFrame );
2873					};
2874
2875					$( window ).scroll( scrollHandler ); */
2876				} 
2877				var getData = function() {
2878					$.get( next + '', function( data ) {
2879						var content    = $( '.' + container, data ).wrapInner( '' ).html(),
2880							newElement = $( '.' + container, data ).find( '.' + container_element );
2881						next = $( anchor, data ).attr( 'href' );
2882						if ($('.masonry-grid').length > 0) {
2883							
2884							$( '.'+ container ).append(newElement).isotope( 'appended', newElement );
2885						$( '.'+ container ).imagesLoaded().progress(function() {
2886							$( '.'+ container ).isotope('layout');
2887						});
2888						
2889						}else{
2890							$( '.' + container ).append(newElement);
2891						}
2892						$( anchor ).text( load_more_label );
2893
2894						if ( page > i ) {
2895							if ( kapee_options.permalink == 'plain' ) {
2896								var link = next.replace( /paged=+[0-9]+/gi, 'paged=' + ( i + 1 ) );
2897							} else {
2898								var link = next.replace( /page\/+[0-9]+\//gi, 'page/' + ( i + 1 ) + '/' );
2899							}
2900
2901							$( anchor ).attr( 'href', link );
2902						} else {
2903							$( anchor ).text( loading_finished_msg );
2904							$( anchor ).attr( 'href', 'javascript:void(0);' ).addClass( 'disabled' );
2905						}
2906						isLoading = false;
2907						i++;
2908						kapee.initMagnaficPopup();
2909						//kapee.priceSlider();
2910						kapee.kapeeOwlCarousel();
2911						kapee.tooltip();
2912						kapee.imagelazyload();
2913						kapee.widgetToggle();
2914						kapee.widgetMenuToggle();
2915						kapee.widgetMaxLimitItem();
2916						kapee.canvasSidebar();
2917						kapee.stickySidebar();
2918						kapee.swatchInLoop();
2919						kapee.ProductLoopQuantityField();
2920						kapee.productQuickView();
2921						kapee.addToCompare();
2922						$(document).trigger('yith_wcwl_reload_fragments'); /* Fixed wishlist icon afer ajax*/
2923					});
2924				}
2925			}
2926		});
2927	}
2928	
2929	kapee.loadmoreProducts = function(){
2930		var load_more_products_button = $('.kapee-products-load-more');
2931		$('.kapee-products-load-more .kapee-load-more').on('click',function(){
2932			
2933			var load_more_btn = $(this);
2934			var page = parseInt(load_more_btn.attr('data-page'));
2935			var attr = load_more_btn.attr('data-attribute');
2936			var post_wrap = load_more_btn.closest('.kapee-element').find('.products-wrap');
2937            var wrap_id = load_more_btn.closest('.kapee-element').attr('id');
2938			var data = {
2939				action: 'kapee_loadmore_product',
2940				nonce: kapee_options.nonce,
2941				attr: attr,
2942				page: page,
2943			};
2944			if(load_more_btn.hasClass('loading')){ return false;}
2945			kapee.loadAjaxPost(load_more_btn,data,post_wrap,wrap_id);
2946		});
2947		var animationFrame = function () {
2948			$('.kapee-products-load-more a.infinity-scroll').each(function (i, val) {
2949				var load_more_btn = $(this);
2950				var page = parseInt(load_more_btn.attr('data-page'));
2951				var attr = load_more_btn.attr('data-attribute');
2952				var post_wrap = load_more_btn.closest('.kapee-element').find('.products-wrap');
2953				var wrap_id = load_more_btn.closest('.kapee-element').attr('id');
2954				var bottomOffset = post_wrap.offset().top + post_wrap.height() - $(window).scrollTop();
2955				if (bottomOffset < window.innerHeight && bottomOffset > 0) {
2956					
2957					var page = parseInt(load_more_btn.attr('data-page'));
2958					if(!load_more_btn.hasClass('kapee-loadmore-disabled')){ 
2959						if(!kapee.isPostLoading){
2960							kapee.isPostLoading = true;
2961							load_more_btn.trigger('click');
2962						}
2963					}
2964				}
2965			});
2966		}
2967		
2968		var scrollHandler = function () {
2969			requestAnimationFrame(animationFrame);
2970		};                    
2971		$(window).scroll(scrollHandler);		
2972	}
2973	
2974	kapee.loadAjaxPost = function( btn, data, element_wrap, parantElement ){
2975		var load_more_label = btn.data('load_more_label');
2976		var loading_finished_msg = btn.data('loading_finished_msg');
2977		var label_txt = '';
2978		btn.addClass('process');
2979		if(btn.hasClass('kapee-loadmore-disabled')){
2980			return;
2981		}
2982		btn.html('<span class="loading"> '+kapee_options.js_translate_text.loading_txt+'</span>');
2983		$.ajax({
2984			url: kapee_options.ajax_url,
2985			data: data,
2986			dataType: 'json',
2987			method: 'POST',
2988			success: function(response) {
2989				var items = $('' + response['html'] + '');
2990				if ($.trim(response['success']) == 'ok') {
2991					//element_wrap.append(items);
2992					
2993					if ($('.masonry-grid').length > 0) {
2994												
2995						 setTimeout(function () {
2996						  element_wrap.imagesLoaded().masonry().append(items).masonry( 'appended', items).masonry('layout');
2997						 }, 500);
2998						 
2999						 
3000					}else{
3001						element_wrap.append(items);
3002					}
3003					
3004					if ($.trim(response['show_bt']) == '0') {
3005						$('#' +parantElement + ' .kapee-load-more').addClass('disabled kapee-loadmore-disabled').html(loading_finished_msg);
3006					} else {
3007						$('#' +parantElement + ' .kapee-load-more').attr('data-page', data['page'] + 1);
3008						btn.html(load_more_label);
3009					}
3010				}
3011			},
3012			error: function(data) {
3013				console.log('ajax error');
3014			},
3015			complete: function() {
3016				kapee.isPostLoading = false;
3017				kapee.imagelazyload();
3018				kapee.initMagnaficPopup();
3019				kapee.swatchInLoop();
3020				kapee.ProductLoopQuantityField();			
3021				kapee.tooltip();
3022				kapee.productQuickView();
3023				kapee.addToCompare();
3024				$(document).trigger('yith_wcwl_reload_fragments'); /* Fixed wishlist icon afer ajax*/
3025				btn.removeClass('process');				
3026			},
3027		});
3028	}
3029	
3030	kapee.tooltip = function () {
3031		
3032		if ( ! kapee_options.product_tooltip ) { return; }
3033		
3034		var tooltip_left = ('.whishlist-button a,.whishlist-button .yith-wcwl-add-to-wishlist-button,.yith-wcwl-add-to-wishlist .yith-wcwl-wishlistaddedbrowse a,.product-style-2:not(.list-view) .product-buttons .cart-button,.product-style-2:not(.list-view) .product-buttons .compare-button a,.product-style-2:not(.list-view) .product-buttons .quickview-button a');
3035		// Bootstrap tooltips
3036		$(tooltip_left).tooltip({
3037			animation: false,
3038			container: 'body',
3039			trigger : 'hover',
3040			placement : !kapee.isCheckRTL() ? 'left':'right',
3041			title: function() {
3042				if( $(this).find('.added_to_cart').length > 0 ) {
3043					return $(this).find('.add_to_cart_button').text();
3044				}
3045				return $(this).text();
3046			}
3047		});
3048		
3049		$(document).on('yith_wcwl_fragments_loaded', function (e) {
3050			 $('.whishlist-button .yith-wcwl-add-to-wishlist .yith-wcwl-add-button a,.whishlist-button .yith-wcwl-add-to-wishlist .yith-wcwl-wishlistexistsbrowse a').tooltip({
3051			animation: false,
3052			container: 'body',
3053			trigger : 'hover',
3054			placement : !kapee.isCheckRTL() ? 'left':'right',
3055			title: function() {				
3056				return $(this).text();
3057			}
3058		});		
3059		});
3060		
3061		$('.products:not(.list-view):not(.product-style-1.grid-columns-4):not(.product-style-1.grid-columns-3):not(.product-style-1.grid-columns-6):not(.product-style-3.grid-columns-4):not(.product-style-3.grid-columns-3):not(.product-style-3.grid-columns-6):not(.product-style-4.grid-columns-4):not(.product-style-4.grid-columns-3):not(.product-style-4.grid-columns-6):not(.product-style-5.grid-columns-4):not(.product-style-5.grid-columns-3):not(.product-style-5.grid-columns-6) .product-buttons .cart-button,.has-sidebar .products:not(.list-view):not(.product-style-1.grid-columns-4):not(.product-style-1.grid-columns-6):not(.product-style-3.grid-columns-4):not(.product-style-3.grid-columns-6):not(.product-style-4.grid-columns-4):not(.product-style-4.grid-columns-6):not(.product-style-5.grid-columns-4):not(.product-style-5.grid-columns-6) .product-buttons .cart-button,.product-buttons .compare-button a,.product-buttons .quickview-button a,.kapee-tooltip').tooltip({
3062			animation: false,
3063			container: 'body',
3064			trigger : 'hover',
3065			title: function() {
3066				if( $(this).find('.added_to_cart').length > 0 ) return $(this).find('.add_to_cart_button').text();
3067				return $(this).text();
3068			}
3069		});	 				
3070	}
3071	
3072	kapee.productGallerySlider = function() {
3073		/*
3074		 * Product Gallery  & Thumnails slider
3075		 */
3076		if ( ! $.isFunction($.fn.slick) ) {
3077			return;
3078		}
3079		
3080		// Product Gallery Slider
3081		if( $('.woocommerce-product-gallery').find( '.single-product-gallery' ).length > 0 ) {
3082			$( '.single-product-gallery' ).not( '.slick-initialized' ).slick({
3083				slidesToShow	: ( 'product-gallery-horizontal' == kapee_options.product_gallery_layout ) ? 2 : 1,
3084				slidesToScroll	: 1,
3085				rows				: 0,
3086				asNavFor		: ( 'product-gallery-left' == kapee_options.product_gallery_layout || 'product-gallery-bottom' == kapee_options.product_gallery_layout ) ? '.single-product-thumbnails' : '',
3087				fade			: ( 'product-gallery-left' == kapee_options.product_gallery_layout || 'product-gallery-bottom' == kapee_options.product_gallery_layout ) ? true : false,
3088				dots			: ( 'product-gallery-horizontal' == kapee_options.product_gallery_layout || 'product-gallery-center' == kapee_options.product_gallery_layout ) ? true : false,
3089				infinite 		: false,
3090				adaptiveHeight	: true,
3091				rtl				: ( kapee.isCheckRTL() ) ? true : false,
3092				responsive		:[
3093					{
3094						breakpoint	: 639,
3095						settings	: {
3096							dots 			: true
3097						}
3098					}
3099				]
3100			});
3101		}
3102		
3103		// Product Thumbnails Silder
3104		if( $('.woocommerce-product-gallery').find( '.single-product-thumbnails' ).length > 0 ) {
3105			$( '.single-product-thumbnails' ).not( '.slick-initialized' ).slick({
3106				slidesToShow	: 4,
3107				slidesToScroll	: 1,
3108				asNavFor		: '.single-product-gallery',
3109				infinite 		: false,
3110				arrows			: true,
3111				focusOnSelect	: true,
3112				rows			: 0,
3113				vertical		: ( 'product-gallery-left' == kapee_options.product_gallery_layout ) ? true : false,			
3114				rtl				: ( 'product-gallery-bottom' == kapee_options.product_gallery_layout && kapee.isCheckRTL() ) ? true : false,
3115				responsive		:[
3116					{
3117						breakpoint	: 639,
3118						settings	: {
3119							slidesToShow 	: 4,
3120							infinite 		: false,
3121							vertical		: false,
3122							rtl				: ( kapee.isCheckRTL() ) ? true : false,
3123						}
3124					}
3125				]
3126			});
3127		}
3128		
3129		/* $( '.single-product-gallery' ).on('afterChange', function(event, slick, currentSlide, nextSlide){
3130			$('.slick-slide').removeClass('flex-active-slide');
3131			$('.slick-current').addClass('flex-active-slide');
3132		}); */
3133					
3134		// Reset the index of image on product variation
3135		$(document).on( 'found_variation', '.variations_form', function( es, variation ) {		
3136			if ( variation && variation.image && variation.image.src && variation.image.src.length > 1 ) {
3137				$( '.single-product-gallery, .single-product-thumbnails' ).slick( 'slickGoTo', 0 );
3138				setTimeout(function () {
3139					var $product_img = $(document).find( '.kapee-quick-view .woocommerce-product-gallery__wrapper  .slick-current.slick-active img' );
3140					kapee.setVariationAttr( $product_img, 'src',
3141					variation.image.src );
3142					kapee.setVariationAttr( $product_img, 'srcset',
3143					variation.image.srcset );
3144					kapee.setVariationAttr( $product_img, 'sizes',
3145					variation.image.sizes );
3146				}, 300);
3147			}
3148		}).on('reset_image', function () {
3149			$( '.single-product-gallery, .single-product-thumbnails').slick( 'slickGoTo', 0 );
3150			setTimeout(function () {
3151				var $product_img = $(document).find( '.kapee-quick-view .woocommerce-product-gallery__wrapper  .slick-current.slick-active img' );
3152				kapee.resetVariationAttr( $product_img, 'src' );
3153				kapee.resetVariationAttr( $product_img, 'srcset' );
3154				kapee.resetVariationAttr( $product_img, 'sizes' );
3155			}, 300);
3156		});
3157	};
3158	
3159	kapee.productImageZoom = function(){
3160		/*
3161		 * Single Product image zoom
3162		 */
3163		if ( kapee_options.product_image_zoom ) {
3164		
3165			var $wc_gallery = $( '.single-product-page .woocommerce-product-gallery' ),
3166			    zoomTarget = $wc_gallery.find( '.woocommerce-product-gallery__image > a, .woocommerce-product-gallery__image' ),
3167				width 		= zoomTarget.children('img').attr( 'data-large_image_width' ),
3168				// zoom option
3169				zoom_options = $.extend( {
3170					touch: false
3171				});
3172				
3173			// On Click Zoom
3174			if ('ontouchstart' in document.documentElement) {
3175				zoom_options.on = 'click';
3176			}			
3177			
3178			setTimeout(function () {
3179				zoomTarget.parent().trigger('zoom.destroy').children('.zoomImg').remove();
3180			}, 500);			
3181			
3182			// Zoom
3183			if ( 'undefined' != typeof width && zoomTarget.width() < width ) {
3184				zoomTarget.trigger( 'zoom.destroy' );
3185				zoomTarget.zoom(zoom_options);
3186				
3187				// show zoom on hover
3188				zoomTarget.find(':hover').length && zoomTarget.trigger('mouseover');
3189			}
3190		}
3191	};
3192	
3193	kapee.productPhotoSwipe = function () {
3194		/*
3195		 * Single Product Photo Swipe
3196		 */
3197		if ( kapee_options.product_PhotoSwipe ) {
3198			if( $( '.woocommerce-product-gallery' ).length === 0 ){
3199				return;
3200			}
3201			//var self = this;
3202			var $wc_gallery = $( '.woocommerce-product-gallery' );	
3203			
3204			setTimeout( function () {
3205				// If woocommmerce product gallery is undefined, create it
3206				typeof $wc_gallery.data('product_gallery') == 'undefined' && $wc_gallery.wc_product_gallery();
3207				this.$wc_gallery = $wc_gallery;
3208				this.wc_gallery = $wc_gallery.data('product_gallery');
3209			
3210				// Remove woocommerce zoom triggers
3211				$wc_gallery.children('.woocommerce-product-gallery__trigger').remove();
3212				
3213				// Prevent going to image link
3214				$wc_gallery
3215					.off('click', '.woocommerce-product-gallery__image a')
3216					.on('click', kapee.preventDefault);
3217								
3218				$wc_gallery.on('click', '.woocommerce-product-gallery__image a, .woocommerce-product-gallery__image', kapee.openPhotoswipe.bind(this));
3219				$wc_gallery.on('click', '.kapee-product-image-full', kapee.openPhotoswipe.bind(this));
3220			}, 100 );
3221		}else{
3222			$('.woocommerce-product-gallery__image a').on('click', function(e){
3223				e.preventDefault();
3224			});			
3225		}		
3226	};
3227	
3228	kapee.openPhotoswipe = function (e) {
3229		if (wc_single_product_params.photoswipe_options) {	
3230			// Slick slider index
3231			var slider = this.$wc_gallery.find('.single-product-gallery').slick("getSlick");
3232			if (slider) {
3233				wc_single_product_params.photoswipe_options.index = slider.currentSlide;
3234			}		
3235
3236			this.wc_gallery.openPhotoswipe(e);			
3237			e.stopPropagation();	
3238		}
3239	}
3240	
3241	kapee.productSaleCountdown = function() {
3242		/*
3243		 * Product Sale CountDown
3244		 */
3245		
3246		$('.product-countdown').each(function(){			
3247			var $this 	= $(this),
3248				template 	= '',
3249				end_date = $this.data('end-date');
3250			
3251			if( $this.data('countdown-style') == 'countdown-box' ) {
3252				template = '<span class="days">%-D<span>'+kapee_options.js_translate_text.days_text+'</span></span><span class="hour">%H<span>'+kapee_options.js_translate_text.hours_text+'</span></span><span class="minute">%M<span>'+kapee_options.js_translate_text.mins_text+'</span></span><span class="second">%S<span>
3252'+kapee_options.js_translate_text.secs_text+'</span></span>';
3253			}else{
3254				template = '%-D'+kapee_options.js_translate_text.sdays_text+':%H'+kapee_options.js_translate_text.shours_text+':%M'+kapee_options.js_translate_text.smins_text+':%S'+kapee_options.js_translate_text.ssecs_text;
3255			}
3256			
3257			// initialize 
3258			$this.countdown( end_date, function(event) {
3259				 $(this).html(event.strftime(template));
3260			});
3261		});
3262	};
3263	
3264	kapee.productReviewLink = function() {
3265		/*
3266		 * Scroll Show Product Review Tab
3267		 */
3268		
3269		$( 'body' ).on( 'click', 'a.woocommerce-review-link', function() {
3270			$( '.reviews_tab a' ).click();
3271			return true;
3272		} );
3273	};
3274	kapee.productPriceSummary = function () {
3275		/*
3276		 * Product Price Summary Popup in Mobile
3277		 */				
3278		$( document ).on( 'click', '.kapee-mobile-device .exclamation-mark.open', function() {
3279			var _this = $(this);
3280			_this.removeClass('open');
3281			_this.find('.kapee-arrow').addClass('active');
3282			
3283		});
3284		$( document ).on( 'click', '.kapee-mobile-device .product-price-summary .kapee-close', function() {
3285			$('.product-price-summary .kapee-arrow').removeClass('active');
3286			$('.product-price-summary').addClass('open');			
3287		});		
3288	};
3289	
3290	kapee.getProductSizeChart = function () {
3291		/*
3292		 * Get Product Size Chart
3293		 */	
3294		$('.kapee-ajax-size-chart').on('click', function (e) {
3295			e.preventDefault();
3296			 var id = $(this).data('id'); // get post value
3297			 var data = {
3298				action			: 'kapee_ajax_get_size_chart',
3299				'id'			: id,
3300				nonce   		: kapee_options.nonce,
3301			};
3302			var chart_btn = $(this);
3303			if(chart_btn.hasClass('loading')){
3304				return false;
3305			}
3306			chart_btn.addClass('loading');
3307			$.ajax({
3308				type: 'post',
3309				url: kapee_options.ajax_url,
3310				data: data,
3311				beforeSend: function (response) {
3312					
3313				},
3314				complete: function (response) {
3315					chart_btn.removeClass('loading');
3316				},
3317				success: function (response) {
3318					$(this).magnificPopup({
3319						removalDelay: 500,
3320						items: {
3321							src: response,
3322							type: 'inline'
3323						},
3324						callbacks: {
3325							open: function () {
3326								var popupWrap = $( '.kapee-product-sizechart' );
3327								popupWrap.addClass('animate__animated animate__fadeInLeft');						
3328							},							
3329							beforeClose: function() {
3330								var popupWrap = $( '.kapee-product-sizechart' );
3331								popupWrap.removeClass('animate__fadeInLeft').addClass('animate__fadeOutRight');
3332							}, 
3333							close: function() {
3334								var popupWrap = $( '.kapee-product-sizechart' );
3335								popupWrap.removeClass('animate__animated animate__fadeOutRight');
3336								
3337							}
3338						},
3339					}).magnificPopup('open');
3340				},
3341			});			
3342      });
3343	}
3344	
3345	kapee.getAjaxBlock = function () {
3346		/*
3347		 * Get Block
3348		 */	
3349		$('.kapee-block-ajax').on('click', function (e) {
3350			e.preventDefault();
3351			 var id = $(this).data('id'); /* get block value */
3352			 var title = $(this).data('title'); /* title */
3353			 var data = {
3354				action			: 'kapee_ajax_get_block',
3355				'id'			: id,
3356				'title'			: title,
3357				nonce   		: kapee_options.nonce,
3358			};
3359			var chart_btn = $(this);
3360			if(chart_btn.hasClass('loading')){
3361				return false;
3362			}
3363			chart_btn.addClass('loading');
3364			$.ajax({
3365				type: 'post',
3366				url: kapee_options.ajax_url,
3367				data: data,
3368				beforeSend: function (response) {
3369					
3370				},
3371				complete: function (response) {
3372					chart_btn.removeClass('loading');
3373				},
3374				success: function (response) {
3375					$(this).magnificPopup({
3376						removalDelay: 500,
3377						items: {
3378							src: response,
3379							type: 'inline'
3380						},
3381						callbacks: {
3382							open: function () {
3383								var popupWrap = $( '.kapee-ajax-blok-content' );
3384								popupWrap.addClass('animate__animated animate__fadeInLeft');						
3385							},							
3386							beforeClose: function() {
3387								var popupWrap = $( '.kapee-ajax-blok-content' );
3388								popupWrap.removeClass('animate__fadeInLeft').addClass('animate__fadeOutRight');
3389							}, 
3390							close: function() {
3391								var popupWrap = $( '.kapee-ajax-blok-content' );
3392								popupWrap.removeClass('animate__animated animate__fadeOutRight');
3393								
3394							}
3395						},
3396					}).magnificPopup('open');
3397				},
3398			});
3399			
3400      });
3401	}
3402	
3403	kapee.getProductTermsConditions = function () {
3404		/*
3405		 * Get Product Terms & Conditions
3406		 */	
3407		var cache = [];
3408		$('.kapee-ajax-block').on('click', function (e) {
3409			e.preventDefault();
3410			$(document).find('.product-term-detail').removeClass('active');
3411			var html = "<div class='product-term-detail kapee-arrow active'> <span class='loading'></span></div>";
3412			var process = false;
3413			var $this = $(this);
3414			var content = $(this).closest('.product-term-wrap').find('.product-term-detail');
3415			var id = $(this).data('id'); // get post value
3416			if(id == ''){return false;}
3417			if( cache['term_condition_'+id] ) {
3418				$(".product-term-detail").not(content).removeClass('active');
3419				if(content.length){
3420					content.addClass('active');
3421				}else{
3422					$(this).after(html);
3423					$this.closest('.product-term-wrap').find('.product-term-detail').addClass('active').html(cache['term_condition_'+id]);
3424				}
3425                return;
3426            }
3427			 var data = {
3428				action			: 'kapee_ajax_get_product_terms_conditions',
3429				'id'			: id,
3430				nonce   		: kapee_options.nonce,
3431			};
3432			
3433			$(this).after(html);
3434			//return false;
3435			$.ajax({
3436				type: 'post',
3437				url: kapee_options.ajax_url,
3438				data: data,
3439				beforeSend: function (response) {
3440					
3441				},
3442				complete: function (response) {
3443					content.removeClass('loading');
3444				},
3445				success: function (response) {
3446					//content.html(response);
3447					$this.closest('.product-term-wrap').find('.product-term-detail').addClass('active').html(response);
3448					cache['term_condition_'+id] = response;
3449				},
3450			});			
3451      });
3452	  
3453	  /* Hide .terms */
3454		$(document).mouseup(function (e){
3455			var container = $(".product-term-wrap");			
3456			if (!container.is(e.target) && container.has(e.target).length === 0){				
3457				$(".product-term-detail").removeClass('active');				
3458			}
3459		}); 
3460		
3461		$( document ).on( 'click', '.product-term-wrap .kapee-close', function() {
3462			$(".product-term-detail").removeClass('active');
3463		});
3464		
3465	}
3466	
3467	kapee.productQuantityPlusMinus = function() {
3468		/*
3469		 * Product Quantity Plus/Minus
3470		 */
3471		$( document ).on( 'click', '.quantity .plus, .quantity .minus', function() {
3472            // Get values
3473            var $qty        = $( this ).closest( '.quantity' ).find( '.qty'),
3474                currentVal  = parseFloat( $qty.val() ),
3475                max         = parseFloat( $qty.attr( 'max' ) ),
3476                min         = parseFloat( $qty.attr( 'min' ) ),
3477                step        = $qty.attr( 'step' );
3478
3479            // Format values
3480            if ( ! currentVal || currentVal === '' || currentVal === 'NaN' ) currentVal = 0;
3481            if ( max === '' || max === 'NaN' ) max = '';
3482            if ( min === '' || min === 'NaN' ) min = 0;
3483            if ( step === 'any' || step === '' || step === undefined || parseFloat( step ) === 'NaN' ) step = '1';
3484
3485            // Change the value
3486            if ( $( this ).is( '.plus' ) ) {
3487                if ( max && ( max == currentVal || currentVal > max ) ) {
3488                    $qty.val( max );
3489                } else {
3490                    $qty.val( currentVal + parseFloat( step ) );
3491                }
3492            } else {
3493                if ( min && ( min == currentVal || currentVal < min ) ) {
3494                    $qty.val( min );
3495                } else if ( currentVal > 0 ) {
3496                    $qty.val( currentVal - parseFloat( step ) );
3497                }
3498            }
3499
3500            // Trigger change event
3501            $qty.trigger( 'change' );
3502        });
3503	};
3504	
3505	kapee.productQuickShop = function () {
3506		/*
3507		 * Product Buy Now Button click
3508		 */
3509		$('body').on('click', '.kapee_quick_buy_button', function() {
3510			if (kapee_options.product_add_to_cart_ajax) {
3511				$('.single_add_to_cart_button').addClass('quick-buy-proceed');
3512			}
3513			var $this = $(this);
3514			var product_id = $(this).attr('data-kapee-product-id');
3515			var product_type = $(this).attr('data-product-type');
3516			var selected = $('form.cart input#kapee_quick_buy_product_' + product_id);
3517			var productform = selected.parent();
3518			
3519			var submit_btn = productform.find('[type="submit"]');
3520			var is_disabled = submit_btn.is(':disabled');
3521			if(!$(this).closest('.woocommerce-variation-add-to-cart').hasClass('woocommerce-variation-add-to-cart-disabled')){
3522				$this.addClass('loading');
3523			}
3524			if ( is_disabled ) {
3525				$('html, body').animate({
3526					scrollTop: submit_btn.offset().top - 200
3527				}, 900);
3528			} else {
3529				if(!$this.hasClass('disable')){
3530					productform.append('<input type="hidden" value="true" name="kapee_quick_buy" />');
3531				}
3532				productform.find('.single_add_to_cart_button').trigger('click');
3533			} 
3534		});
3535		
3536		$('form.cart').change(function () {
3537			var is_submit_disabled = $(this).find('[type="submit"]').is(':disabled');
3538			if ( is_submit_disabled ) {
3539				$('.kapee_quick_buy_button').attr('disabled', 'disable');
3540			} else {
3541				$('.kapee_quick_buy_button').removeAttr('disabled');
3542			}
3543		});
3544	}
3545	
3546	kapee.productBoughtTogetherInit = function(){ 
3547		/* Procut Bought Together */
3548		
3549		if ( kapee.$body.find('.kapee-bought-together-products').length === 0 ) {
3550			return;
3551		}
3552		
3553		var self = this;
3554		// check box click
3555		$('body').on('click', '.kapee-bought-together-products .product-checkbox input[type=checkbox]', function() {
3556			if ($(this).is(":checked")) {
3557				$(this).closest('.product-wrapper').removeClass('kapee-disable-product');				
3558			}else{
3559				$(this).closest('.product-wrapper').addClass('kapee-disable-product');
3560			}
3561			self.productBoughtTogetherChangeEvent();
3562		});
3563		// check all
3564		self.productBoughtTogetherCheckAllItems();
3565		// add to cart
3566		self.productBoughtTogetherAddToCart();
3567		
3568		$( 'body' ).on( 'found_variation', function( event, variation ) {
3569			$('.kapee-bought-together-products .current-item .item-price').each(function() {				
3570				if( $(this).data( 'type' ) == 'variable' ) {
3571					$(this).data( 'itemprice', variation.display_price );
3572					$(this).html(self.kapee_woo_formated_price(variation.display_price));
3573					self.productBoughtTogetherChangeEvent();
3574				}
3575			});
3576		});
3577	}
3578	kapee.productBoughtTogetherChangeEvent = function() {
3579		var self = this;
3580		$('.add-items-to-cart').addClass('loading');
3581		
3582		var total_price = self.product_bought_together_get_total_price();
3583		var addon_total_price = self.product_addons_get_total_price();
3584		var total_addon = self.product_bought_together_product_count();
3585		if(total_addon){
3586			$('.add-items-to-cart').removeAttr("disabled");
3587		}else{
3588			$('.add-items-to-cart').attr("disabled", true);
3589		}
3590		$( '.addons-item .addon-count' ).html( total_addon );
3591				$( '.addons-item span.items-price' ).html( self.kapee_woo_formated_price(addon_total_price) );
3592				$( '.items-total span.total-price' ).html( self.kapee_woo_formated_price(total_price) );
3593		$('.add-items-to-cart').removeClass('loading');
3594	}
3595	
3596	kapee.kapee_woo_formated_price = function(number){
3597		var self = this;
3598		return window.kapeePublic.kapee_formated_price(number, kapee_options.price_thousand_separator,
3599		kapee_options.price_decimal_separator, kapee_options.price_decimals, 
3600		kapee_options.currency_symbol,kapee_options.price_format);
3601	}
3602	
3603	kapee.kapee_formated_price = function(number, thousand_sep, decimal_sep, tofixed, symbol, woo_price_format){
3604		  var before_text = '';
3605        var after_text = '';
3606        number = number || 0;
3607        tofixed = !isNaN(tofixed = Math.abs(tofixed)) ? tofixed : 2;
3608        symbol = symbol !== undefined ? symbol : "$";
3609        thousand_sep = thousand_sep || ",";
3610        decimal_sep = decimal_sep || ".";
3611        var negative = number < 0 ? "-" : "",
3612            i = parseInt(number = Math.abs(+number || 0).toFixed(tofixed), 10) + "",
3613            j = (j = i.length) > 3 ? j % 3 : 0;
3614        
3615        symbol = '<span class="woocommerce-Price-currencySymbol">' + symbol + '</span>';
3616        
3617        switch (woo_price_format) {
3618            case '%1$s%2$s':
3619                //left
3620                before_text += symbol;
3621                break;
3622            case '%1$s %2$s':
3623                //left with space
3624                before_text += symbol + ' ';
3625                break;
3626            case '%2$s%1$s':
3627                //right
3628                after_text += symbol;
3629                break;
3630            case '%2$s %1$s':
3631                //right with space
3632                after_text += ' ' + symbol;
3633                break;
3634            default:
3635                //default
3636                before_text += symbol;
3637        }       
3638        
3639        var woo_price_return = before_text +
3640            negative + (j ? i.substr(0, j) + thousand_sep : "" ) +
3641            i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand_sep) +
3642            (tofixed ? decimal_sep + Math.abs(number - i).toFixed(tofixed).slice(2) : "") +
3643            after_text;
3644        
3645        woo_price_return = '<span class="woocommerce-Price-amount amount">' + woo_price_return + '</span>';
3646        
3647        return woo_price_return;
3648	}
3649	
3650	kapee.productBoughtTogetherCheckAllItems = function(){
3651		var self = this;
3652		$('body').on('click', '.check-all-items', function(){
3653			$('.kapee-together-product:checkbox').not(this).prop('checked', this.checked);
3654			if ($(this).is(":checked")) {
3655				$('.kapee-together-product:checkbox').prop('checked', true);  
3656			} else {
3657				$('.kapee-together-product:checkbox').prop("checked", false);
3658			}
3659
3660			self.productBoughtTogetherChangeEvent();
3661		});
3662	}
3663	
3664	kapee.BoughtTogetherIsVariationProduct = function(){
3665		
3666		var product_type = $('.kapee-bought-together-products .current-item .item-price').data('type');
3667		if( product_type == 'variable'){
3668			return true
3669		}
3670		return false;
3671	}
3672	
3673	kapee.BoughtTogetherCurrentProductid = function(){
3674				
3675		var product_id = $('.kapee-bought-together-products .current-item .item-price').data('id');
3676		
3677		return 	product_id;
3678	}
3679	
3680	kapee.BoughtTogetherVariationAvailable = function(){
3681		if( $(".single_add_to_cart_button").length === 0 || $(".single_add_to_cart_button").hasClass("disabled") || $(".single_add_to_cart_button").hasClass("wc-variation-is-unavailable") ) {
3682			return false;
3683		}
3684		return true;
3685	}
3686	
3687	kapee.productBoughtTogetherAddToCart = function(){
3688		var self = this;
3689		$('body').on('click', '.add-items-to-cart:not(.loading)', function(e){
3690			e.preventDefault();
3691			
3692			var is_variation_product = kapee.BoughtTogetherIsVariationProduct();
3693			var variation_product_id = kapee.BoughtTogetherCurrentProductid();
3694			
3695			if(is_variation_product && kapee.BoughtTogetherVariationAvailable() === false){
3696				alert(kapee_options.js_translate_text.variation_unavailable);
3697				return;
3698			}
3699			
3700			var self_this = $(this);
3701			self_this.addClass('loading');
3702			
3703			var all_product_ids = self.product_bought_together_get_checked_product_ids();
3704			var msg='';
3705			if( all_product_ids.length === 0 ) {
3706				msg = kapee_options.bought_together_error;
3707			} else {
3708				
3709				setTimeout(function () {
3710					for (var i = 0; i < all_product_ids.length; i++ ) {
3711						if( is_variation_product && all_product_ids[i] == variation_product_id ){							
3712							var variation_id  = $('.variations_form .variations_button').find('input[name^=variation_id]').val();
3713							var variation = {};
3714							if( $( '.variations_form' ).find('select[name^=attribute]').length ) {
3715								$( '.variations_form' ).find('select[name^=attribute]').each(function() {
3716									var attribute = $(this).attr("name");
3717									var attributevalue = $(this).val();
3718									variation[attribute] = attributevalue;
3719								});
3720							} else {
3721
3722								$( '.variations_form' ).find('.select').each(function() {
3723									var attribute = $(this).attr("data-attribute-name");
3724									var attributevalue = $(this).find('.selected').attr('data-name');
3725									variation[attribute] = attributevalue;
3726								});
3727
3728							}
3729							$.ajax({
3730								type: "POST",
3731								async: false,
3732								url: kapee_options.ajax_url,
3733								data: {
3734									'product_id': all_product_ids[i],
3735									'variation_id': variation_id, 
3736									'variation': variation,
3737									'action': 'kapee_all_add_to_cart'
3738								},
3739								success : function( response ) {
3740									self.product_bought_together_refresh_fragments( response );
3741								}
3742							}); 
3743						} else {
3744							$.ajax({
3745								type: "POST",
3746								async: false,
3747								url: kapee_options.ajax_url,
3748								data: {
3749									'product_id': all_product_ids[i],
3750									'action': 'kapee_all_add_to_cart'
3751								},
3752								success : function( response ) {
3753									self.product_bought_together_refresh_fragments( response );
3754								}
3755							}); 
3756						}
3757					}
3758					var miniCartSidebar = $('.kapee-minicart-slide');
3759					var closeSidebar 	= $('.kapee-mask-overaly');
3760					if ( ! miniCartSidebar.hasClass('opened') ) {
3761						miniCartSidebar.addClass('opened');
3762						closeSidebar.addClass('opened');
3763						self.initNanoScroller();
3764					}
3765					self_this.removeClass('loading');
3766				}, 300); 
3767				
3768			}
3769			if(msg != ''){
3770				$( '.kapee-wc-message' ).html(msg).show(100);
3771				self_this.removeClass('loading');
3772				setTimeout(function () {
3773					$( '.kapee-wc-message' ).slideUp(500);
3774					
3775				}, 3000);				
3776			}
3777			
3778		});
3779	}
3780	
3781	kapee.product_bought_together_get_total_price = function(){
3782		var tprice = 0,itemprice =0;
3783		itemprice = $('.items-total-price .item-price').data('itemprice');
3784		tprice = parseFloat(itemprice);
3785		$('.kapee-bought-together-products .product-checkbox input[type=checkbox]').each(function() {
3786			if( $(this).is(':checked') ) {
3787				tprice += parseFloat( $(this).data( 'price' ) );
3788			}
3789		});
3790		return tprice;
3791	}
3792	
3793	kapee.product_addons_get_total_price = function(){
3794		var tprice = 0;
3795		
3796		$('.kapee-bought-together-products .product-checkbox input[type=checkbox]').each(function() {
3797			if( $(this).is(':checked') ) {
3798				tprice += parseFloat( $(this).data( 'price' ) );
3799			}
3800		});
3801		return tprice;
3802	}
3803	
3804	kapee.product_bought_together_product_count = function(){
3805		var pcount = 0;
3806		$('.kapee-bought-together-products .product-checkbox input[type=checkbox]').each(function() {
3807			if ($(this).is(':checked')) {
3808				pcount++;
3809			}
3810		});
3811		return pcount;
3812	}
3813	
3814	// get checked product ids
3815	kapee.product_bought_together_get_checked_product_ids = function(){
3816		var pids = [],pidd;
3817		pidd = $('.items-total-price .item-price').data('id');
3818		
3819		pids.push( pidd);
3820		$('.kapee-bought-together-products .product-checkbox input[type=checkbox]').each(function() {
3821			if( $(this).is(':checked') ) {
3822				pids.push( $(this).data( 'id' ) );
3823			}
3824		});
3825		return pids;
3826	}
3827	
3828	// get checked product ids
3829	kapee.product_bought_together_refresh_fragments = function(response){
3830		var frags = response.fragments;
3831
3832            // Block fragments class
3833            if ( frags ) {
3834                $.each( frags, function( key ) {
3835                    $( key ).addClass( 'updating' );
3836                });
3837            }
3838            if ( frags ) {
3839                $.each( frags, function( key, value ) {
3840                    $( key ).replaceWith( value );
3841                });
3842            }
3843	}
3844	
3845	kapee.wooProductTabsAccordian = function(){
3846		if( ( $('.woocommerce-tabs.accordion-layout').length > 0 ) || ( $('.woocommerce-tabs.tabs-layout').length > 0 ) ){
3847			
3848			var $accordion = $('.tab-content-wrap');
3849			var hash  = window.location.hash;
3850			var url   = window.location.href;
3851		
3852			if ( hash.toLowerCase().indexOf( 'comment-' ) >= 0 || hash === '#reviews' || hash === '#tab-reviews' ) {
3853				$accordion.find('.title-reviews').addClass('open');
3854			} else if ( url.indexOf( 'comment-page-' ) > 0 || url.indexOf( 'cpage=' ) > 0 ) {
3855				$accordion.find('.title-reviews').addClass('open');
3856			}else if ( hash === '#tab-additional_information' ) {
3857				$accordion.find('.title-additional_information').addClass('open');
3858			}  else {
3859				$accordion.find('.accordion-title').first().addClass('open');
3860			}
3861			$accordion.on('click', '.accordion-title', function( e ) {
3862				e.preventDefault();
3863				$(this).parent().siblings().find('.woocommerce-Tabs-panel').slideUp('fast');
3864				$(".accordion-title").not($(this)).removeClass("open");
3865				$(this).toggleClass("open").next().slideToggle('fast');
3866			});
3867			$(document).on('click', 'a.woocommerce-review-link', function(e) {
3868				$accordion.find('.accordion-title').removeClass("open");
3869				$accordion.find('.title-reviews').addClass("open");
3870			});
3871		}
3872	}
3873	
3874	kapee.wooProductTabsToggle = function(){
3875		if($('.woocommerce-tabs.toggle-layout').length > 0){
3876			var $accordion = $('.tab-content-wrap');
3877			
3878			$accordion.find('.accordion-title').addClass('open');
3879			$accordion.find('.woocommerce-Tabs-panel').css("display", "block");
3880			$accordion.on('click', '.accordion-title', function( e ) {
3881				e.preventDefault();				
3882				var accordion = $(this);
3883				var accordionContent = accordion.next('.woocommerce-Tabs-panel');				
3884				accordion.toggleClass("open");
3885				accordionContent.slideToggle(250);				
3886			});
3887			$(document).on('click', 'a.woocommerce-review-link', function(e) {
3888				e.stopPropagation();
3889			});
3890		}
3891	}
3892	
3893	kapee.wooCheckoutStep = function() {
3894		var btn_next = $('.checkout-next-step'),
3895		wooStepWrap = $('#checkout-wrapper .panel.panel-default'),
3896		mutistepCheckout = $('#multi-step-checkout');
3897		if(mutistepCheckout.length > 0 ){ var formscrollTo = mutistepCheckout.offset().top - 30;}
3898		
3899		btn_next.on('click',function(){
3900			
3901			$(window).unbind('beforeunload'); /* Fixed site loader in multi step checkout */
3902			
3903			var currentPanel 	= $(this).closest("div.panel.panel-default"),			
3904			this_btn 		= $(this),
3905			currentstep 		= currentPanel.data('step'),
3906			steptitle 		= currentPanel.data('steptitle'),
3907			nextPanel_id 		= this_btn.data("next"),
3908			nextPanel 			= $("#"+nextPanel_id),
3909			billing 			= $( '#customer_billing_details' ),
3910			shipping 			= $( '#customer_shipping_details' ),
3911			selector 			= null,
3912			valid           	= false,
3913			$offset         = 30,
3914			posted_data     	= {};
3915			this_btn.addClass('loading');
3916			$( 'form.woocommerce-checkout .woocommerce-NoticeGroup.woocommerce-NoticeGroup-checkout' ).remove();
3917			setTimeout(function () {
3918			if(steptitle == 'billing' || steptitle =='shipping'){
3919				
3920				if(steptitle == 'billing'){
3921					selector = billing;
3922				}
3923				if(steptitle == 'shipping'){
3924					selector = shipping;
3925				}
3926				$( selector ).find( '.validate-required input' ).each( function() {
3927					posted_data[ $( this ).attr( 'name' ) ] = $( this ).val();
3928				} );
3929
3930				$( selector ).find( '.validate-required select' ).each( function() {
3931					posted_data[ $( this ).attr( 'name' ) ] = $( this ).val();
3932				} );
3933
3934				$( selector ).find( '.input-checkbox' ).each( function() {
3935					if ( $( this ).is( ':checked' ) ) {
3936						posted_data[ $( this ).attr( 'name' ) ] = $( this ).val();
3937					}
3938				} );
3939				
3940				var data = {
3941					action		: 'kapee_validate_checkout',
3942					type		: steptitle,
3943					posted_data	: posted_data,
3944					nonce   	: kapee_options.nonce,
3945				};
3946
3947				$.ajax( {
3948					type: 'POST',
3949					url: kapee_options.ajax_url,
3950					data: data,
3951					async: false,
3952					success: function( response ) {
3953						valid = response.valid;
3954
3955						if ( ! response.valid ) {
3956							currentPanel.find('.panel-body').prepend( response.html );
3957							$( 'html, body' ).animate( {
3958								scrollTop: $( 'form.woocommerce-checkout' ).offset().top - $offset },
3959							'slow' );
3960						}
3961						this_btn.removeClass('loading');
3962					},
3963					complete: function() {}
3964				} );
3965				
3966			}else {
3967				valid = true;
3968			}
3969			if ( valid ) {
3970				
3971			}else{
3972				
3973				return false;
3974			}
3975		 
3976			if ($(nextPanel).hasClass('hidden')) {
3977				currentPanel.removeClass('active');
3978				currentPanel.addClass('completed');
3979				currentPanel.find('.panel-collapse').slideUp('slow').removeClass('show');
3980				this_btn.removeClass('loading');
3981				$(nextPanel).removeClass('hidden');
3982				$(nextPanel).addClass('active');
3983				$(nextPanel).find('.panel-collapse').slideDown('slow').addClass('show');
3984				 $( 'html, body' ).animate( {
3985					scrollTop : formscrollTo },
3986				'slow' );		
3987				
3988			}
3989			return false;
3990			}, 300); 
3991		});
3992		$('.edit-action').on('click',function(){
3993			var currentPanel 	= $(this).closest("div.panel.panel-default"),			
3994			this_btn 		= $(this),
3995			currentstep 		= currentPanel.data('step');
3996			currentPanel.removeClass('completed').addClass('active');
3997			currentPanel.find('.panel-collapse').slideDown('slow').addClass('show');
3998			kapee_deactivate_steps(currentstep);
3999		});
4000		function kapee_deactivate_steps(currentstep){
4001			var panels = mutistepCheckout.find('.panel');
4002			panels.each(function( index ) {
4003				var current_panel = $(this),
4004				step = current_panel.data('step');
4005				if(currentstep < step)
4006				{
4007					var stepwrap = $("#step-"+step);
4008					if(stepwrap.hasClass('active')){
4009						stepwrap.find('.panel-collapse').slideUp('slow').removeClass('show');
4010						stepwrap.removeClass('active');
4011						stepwrap.addClass('hidden');
4012					}
4013					if(stepwrap.hasClass('completed')){
4014						stepwrap.removeClass('completed');
4015						stepwrap.addClass('hidden');
4016					}
4017				}
4018				
4019				
4020			});
4021		}
4022	}
4023	
4024	kapee.resetVariations = function(){
4025		var price_html = '',
4026			discount_html = '',
4027			price_summary_html = '',
4028			$price_summer_inner_price = $(document).find(".woocommerce div.entry-summary > p.price"),
4029			$price_summer_inner_discount = $(document).find(".woocommerce div.entry-summary .product-price-discount"),
4030			$price_summer_inner_price_summary = $(document).find(".woocommerce div.entry-summary .product-price-summary");
4031		if($price_summer_inner_price.length){
4032			price_html = $price_summer_inner_price.html();
4033        }
4034		if($price_summer_inner_discount.length){
4035			discount_html = $price_summer_inner_discount.html();
4036        }
4037		if($price_summer_inner_price_summary.length){
4038			price_summary_html = $price_summer_inner_price_summary.html();
4039        }
4040		
4041		$(document).find( ".variations_form" ).on( "reset_data", function () {
4042				if (kapee_options.disable_variation_price_change) {
4043					return;
4044				}
4045				$(document).find(".woocommerce div.entry-summary > p.price").html(price_html);
4046				$(document).find(".woocommerce div.entry-summary .product-price-discount").html(discount_html);
4047				$(document).find(".woocommerce div.entry-summary .product-price-summary").html(price_summary_html);
4048				if($(document).find(".woocommerce .kapee-quick-buy").length){
4049					$(document).find(".kapee_quick_buy_button").addClass('disabled');
4050				}
4051		});
4052	}
4053	
4054	kapee.variationChangeevent = function(){
4055		$( ".single_variation_wrap" ).on( "show_variation", function ( event, variation ) {
4056			if($(document).find(".woocommerce .kapee-quick-buy").length){
4057				$(document).find(".kapee_quick_buy_button").removeClass('disabled');
4058			}
4059		} ); 
4060		$(document).find( ".variations_form" ).on( "woocommerce_variation_select_change", function () {
4061			
4062			if (kapee_options.disable_variation_price_change) {
4063				return;
4064			}
4065			$(document).find( ".single_variation_wrap" ).on( "show_variation", function ( event, variation ) {
4066				var sell_price = variation.display_price,
4067				regular_price = variation.display_regular_price,
4068				formate_sell_price,
4069				formate_regular_price,
4070				total = 0,
4071				discount_per = 0,
4072				discount = regular_price - sell_price,
4073				formate_discount,
4074				price_html = variation.price_html,
4075				test_var = 1;				
4076				
4077				formate_sell_price = window.kapeePublic.kapee_formated_price(sell_price, kapee_options.price_thousand_separator,
4078				kapee_options.price_decimal_separator, kapee_options.price_decimals, 
4079				kapee_options.currency_symbol,kapee_options.price_format);
4080				
4081				formate_regular_price = window.kapeePublic.kapee_formated_price(regular_price, kapee_options.price_thousand_separator,
4082				kapee_options.price_decimal_separator, kapee_options.price_decimals, 
4083				kapee_options.currency_symbol,kapee_options.price_format);
4084				
4085				formate_discount = window.kapeePublic.kapee_formated_price(discount, kapee_options.price_thousand_separator,
4086				kapee_options.price_decimal_separator, kapee_options.price_decimals, 
4087				kapee_options.currency_symbol,kapee_options.price_format);
4088				
4089				if( sell_price != regular_price ){
4090					$(document).find('.woocommerce div.entry-summary .product-price-discount').show();
4091					$(document).find('.product-price-summary .discount').show();
4092					$(document).find('.product-price-summary .overall-discount').show();
4093					discount_per = Math.round( ((regular_price - sell_price)/regular_price) * 100 );
4094					$(document).find('.woocommerce div.entry-summary > p.price').html('<ins>' + formate_sell_price  + '</ins><del> ' + formate_regular_price + '</del>');
4095					$(document).find('.woocommerce div.entry-summary .product-price-discount .on-sale span').html( discount_per);
4096					$(document).find('.product-price-summary .regular-price > span').html( formate_regular_price);
4097					$(document).find('.product-price-summary .selling-price span').html( formate_sell_price);
4098					$(document).find('.product-price-summary .discount span').html( discount_per +'%');
4099					$(document).find('.product-price-summary .total-discount span').html( formate_sell_price);
4100					$(document).find('.product-price-summary .overall-discount .amount-discount').html( formate_discount);
4101					$(document).find('.product-price-summary .overall-discount .percentage-discount').html( '(' + discount_per + '%)');
4102				}else{
4103					$(document).find('.woocommerce div.entry-summary > p.price').html(formate_regular_price);
4104					$(document).find('.product-price-summary .regular-price > span').html( formate_regular_price);
4105					$(document).find('.product-price-summary .selling-price span').html( formate_regular_price);
4106					$(document).find('.product-price-summary .total-discount span').html( formate_regular_price);
4107					$(document).find('.woocommerce div.entry-summary .product-price-discount').hide();
4108					$(document).find('.product-price-summary .discount').hide();
4109					$(document).find('.product-price-summary .overall-discount').hide();
4110				}
4111				
4112			} );
4113		} );
4114	}
4115	
4116	kapee.wcfm_vendor = function(){
4117		//*******************************************************************
4118		//* WCFM Vendor
4119		//*******************************************************************/
4120		if ($('#_kp_product_ids').length <= 0) {
4121            return false;
4122        }
4123        if (typeof $wcfm_product_select_args === 'undefined') {
4124            return false;
4125        }
4126
4127        $('#_kp_product_ids').select2($wcfm_product_select_args);
4128	};
4129	
4130	kapee.MiniCartUpdateQuantity = function(){
4131		/* Update Minicart item quantity */
4132		$(document).on('change', '.woocommerce-mini-cart .qty', function(){
4133			var quantity = parseFloat($(this).val());
4134			var max = parseFloat($(this).attr('max'));
4135			if( max !== 'NaN' && max < quantity ){
4136				quantity = max;
4137				$(this).val( max );
4138			}
4139			
4140			$(this).parents('.woocommerce-mini-cart-item').addClass('loading');
4141			var cart_item_key = $(this).parents('.woocommerce-mini-cart-item').attr('data-cart_item_key');
4142			
4143			var data = {
4144				quantity: quantity,
4145				cart_item_key: cart_item_key,
4146				nonce: kapee_options.nonce,
4147				action: 'kapee_update_cart_widget_quantity',
4148			};
4149			$.ajax({
4150				url: kapee_options.ajax_url,
4151				data: data,
4152				dataType: 'json',
4153				method: 'POST',
4154				success: function (response) {
4155					if( !response ){
4156						return;
4157					}
4158					$(document.body).trigger('wc_fragment_refresh');					
4159				}				
4160			});
4161		});
4162	};
4163	
4164	kapee.autoCartUpdate = function(){
4165		if( ! kapee_options.cart_auto_update || $('.woocommerce-cart-form').length <= 0){
4166			return;
4167		}
4168		$(document).on('change','.woocommerce-cart-form .product-quantity',function(e) {
4169			$("[name='update_cart']").removeAttr('disabled');
4170			$("[name='update_cart']").trigger("click"); 
4171        });
4172	};
4173	
4174	kapee.checkoutUpdateQuantity = function(){
4175		
4176		/* Update Minicart item quantity */
4177		
4178		if( ! kapee_options.checkout_product_quantity || $('.woocommerce-checkout-review-order-table').length <= 0){
4179			return;
4180		}
4181		
4182		$(document).on('change', '.woocommerce-checkout-review-order-table .qty', function(){
4183			var $form = $( 'form.checkout' );
4184			var form_data =  $( 'form.checkout' ).serialize();
4185			$(".woocommerce-checkout-payment, .woocommerce-checkout-review-order-table").block({
4186                message: null,
4187                overlayCSS: {
4188                    opacity: 0.6
4189                }
4190            })						
4191			var data = {
4192				action 		: 'kapee_update_checkout_quantity',
4193				form_data 	: form_data,
4194				nonce		: kapee_options.nonce,
4195			};
4196			$.ajax({
4197				url: kapee_options.ajax_url,
4198				data: data,
4199				dataType: 'json',
4200				method: 'POST',
4201				success: function (response) {
4202					if( !response ){
4203						location.reload();
4204					}
4205					$.each( response.fragments, function( key, value ) {
4206						$( key ).replaceWith( value );
4207					});			
4208					$( 'body' ).trigger( 'update_checkout' );
4209				},
4210				error: function (jqXHR, exception) {
4211					console.log("Error: Something went wrong.");
4212					$(".woocommerce-checkout-payment, .woocommerce-checkout-review-order-table").unblock();
4213				}
4214			});
4215		});
4216	};
4217	
4218	kapee.getVisitorCount = function(){
4219		
4220		var min,max,delay;
4221		var visitor_elm = $('.kapee-visitor-change');
4222		if(  visitor_elm.length <= 0){
4223			return;
4224		}
4225		min 	= parseInt( visitor_elm.data('min') );
4226		max 	= parseInt( visitor_elm.data('max') );
4227		delay 	= parseInt( visitor_elm.data('delay') );
4228		setInterval(function() {
4229		  var variation = kapeeGetRandomInt(min, max );
4230		  visitor_elm.find('.product-visitor-count').html(variation);
4231		}, delay * 1000 );
4232		function kapeeGetRandomInt(min, max) {			
4233			let difference = max - min;
4234			let rand = Math.random();
4235			rand = Math.floor( rand * difference);
4236			rand = rand + min;
4237			return rand;
4238		}
4239	}
4240	
4241	kapee.askQuestionsForm = function(){
4242		
4243		var ask_questions_form = $('.kapee-ask-questions-ajax');
4244		if(  ask_questions_form.length <= 0){
4245			return;
4246		}
4247		$('.kapee-ask-questions').magnificPopup({
4248			type: 'inline',
4249			preloader: false,			
4250			removalDelay: 500,
4251			items: {
4252				src: '#kapee-ask-questions-popup' ,					
4253			},
4254			/* mainClass: 'animated bounceIn', */
4255			callbacks: {
4256				open: function() {
4257					var closeSidebar 	= $('.kapee-mask-overaly');
4258					var mobileSidebar = $('.kapee-mobile-menu');
4259					closeSidebar.removeClass('opened');
4260					mobileSidebar.removeClass('opened');
4261					$('.kapee-ask-questions-popup').addClass('animate__animated animate__fadeInLeft');
4262				},
4263				beforeClose: function() {
4264						var popupWrap = $( '.kapee-ask-questions-popup' );
4265						popupWrap.removeClass('animate__fadeInLeft').addClass('animate__fadeOutRight');
4266					}, 
4267				close: function() {
4268					$('.kapee-ask-questions-popup').removeClass('animate__animated animate__fadeOutRight');
4269				}
4270			} 
4271		});
4272		
4273	}
4274	
4275	kapee.kapeeEqualTabsHeight = function(){
4276		//*******************************************************************
4277		//* Equal tabs height
4278		//*******************************************************************/
4279		setTimeout(function () {
4280			$('.products-tab-content').each(function () {
4281				var $this = $(this);
4282				if ($this.find('.tab-content').length) {
4283					$this.find('.tab-content').css({
4284						'height': 'auto'
4285					});
4286					var elem_height = 0;
4287					$this.find('.tab-content').each(function () {
4288						var this_elem_h = $(this).height();
4289						if (elem_height < this_elem_h) {
4290							elem_height = this_elem_h;
4291						}
4292					});
4293					$this.find('.tab-content').height(elem_height);
4294				}
4295			});
4296		}, 4000);
4297	};
4298	
4299	kapee.kapeeTabEffect = function() {
4300		// effect click
4301		$(document).on('click', '.products-tabs .nav-tabs a', function (event) {
4302			
4303			var tab_id = $(this).attr('href');
4304			var tab_animated = 'animate__fadeInUp';
4305			tab_animated = ( tab_animated == undefined || tab_animated == "" ) ? '' : tab_animated;
4306			if (tab_animated == "") {
4307				return false;
4308			}
4309			$(tab_id).find('.owl-item.active').each(function (i) {
4310				
4311				var t = $(this);
4312				var style = $(this).attr("style");
4313				var defaultcss = $(this).attr('default-style');
4314				style = ( style == undefined ) ? '' : style;
4315				if(defaultcss == undefined ){
4316					$(this).attr('default-style',style);
4317				}else{
4318					style = $(this).attr('default-style');
4319				}
4320				var delay = i * 100;
4321				t.attr("style", style +
4322					";-webkit-animation-delay:" + delay + "ms;"
4323					+ "-moz-animation-delay:" + delay + "ms;"
4324					+ "-o-animation-delay:" + delay + "ms;"
4325					+ "animation-delay:" + delay + "ms;"
4326				).addClass(tab_animated + ' animate__animated').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
4327					t.removeClass(tab_animated + ' animate__animated');
4328					t.attr("style", style);
4329				});
4330			});
4331			$(tab_id).addClass('active').siblings().removeClass('active');
4332		});
4333	}
4334	
4335	kapee.kapeeAjaxTab = function() {
4336		// Ajax tabs
4337		$(document).on('click', '.products-tab-container [data-ajax="1"]', function (event) {
4338			
4339			var datasource = $(this).data('datasource');
4340			var limit = $(this).data('limit');
4341			var slider_data = $(this).data('slider_data');
4342			var tab_id = $(this).attr('href');
4343			var current_tab = $(this);
4344			var data = {
4345				action      :  'kapee_get_products_tab_data',
4346				nonce    	:   kapee_options.nonce,
4347				datasource  :   datasource,
4348				limit  		:   limit,
4349				slider_data	:   slider_data,
4350			};
4351			
4352			var container = $(this).closest('.products-tab-container').find('.tab-content');
4353			
4354			$.post(kapee_options.ajax_url, data, function(response){
4355				var items = $( '' + response['html'] + '' );
4356				
4357				container.html(items);
4358				kapee.kapeeOwlCarousel();
4359			});
4360		});
4361	}
4362	
4363	kapee.kapeeResponsiveTab = function() {
4364		// Responsive tabs
4365		$(document).on('click', '[data-trigger="tab"]', function (event) {
4366			var href = $( this ).attr( 'href' );
4367			event.preventDefault();
4368			$( '[data-toggle="tab"][href="' + href + '"]' ).trigger( 'click' );
4369		} );
4370
4371	}
4372	
4373	kapee.kapeeProgressbar = function() {
4374		/*
4375		* Progress Bar
4376		*/		
4377		$('.progress .progress-bar').each(function(){
4378			if (typeof ($.fn.waypoint) != 'undefined') {
4379				$(this).waypoint(function(){
4380					var width = $(this).attr('data-value');
4381					$(this).animate({
4382							width: width+'%'
4383						},
4384						{
4385							duration: 1000,
4386							easing: 'swing'
4387						}
4388					);
4389				}, { offset: '100%', triggerOnce: true });
4390			}
4391		});	
4392	}
4393	
4394	kapee.kapeeCounterUp = function() {
4395		/*
4396		* Counter Up
4397		*/	
4398		if ( ! $.isFunction($.fn.counterUp) ) {
4399			return;
4400		}
4401		jQuery('.counter').counterUp({
4402            delay: 20,
4403            time: 2000
4404        });
4405	}
4406	
4407	kapee.imageGaleryMasonry = function (){
4408		
4409		/*
4410		* Image Gallery Masonry
4411		*/
4412		
4413		if ( ! $('.kapee-image-gallery.image-gallery-masonry-grid').length > 0 ) return;
4414		var $layoutMode='masonry';
4415		
4416		if($( '.kapee-image-gallery.image-gallery-masonry-grid' ).length){
4417			$( '.kapee-image-gallery.image-gallery-masonry-grid' ).each(function(){
4418				
4419				var image_gallery_container = $( this );
4420				// initialize Masonry after all images have loaded
4421                image_gallery_container.imagesLoaded(function() {
4422					image_gallery_container.isotope({
4423						itemSelector: '.kapee-gallery',
4424						isOriginLeft: ! $('body').hasClass('rtl'),
4425						layoutMode: $layoutMode
4426					});
4427				 });
4428			});			
4429		}		
4430	};
4431	
4432	kapee.BackgroundParallax = function(){
4433		/*
4434		* Parallax Background
4435		*/		
4436		if ($(window).width() <= 1024) {
4437			return;
4438		}
4439		$('.kapee-parallax-background').each(function() {
4440			var $this = $(this);
4441			if ($this.hasClass('wpb_column')) {
4442				$this.find('> .vc_column-inner').parallax("50%", 0.3);
4443			} else {
4444				$this.parallax("50%", 0.3);
4445			}
4446		});
4447	};
4448	
4449	/*
4450	 * Document ready
4451	 */ 
4452	$(document).ready(function(){ 
4453		kapee.init();		
4454    });
4455	
4456	$(document).ready(function(){ 
4457		$(window).on('vc_reload', function () {
4458           kapee.init();            
4459        });	
4460    });
4461	
4462	$( window ).on('load', function () {
4463		var kapee_pre_loader = $( '.kapee-site-preloader' );
4464		if ( kapee_pre_loader.length ) {
4465            kapee_pre_loader.fadeOut( 800 );
4466		}
4467	});
4468	
4469	window.kapeePublic = {
4470		kapee_formated_price: function(number, thousand_sep, decimal_sep, tofixed, symbol, woo_price_format){
4471			var before_text = '';
4472			var after_text = '';
4473			number = number || 0;
4474			tofixed = !isNaN(tofixed = Math.abs(tofixed)) ? tofixed : 2;
4475			symbol = symbol !== undefined ? symbol : "$";
4476			thousand_sep = thousand_sep || ",";
4477			decimal_sep = decimal_sep || ".";
4478			var negative = number < 0 ? "-" : "",
4479					i = parseInt(number = Math.abs(+number || 0).toFixed(tofixed), 10) + "",
4480					j = (j = i.length) > 3 ? j % 3 : 0;
4481
4482			symbol = '<span class="woocommerce-Price-currencySymbol">' + symbol + '</span>';
4483
4484			switch (woo_price_format) {
4485				case '%1$s%2$s':
4486					//left
4487					before_text += symbol;
4488					break;
4489				case '%1$s %2$s':
4490					//left with space
4491					before_text += symbol + ' ';
4492					break;
4493				case '%2$s%1$s':
4494					//right
4495					after_text += symbol;
4496					break;
4497				case '%2$s %1$s':
4498					//right with space
4499					after_text += ' ' + symbol;
4500					break;
4501				default:
4502					//default
4503					before_text += symbol;
4504			}
4505
4506			var woo_price_return = before_text +
4507					negative + (j ? i.substr(0, j) + thousand_sep : "" ) +
4508					i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand_sep) +
4509					(tofixed ? decimal_sep + Math.abs(number - i).toFixed(tofixed).slice(2) : "") +
4510					after_text;
4511
4512			woo_price_return = '<span class="woocommerce-Price-amount amount">' + woo_price_return + '</span>';
4513
4514			return woo_price_return;
4515		}
4516	}
4517	
4518})(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.