;(function($){
"use strict";
var WooLentorQuickView={
body: $('body'),
modal: $('#woolentor-quickview-modal'),
modalbody: $('.woolentor-quickview-modal-body'),
init: function(){
this.wrapperHeight();
$(document)
.on('click.WooLentorQuickView', 'a.woolentor-quickview-btn,.woolentorquickview', this.openQuickView)
.on('click.WooLentorQuickView', '.woolentor-quickview-modal-close', this.closeQuickView)
.on('click.WooLentorQuickView', '.woolentor-quickview-overlay', this.closeQuickView);
$(document).keyup(this.closeKeyUp);
if(woolentorQuickView.optionData['enableAjaxCart']==='on'){
$(document).on('click.WooLentorQuickView', '.woolentor-quickview-modal-content .woolentorquickview-content-template:not(.external) .single_add_to_cart_button:not(.disabled)', this.addToCart);
}},
openQuickView: function(event){
event.preventDefault();
var $this=$(this),
id=$this.data('product_id');
WooLentorQuickView.modalbody.html(''); 
WooLentorQuickView.body.addClass('woolentor-quickview-loader');
if(woolentorQuickView?.optionData?.spinnerImageUrl.length > 0){
WooLentorQuickView.body.css('--woolentor-quick-view-spinner-image', 'url(' + woolentorQuickView?.optionData?.spinnerImageUrl + ')');
}
$this.addClass('loading');
WooLentorQuickView.modal.addClass('loading');
$.ajax({
url: woolentorQuickView.ajaxUrl,
data: {
action: 'woolentor_quickview',
id: id,
nonce: woolentorQuickView.ajaxNonce,
},
method: 'POST',
success: function (response){
if(response){
WooLentorQuickView.body.removeClass('woolentor-quickview-loader');
WooLentorQuickView.modal.removeClass('loading').addClass('woolentor-quickview-open');
$this.removeClass('loading');
WooLentorQuickView.modalbody.html(response);
WooLentorQuickView.variation(WooLentorQuickView.modalbody);
$(document).trigger('woolentor_quick_view_rendered');
if(woolentorQuickView.optionData['thumbnailLayout']==='slider'){
WooLentorQuickView.imageSlider();
}}else{
console.log('Something wrong loading fetching product data');
}},
error: function (response){
console.log('Something wrong with AJAX response.');
},
complete: function (){
$this.removeClass('loading');
},
});
},
variation: function($container){
var $formvariation=$container.find('.variations_form');
$formvariation.each(function(){
$(this).wc_variation_form();
});
$formvariation.trigger('check_variations');
$formvariation.trigger('reset_image');
if(typeof $.fn.wc_product_gallery!=='undefined'){
$container.find('.woocommerce-product-gallery').each(function (){
$(this).wc_product_gallery();
});
}
if(woolentorQuickView.optionData['thumbnailLayout']==='slider'){
WooLentorQuickView.variationData($container);
}},
variationData: function($product){
$('.single_variation_wrap').on('show_variation', function(event, variation){
$product.find('.woolentor-quickview-main-image-slider').slick('slickGoTo', 0);
});
},
closeQuickView: function(event){
event.preventDefault();
WooLentorQuickView.modal.removeClass('woolentor-quickview-open');
},
closeKeyUp: function(event){
if(event.keyCode===27){
WooLentorQuickView.modal.removeClass('woolentor-quickview-open');
}},
wrapperHeight: function(){
var window_width=$(window).width(),
window_height=$(window).height();
$('.woolentor-quickview-modal-wrapper').css({"max-height":(window_height-150)+"px"});
},
MainImageSlider: function(){
$('.woolentor-quickview-main-image-slider').slick({
slidesToShow: 1,
slidesToScroll: 1,
arrows: true,
fade: true,
asNavFor: '.woolentor-quickview-thumbnail-slider',
prevArrow: '<span class="woolentor-quickview-slick-prev">&#8592;</span>',
nextArrow: '<span class="woolentor-quickview-slick-next">&#8594;</span>',
});
},
ThumbnailSlider: function(){
$('.woolentor-quickview-thumbnail-slider').slick({
slidesToShow: 4,
slidesToScroll: 1,
asNavFor: '.woolentor-quickview-main-image-slider',
dots: false,
arrows: true,
focusOnSelect: true,
prevArrow: '<span class="woolentor-quickview-slick-prev">&#8592;</span>',
nextArrow: '<span class="woolentor-quickview-slick-next">&#8594;</span>',
});
},
imageSlider: function(){
this.MainImageSlider();
this.ThumbnailSlider();
},
addToCart: function(event){
event.preventDefault();
var $this=$(this),
$form=$this.closest('form.cart'),
all_data=$form.serialize(),
product_qty=$form.find('input[name=quantity]').val()||1,
product_id=$form.find('input[name=product_id]').val()||$this.val(),
variation_id=$form.find('input[name=variation_id]').val()||0;
var item={},
variations=$form.find('select[name^=attribute]');
if(!variations.length){
variations=$form.find('[name^=attribute]:checked');
}
if(!variations.length){
variations=$form.find('input[name^=attribute]');
}
variations.each(function(){
var $thisitem=$(this),
attributeName=$thisitem.attr('name'),
attributevalue=$thisitem.val(),
index,
attributeTaxName;
$thisitem.removeClass('error');
if(attributevalue.length===0){
index=attributeName.lastIndexOf('_');
attributeTaxName=attributeName.substring(index + 1);
$thisitem.addClass('required error');
}else{
item[attributeName]=attributevalue;
}});
var data={
product_id: product_id,
product_sku: '',
quantity: product_qty,
variation_id: variation_id,
variations: item,
all_data: all_data,
};
var alldata=data.all_data + '&product_id='+ data.product_id + '&product_sku='+ data.product_sku + '&quantity='+ data.quantity + '&variation_id='+ data.variation_id + '&variations='+ JSON.stringify(data.variations) +'&action=woolentor_quickview_insert_to_cart' +'&nonce='+woolentorQuickView.ajaxNonce;
$(document.body).trigger('adding_to_cart', [$this, data]);
$.ajax({
type: 'POST',
url: woolentorQuickView.ajaxUrl,
data: alldata,
beforeSend: function (response){
$this.removeClass('added').addClass('loading');
},
complete: function (response){
$this.addClass('added').removeClass('loading');
},
success: function (response){
if(response.error & response.product_url){
window.location=response.product_url;
return;
}else{
$(document.body).trigger('wc_fragment_refresh');
$(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $this]);
}},
});
}};
$(document).ready(function(){
WooLentorQuickView.init();
$(window).on('resize', WooLentorQuickView.wrapperHeight);
});
})(jQuery);
!function(t,e){"object"==typeof module&&module.exports?module.exports=e():t.EvEmitter=e()}("undefined"!=typeof window?window:this,(function(){function t(){}let e=t.prototype;return e.on=function(t,e){if(!t||!e)return this;let i=this._events=this._events||{},s=i[t]=i[t]||[];return s.includes(e)||s.push(e),this},e.once=function(t,e){if(!t||!e)return this;this.on(t,e);let i=this._onceEvents=this._onceEvents||{};return(i[t]=i[t]||{})[e]=!0,this},e.off=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;let s=i.indexOf(e);return-1!=s&&i.splice(s,1),this},e.emitEvent=function(t,e){let i=this._events&&this._events[t];if(!i||!i.length)return this;i=i.slice(0),e=e||[];let s=this._onceEvents&&this._onceEvents[t];for(let n of i){s&&s[n]&&(this.off(t,n),delete s[n]),n.apply(this,e)}return this},e.allOff=function(){return delete this._events,delete this._onceEvents,this},t})),
function(t,e){"object"==typeof module&&module.exports?module.exports=e(t,require("ev-emitter")):t.imagesLoaded=e(t,t.EvEmitter)}("undefined"!=typeof window?window:this,(function(t,e){let i=t.jQuery,s=t.console;function n(t,e,o){if(!(this instanceof n))return new n(t,e,o);let r=t;var h;("string"==typeof t&&(r=document.querySelectorAll(t)),r)?(this.elements=(h=r,Array.isArray(h)?h:"object"==typeof h&&"number"==typeof h.length?[...h]:[h]),this.options={},"function"==typeof e?o=e:Object.assign(this.options,e),o&&this.on("always",o),this.getImages(),i&&(this.jqDeferred=new i.Deferred),setTimeout(this.check.bind(this))):s.error(`Bad element for imagesLoaded ${r||t}`)}n.prototype=Object.create(e.prototype),n.prototype.getImages=function(){this.images=[],this.elements.forEach(this.addElementImages,this)};const o=[1,9,11];n.prototype.addElementImages=function(t){"IMG"===t.nodeName&&this.addImage(t),!0===this.options.background&&this.addElementBackgroundImages(t);let{nodeType:e}=t;if(!e||!o.includes(e))return;let i=t.querySelectorAll("img");for(let t of i)this.addImage(t);if("string"==typeof this.options.background){let e=t.querySelectorAll(this.options.background);for(let t of e)this.addElementBackgroundImages(t)}};const r=/url\((['"])?(.*?)\1\)/gi;function h(t){this.img=t}function d(t,e){this.url=t,this.element=e,this.img=new Image}return n.prototype.addElementBackgroundImages=function(t){let e=getComputedStyle(t);if(!e)return;let i=r.exec(e.backgroundImage);for(;null!==i;){let s=i&&i[2];s&&this.addBackground(s,t),i=r.exec(e.backgroundImage)}},n.prototype.addImage=function(t){let e=new h(t);this.images.push(e)},n.prototype.addBackground=function(t,e){let i=new d(t,e);this.images.push(i)},n.prototype.check=function(){if(this.progressedCount=0,this.hasAnyBroken=!1,!this.images.length)return void this.complete();let t=(t,e,i)=>{setTimeout((()=>{this.progress(t,e,i)}))};this.images.forEach((function(e){e.once("progress",t),e.check()}))},n.prototype.progress=function(t,e,i){this.progressedCount++,this.hasAnyBroken=this.hasAnyBroken||!t.isLoaded,this.emitEvent("progress",[this,t,e]),this.jqDeferred&&this.jqDeferred.notify&&this.jqDeferred.notify(this,t),this.progressedCount===this.images.length&&this.complete(),this.options.debug&&s&&s.log(`progress: ${i}`,t,e)},n.prototype.complete=function(){let t=this.hasAnyBroken?"fail":"done";if(this.isComplete=!0,this.emitEvent(t,[this]),this.emitEvent("always",[this]),this.jqDeferred){let t=this.hasAnyBroken?"reject":"resolve";this.jqDeferred[t](this)}},h.prototype=Object.create(e.prototype),h.prototype.check=function(){this.getIsImageComplete()?this.confirm(0!==this.img.naturalWidth,"naturalWidth"):(this.proxyImage=new Image,this.img.crossOrigin&&(this.proxyImage.crossOrigin=this.img.crossOrigin),this.proxyImage.addEventListener("load",this),this.proxyImage.addEventListener("error",this),this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.proxyImage.src=this.img.currentSrc||this.img.src)},h.prototype.getIsImageComplete=function(){return this.img.complete&&this.img.naturalWidth},h.prototype.confirm=function(t,e){this.isLoaded=t;let{parentNode:i}=this.img,s="PICTURE"===i.nodeName?i:this.img;this.emitEvent("progress",[this,s,e])},h.prototype.handleEvent=function(t){let e="on"+t.type;this[e]&&this[e](t)},h.prototype.onload=function(){this.confirm(!0,"onload"),this.unbindEvents()},h.prototype.onerror=function(){this.confirm(!1,"onerror"),this.unbindEvents()},h.prototype.unbindEvents=function(){this.proxyImage.removeEventListener("load",this),this.proxyImage.removeEventListener("error",this),this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},d.prototype=Object.create(h.prototype),d.prototype.check=function(){this.img.addEventListener("load",this),this.img.addEventListener("error",this),this.img.src=this.url,this.getIsImageComplete()&&(this.confirm(0!==this.img.naturalWidth,"naturalWidth"),this.unbindEvents())},d.prototype.unbindEvents=function(){this.img.removeEventListener("load",this),this.img.removeEventListener("error",this)},d.prototype.confirm=function(t,e){this.isLoaded=t,this.emitEvent("progress",[this,this.element,e])},n.makeJQueryPlugin=function(e){(e=e||t.jQuery)&&(i=e,i.fn.imagesLoaded=function(t,e){return new n(this,t,e).jqDeferred.promise(i(this))})},n.makeJQueryPlugin(),n}));