var EGallery=function(t){var e={};function i(n){if(e[n])return e[n].exports;var s=e[n]={i:n,l:!1,exports:{}};return t[n].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=e,i.d=function(t,e,n){i.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},i.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},i.t=function(t,e){if(1&e&&(t=i(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)i.d(n,s,function(e){return t[e]}.bind(null,s));return n},i.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return i.d(e,"a",e),e},i.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},i.p="",i(i.s=9)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}},function(t,e){function i(t,e){for(var i=0;i<e.length;i++){var n=e[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,n.key,n)}}t.exports=function(t,e,n){return e&&i(t.prototype,e),n&&i(t,n),t}},function(t,e,i){var n=i(5),s=i(6);t.exports=function(t,e){return!e||"object"!==n(e)&&"function"!=typeof e?s(t):e}},function(t,e){function i(e){return t.exports=i=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},i(e)}t.exports=i},function(t,e,i){var n=i(7);t.exports=function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&n(t,e)}},function(t,e){function i(t){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function n(t){return(n="function"==typeof Symbol&&"symbol"===i(Symbol.iterator)?function(t){return i(t)}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":i(t)})(t)}function s(e){return"function"==typeof Symbol&&"symbol"===n(Symbol.iterator)?t.exports=s=function(t){return n(t)}:t.exports=s=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":n(t)},s(e)}t.exports=s},function(t,e){t.exports=function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}},function(t,e){function i(e,n){return t.exports=i=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},i(e,n)}t.exports=i},function(t,e,i){},function(t,e,i){"use strict";i.r(e);var n=i(0),s=i.n(n),r=i(1),a=i.n(r),o=i(2),l=i.n(o),u=i(3),c=i.n(u),h=i(4),y=i.n(h);var g=function(){function t(e){var i=this;s()(this,t),this.settings=jQuery.extend(!0,this.getDefaultSettings(),e),this.$container=jQuery(this.settings.container),this.timeouts=[],this.initElements(),this.prepareGallery();var n=this.runGallery.bind(this);this.runGallery=this.debounce(function(){for(var t=arguments.length,e=new Array(t),s=0;s<t;s++)e[s]=arguments[s];i.settings.lazyLoad?n.apply(void 0,e):i.allImagesPromise.then(function(){return n.apply(void 0,e)})},300),this.settings.lazyLoad&&(this.handleScroll=this.debounce(function(){return i.lazyLoadImages()},16)),this.bindEvents(),this.runGallery()}return a()(t,[{key:"getDefaultSettings",value:function(){return{}}},{key:"getItemClass",value:function(t){return this.settings.classesPrefix+t}},{key:"initElements",value:function(){this.elements={$window:jQuery(window)};var t="-"+(this.settings.rtl?"rtl":"ltr"),e=this.getItemClass(this.settings.classes.container)+" "+this.getItemClass(this.settings.type)+" "+this.getItemClass(t);this.settings.lazyLoad&&(e+=" "+this.getItemClass(this.settings.classes.lazyLoad)),this.$container.addClass(e)}},{key:"bindEvents",value:function(){this.elements.$window.on("resize",this.runGallery),this.settings.lazyLoad&&this.elements.$window.on("scroll",this.handleScroll)}},{key:"getNestedObjectData",value:function(t,e){var i=e.split("."),n=i.splice(0,1);return i.length?this.getNestedObjectData(t[n],i.join(".")):{object:t,key:e}}},{key:"getTemplateArgs",value:function(t,e){var i=this.getNestedObjectData(t,e);return i.object[i.key]||""}},{key:"getCurrentBreakpoint",value:function(){var t=Object.keys(this.settings.breakpoints).map(Number).sort(function(t,e){return t-e}),e=0;return t.some(function(t){return innerWidth<t&&(e=t,!0)}),e}},{key:"getCurrentDeviceSetting",value:function(t){var e=this.getCurrentBreakpoint();return e?this.settings.breakpoints[e][t]:this.settings[t]}},{key:"getActiveItems",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=this.settings.tags,i=[];if(!e.length)return t?(this.$items.each(function(t){i.push(t)}),i):this.$items;var n=this.$items.filter(function(n,s){var r=s.dataset.eGalleryTags;return!!r&&(r=r.split(/[ ,]+/),!!e.some(function(t){return r.includes(t)})&&(t&&i.push(n),!0))});return t?i:n}},{key:"getImageData",value:function(t){return this.settings.tags.length&&(t=this.getActiveItems(!0)[t]),this.imagesData[t]}},{key:"compileTemplate",value:function(t,e){var i=this;return t.replace(/{{([^}]+)}}/g,function(t,n){return i.getTemplateArgs(e,n.trim())})}},{key:"createOverlay",value:function(t){var e=this.settings,i=e.classes,n=e.overlayTemplate,s=jQuery("<div>",{class:this.getItemClass(i.overlay)}),r=this.compileTemplate(n,jQuery.extend(!0,this.settings,t));return s.html(r),s}},{key:"createItem",value:function(t){var e,i=this.settings.classes,n=jQuery("<div>",{class:this.getItemClass(i.item),"data-e-gallery-tags":t.tags}),s=jQuery("<div>",{class:this.getItemClass(i.image)});this.settings.lazyLoad||s.css("background-image","url("+t.thumbnail+")"),this.settings.overlay&&(e=this.createOverlay(t));var r=n;return t.url&&(r=jQuery("<a>",{class:this.getItemClass(i.link),href:t.url}),n.html(r)),r.html(s),e&&r.append(e),n}},{key:"debounce",value:function(t,e){var i,n=this;return function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];clearTimeout(i),i=setTimeout(function(){return t.apply(void 0,r)},e),n.timeouts.push(i)}}},{key:"buildGallery",value:function(){var t=this,e=this.settings.items;this.$items=jQuery(),e.forEach(function(e){var i=t.createItem(e);t.$items=t.$items.add(i),t.$container.append(i)})}},{key:"loadImages",value:function(){var t=this,e=[];this.settings.items.forEach(function(i,n){var s=new Image,r=new Promise(function(t){s.onload=t});e.push(r),r.then(function(){return t.calculateImageSize(s,n)}),s.src=i.thumbnail}),this.allImagesPromise=Promise.all(e)}},{key:"lazyLoadImages",value:function(){var t=this;if(!this.lazyLoadComplete){var e=this.getActiveItems(),i=this.getActiveItems(!0);e.each(function(e,n){var s=t.settings.items[i[e]];if(s.loading||!function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"top",i=t.getBoundingClientRect().top,n=t.offsetHeight,s=i+n;return("middle"===e?i+n/2:"bottom"===e?s:i)<=innerHeight&&s>=0}(n))return!0;s.loading=!0;var r=jQuery(n),a=new Image;return new Promise(function(t){a.onload=t}).then(function(){r.find(t.settings.selectors.image).css("background-image",'url("'+s.thumbnail+'")').addClass(t.getItemClass(t.settings.classes.imageLoaded)),t.loadedItemsCount++,t.loadedItemsCount===t.settings.items.length&&(t.lazyLoadComplete=!0)}),a.src=s.thumbnail,!0})}}},{key:"calculateImageSize",value:function(t,e){this.imagesData[e]={width:t.width,height:t.height,ratio:t.width/t.height}}},{key:"createImagesData",value:function(){var t=this;this.settings.items.forEach(function(e,i){return t.calculateImageSize(e,i)})}},{key:"makeGalleryFromContent",value:function(){var t=this.settings.selectors,e=this.settings.lazyLoad,i=[];this.$items=this.$container.find(t.items),this.$items.each(function(n,s){var r=jQuery(s).find(t.image);i[n]={thumbnail:r.data("thumbnail")},e?(i[n].width=r.data("width"),i[n].height=r.data("height")):r.css("background-image",'url("'.concat(r.data("thumbnail"),'")'))}),this.settings.items=i}},{key:"prepareGallery",value:function(){this.settings.items?this.buildGallery():this.makeGalleryFromContent(),this.imagesData=[],this.settings.lazyLoad?(this.loadedItemsCount=0,this.lazyLoadComplete=!1,this.createImagesData()):this.loadImages()}},{key:"runGallery",value:function(t){var e=this,i=this.$container[0].style;i.setProperty("--hgap",this.getCurrentDeviceSetting("horizontalGap")+"px"),i.setProperty("--vgap",this.getCurrentDeviceSetting("verticalGap")+"px"),i.setProperty("--animation-duration",this.settings.animationDuration+"ms"),this.$items.addClass(this.getItemClass(this.settings.classes.hidden)),this.getActiveItems().removeClass(this.getItemClass(this.settings.classes.hidden)),this.settings.lazyLoad&&setTimeout(function(){return e.lazyLoadImages()},300),this.run(t)}},{key:"setSettings",value:function(t,e){var i=this.getNestedObjectData(this.settings,t);i.object&&(i.object[i.key]=e,this.runGallery(!0))}},{key:"unbindEvents",value:function(){this.elements.$window.off("resize",this.runGallery)}},{key:"destroy",value:function(){this.unbindEvents(),this.$container.empty(),this.timeouts.forEach(function(t){return clearTimeout(t)})}}]),t}(),f=function(t){function e(){return s()(this,e),l()(this,c()(e).apply(this,arguments))}return y()(e,t),a()(e,[{key:"getDefaultSettings",value:function(){return{aspectRatio:"16:9"}}},{key:"setItemsPosition",value:function(){var t=this.getCurrentDeviceSetting("columns");this.getActiveItems().each(function(e,i){i.style.setProperty("--column",e%t),i.style.setProperty("--row",Math.floor(e/t))})}},{key:"setContainerSize",value:function(){var t=this.getCurrentDeviceSetting("columns"),e=Math.ceil(this.getActiveItems().length/t),i=this.$container[0].style;i.setProperty("--columns",t),i.setProperty("--rows",e);var n=this.getActiveItems().width(),s=this.settings.aspectRatio.split(":"),r=s[1]/s[0],a=(r*n*e+this.getCurrentDeviceSetting("horizontalGap")*(e-1))/this.$container.width()*100;i.setProperty("--aspect-ratio",100*r+"%"),i.setProperty("--container-aspect-ratio",a+"%")}},{key:"run",value:function(){var t=this,e=this.getItemClass(this.settings.classes.animated);this.$container.addClass(e),setTimeout(function(){t.setItemsPosition(),t.setContainerSize(),setTimeout(function(){return t.$container.removeClass(e)},t.settings.animationDuration)},50)}}]),e}(g),m=function(t){function e(){return s()(this,e),l()(this,c()(e).apply(this,arguments))}return y()(e,t),a()(e,[{key:"getDefaultSettings",value:function(){return{idealRowHeight:200,lastRow:"auto",breakpoints:{1024:{idealRowHeight:150},768:{idealRowHeight:100}}}}},{key:"run",value:function(){this.rowsHeights=[],this.rowsCount=0,this.containerWidth=this.$container.width(),this.makeJustifiedRow(0)}},{key:"makeJustifiedRow",value:function(t){for(var e=0,i=t;;i++){var n=this.getImageData(i),s=Math.round(this.getCurrentDeviceSetting("idealRowHeight")*n.ratio);s>this.containerWidth&&(s=this.containerWidth);var r=e+s;if(r>this.containerWidth)if(this.containerWidth-e<r-this.containerWidth){this.fitImagesInContainer(t,i,e),this.rowsCount++,this.makeJustifiedRow(i);break}var a=i===this.getActiveItems().length-1;if(n.computedWidth=s,a){var o=this.getCurrentDeviceSetting("lastRow");if("hide"!==o){var l="fit"===o||.7<=r/this.containerWidth?r:this.containerWidth;this.fitImagesInContainer(t,i+1,l)}this.inflateGalleryHeight();break}e=r}}},{key:"fitImagesInContainer",value:function(t,e,i){for(var n=e-t-1,s=this.getActiveItems(),r=0,a=t;a<e;a++){var o=this.getImageData(a),l=o.computedWidth/i,u=s.get(a),c=this.getItemClass(this.settings.classes.firstRowItem);if(u.style.setProperty("--item-width",l),u.style.setProperty("--gap-count",n),u.style.setProperty("--item-height",o.height/o.width*100+"%"),u.style.setProperty("--item-start",r),u.style.setProperty("--item-row-index",a-t),r+=l,a===t){u.classList.add(c);var h=l*(this.containerWidth-n*this.getCurrentDeviceSetting("horizontalGap"));this.rowsHeights.push(h/o.ratio)}else u.classList.remove(c)}}},{key:"inflateGalleryHeight",value:function(){var t=this.rowsHeights.reduce(function(t,e){return t+e})+this.rowsCount*this.getCurrentDeviceSetting("verticalGap"),e=t/this.containerWidth,i=this.rowsHeights.map(function(e){return e/t*100}),n=-1,s=0;this.getActiveItems().each(function(t,e){"0"===e.style.getPropertyValue("--item-row-index")&&++n&&(s+=i[n-1]),e.style.setProperty("--item-top",s+"%"),e.style.setProperty("--item-height",i[n]+"%"),e.style.setProperty("--row",n)}),this.$container[0].style.setProperty("--container-aspect-ratio",e)}}]),e}(g),d=function(t){function e(){return s()(this,e),l()(this,c()(e).apply(this,arguments))}return y()(e,t),a()(e,[{key:"run",value:function(t){var e=this,i=this.getCurrentBreakpoint();if(t||i!==this.currentBreakpoint){this.currentBreakpoint=i;for(var n=[],s=[],r=[],a=this.getCurrentDeviceSetting("columns"),o=this.$container.width(),l=(o-this.getCurrentDeviceSetting("horizontalGap")*(a-1))/a,u=this.getActiveItems(),c=0,h=0;h<a;h++)s[h]=0,n[h]=0;u.each(function(t,i){var o=e.getImageData(t),u=l/o.ratio,h=t%a;c=n[h],jQuery.each(n,function(t,e){e&&c>e+5&&(c=e,h=t)}),r[t]=n[h],n[h]+=u,i.style.setProperty("--item-height",o.height/o.width*100+"%"),i.style.setProperty("--column",h),i.style.setProperty("--items-in-column",s[h]),s[h]++});var y=Math.max.apply(Math,n),g=n.indexOf(y),f=s[g]-1,m=y/o;this.$container[0].style.setProperty("--columns",a),this.$container[0].style.setProperty("--highest-column-gap-count",f),this.$container.css("padding-bottom",100*m+"%"),u.each(function(t,e){var i=r[t]?r[t]/y*100:0;e.style.setProperty("--percent-height",i+"%")})}}}]),e}(g);i(8);i.d(e,"default",function(){return p});var p=function(){function t(e){s()(this,t),this.userSettings=e,this.initGalleriesTypes(),this.createGallery()}return a()(t,[{key:"getDefaultSettings",value:function(){return{container:null,items:null,type:"grid",tags:[],overlay:!1,overlayTemplate:'<div class="{{ classesPrefix }}{{ classes.overlayTitle }}">{{ title }}</div><div class="{{ classesPrefix }}{{ classes.overlayDescription }}">{{ description }}</div>',columns:5,horizontalGap:10,verticalGap:10,rtl:!1,animationDuration:350,lazyLoad:!1,classesPrefix:"e-gallery-",classes:{container:"container",item:"item",image:"image",overlay:"overlay",overlayTitle:"overlay__title",overlayDescription:"overlay__description",link:"link",firstRowItem:"first-row-item",animated:"-animated",hidden:"item--hidden",lazyLoad:"-lazyload",imageLoaded:"image-loaded"},selectors:{items:".e-gallery-item",image:".e-gallery-image"},breakpoints:{1024:{horizontalGap:5,verticalGap:5,columns:4},768:{horizontalGap:1,verticalGap:1,columns:2}}}}},{key:"initGalleriesTypes",value:function(){this.galleriesTypes={grid:f,justified:m,masonry:d}}},{key:"createGallery",value:function(){var t=jQuery.extend(this.getDefaultSettings(),this.userSettings),e=this.galleriesTypes[t.type];this.galleryHandler=new e(t)}},{key:"setSettings",value:function(t,e){this.galleryHandler.setSettings(t,e)}},{key:"destroy",value:function(){this.galleryHandler.destroy()}}]),t}()}]).default;
!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}));
jQuery(document).ready(function($){
var isCartPage=xoo_wsc_params.isCart=='1',
isCheckoutPage=xoo_wsc_params.isCheckout=='1';
var get_wcurl=function(endpoint){
return xoo_wsc_params.wc_ajax_url.toString().replace('%%endpoint%%',
endpoint
);
};
var markupTimeout=null;
class Notice{
constructor($modal){
this.$modal=$modal;
this.timeout=null;
}
add(notice, type='success', clearPrevious=true){
var $noticeCont=this.$modal.find('.xoo-wsc-notice-container');
if(clearPrevious){
$noticeCont.html('');
}
var noticeHTML=type==='success' ? xoo_wsc_params.html.successNotice.toString().replace('%s%', notice):xoo_wsc_params.html.errorNotice.toString().replace('%s%', notice);
$noticeCont.html(noticeHTML);
}
showNotification(){
Notice.showMarkupNotice();
var $noticeCont=this.$modal.find('.xoo-wsc-notice-container');
if(!$noticeCont.length||$noticeCont.children().length===0) return;
$noticeCont.slideDown();
clearTimeout(this.timeout);
this.timeout=setTimeout(function(){
$noticeCont.slideUp('slow',function(){
});
},xoo_wsc_params.notificationTime)
}
hideNotification(){
this.$modal.find('.xoo-wsc-notice-container').hide();
}
static hideMarkupNotice(){
Notice.$noticeContainer().removeClass('xoo-wsc-active');
}
static $noticeContainer(){
return $('.xoo-wsc-markup-notices')
}
static showMarkupNotice(){
if(cart.isOpen()) return;
var $markupNotice=Notice.$noticeContainer();
var $notices=$markupNotice.find('.xoo-wsc-notice-container .xoo-wsc-notices');
if(!$notices.length||$notices.children().length===0) return;
setTimeout(function(){$markupNotice.addClass('xoo-wsc-active')},10);
clearTimeout(markupTimeout);
markupTimeout=setTimeout(function(){
$markupNotice.removeClass('xoo-wsc-active');
},xoo_wsc_params.notificationTime)
}}
class Container{
constructor($modal, container){
this.$modal=$modal;
this.container=container||'cart';
this.notice=new Notice(this.$modal);
}
isOpen(){
return this.$modal.hasClass('xoo-wsc-'+this.container+'-active');
}
eventHandlers(){
$(document.body).on('wc_fragments_refreshed updated_checkout', this.onCartUpdate.bind(this));
}
onCartUpdate(){
this.unblock();
this.notice.showNotification();
}
setAjaxData(data, noticeSection){
var ajaxData={
container: this.container,
noticeSection: noticeSection||this.noticeSection||this.container,
isCheckout: isCheckoutPage,
isCart: isCartPage
}
if(typeof data==='object'){
$.extend(ajaxData, data);
}else{
var serializedData=data;
$.each(ajaxData, function(key, value){
serializedData +=('&'+key+'='+value);
})
ajaxData=serializedData;
}
return ajaxData;
}
toggle(type){
var $activeEls=this.$modal.add('body').add('html'),
activeClass='xoo-wsc-'+ this.container +'-active';
if(type==='show'){
$activeEls.addClass(activeClass);
}
else if(type==='hide'){
$activeEls.removeClass(activeClass);
}else{
$activeEls.toggleClass(activeClass);
}
$(document.body).trigger('xoo_wsc_' + this.container + '_toggled', [ type ]);
this.notice.hideNotification();
}
block(){
this.$modal.addClass('xoo-wsc-loading');
}
unblock(){
this.$modal.removeClass('xoo-wsc-loading');
}
refreshMyFragments(){
if(xoo_wsc_params.refreshCart==="yes"&&typeof wc_cart_fragments_params!=='undefined'){
$(document.body).trigger('wc_fragment_refresh');
return;
}
this.block();
$.ajax({
url: get_wcurl('xoo_wsc_refresh_fragments'),
type: 'POST',
context: this,
data: {},
success: function(response){
this.updateFragments(response);
},
complete: function(){
this.unblock();
}})
}
updateCartCheckoutPage(){
if(isCheckoutPage){
if($('form.checkout').length===0){
location.reload();
return;
}
$(document.body).trigger("update_checkout");
}
if(isCartPage){
$(document.body).trigger("wc_update_cart");
}}
updateFragments(response){
console.log('updated');
if(response.fragments){
$(document.body).trigger('xoo_wsc_before_loading_fragments', [ response ]);
this.block();
$.each(response.fragments, function(key, value){
$(key).replaceWith(value);
});
if(typeof wc_cart_fragments_params!=='undefined'&&('sessionStorage' in window&&window.sessionStorage!==null) ){
sessionStorage.setItem(wc_cart_fragments_params.fragment_name, JSON.stringify(response.fragments) );
localStorage.setItem(wc_cart_fragments_params.cart_hash_key, response.cart_hash);
sessionStorage.setItem(wc_cart_fragments_params.cart_hash_key, response.cart_hash);
if(response.cart_hash){
sessionStorage.setItem('wc_cart_created',(new Date()).getTime());
}}
$(document.body).trigger('wc_fragments_refreshed');
this.unblock();
}
if(xoo_wsc_params.refreshCart==="yes"&&typeof wc_cart_fragments_params!=='undefined'){
this.block();
$(document.body).trigger('wc_fragment_refresh');
return;
}}
}
class Cart extends Container{
constructor($modal){
super($modal, 'cart');
this.refreshFragmentsOnPageLoad();
this.eventHandlers();
}
refreshFragmentsOnPageLoad(){
setTimeout(function(){
this.refreshMyFragments();
}.bind(this), xoo_wsc_params.fetchDelay)
}
eventHandlers(){
super.eventHandlers();
this.$modal.on('click', '.xoo-wsc-smr-del', this.deleteIconClick.bind(this));
this.$modal.on('click', '.xoo-wsch-close, .xoo-wsc-opac, .xoo-wsc-cart-close', this.closeCartOnClick.bind(this));
this.$modal.on('click', '.xoo-wsc-basket', this.toggleCart.bind(this));
$(document.body).on('xoo_wsc_cart_updated', this.updateCartCheckoutPage.bind(this));
$(document.body).on('click', 'a.added_to_cart, .xoo-wsc-cart-trigger', this.openCart.bind(this));
$(document.body).on('added_to_cart', this.addedToCart.bind(this));
$(document.body).on('wc-blocks_added_to_cart', this.blockAddedToCart.bind(this));
if(xoo_wsc_params.autoOpenCart==='yes'&&xoo_wsc_params.addedToCart==='yes'){
this.openCart();
}
if(xoo_wsc_params.ajaxAddToCart==='yes'){
$(document.body).on('submit', 'form.cart', this.addToCartFormSubmit.bind(this));
}
if(typeof wc_cart_fragments_params==='undefined'){
$(window).on('pageshow' , this.onPageShow.bind(this));
}
if(xoo_wsc_params.triggerClass){
$(document.body).on('click', '.'+xoo_wsc_params.triggerClass, this.openCart.bind(this));
}
if(isCheckoutPage||isCartPage){
$(document.body).on('updated_shipping_method', this.refreshMyFragments.bind(this));
}
this.initMasonryLayout();
}
toggleCart(e){
if(this.isOpen()){
this.closeCartOnClick(e);
}else{
this.openCart(e);
}}
openCart(e){
if(e){
e.preventDefault();
e.stopImmediatePropagation();
}
this.toggle('show');
Notice.hideMarkupNotice();
}
addToCartFormSubmit(e){
var $form=$(e.currentTarget);
if($form.closest('.product').hasClass('product-type-external')||$form.siblings('.xoo-wsc-disable-atc').length) return;
var $button=e.originalEvent&&e.originalEvent.submitter ? $(e.originalEvent.submitter):$form.find('button[type="submit"]'),
formData=new FormData($form.get(0)),
productData=$form.serializeArray(),
hasProductId=false;
$.each(productData, function(key, form_item){
if(form_item.name==='productID'||form_item.name==='add-to-cart'){
if(form_item.value){
hasProductId=true;
return false;
}}
})
if(!hasProductId&&$form.attr('action')){
var is_url=$form.attr('action').match(/add-to-cart=([0-9]+)/),
productID=is_url ? is_url[1]:false;
}
if($button.attr('name')&&$button.attr('value')){
formData.append($button.attr('name'), $button.attr('value'));
}
if(productID){
formData.append('add-to-cart', productID);
}
formData.append('action', 'xoo_wsc_add_to_cart');
var doAjaxAddToCart=true;
$.each(xoo_wsc_params.skipAjaxForData, function(key, value){
if(formData.has(key)&&(!value||formData.get(key)==value) ){
doAjaxAddToCart=false;
return false;
}})
if(doAjaxAddToCart){
e.preventDefault();
this.addToCartAjax($button, formData);
}}
addToCartAjax($button, formData){
this.block();
$button.addClass('loading');
$(document.body).trigger('adding_to_cart', [ $button, formData ]);
$.ajax({
url: get_wcurl('xoo_wsc_add_to_cart'),
type: 'POST',
context: this,
cache: false,
contentType: false,
processData: false,
data: formData,
success: function(response){
if(response.fragments){
$(document.body).trigger('added_to_cart', [ response.fragments, response.cart_hash, $button ]);
}else if(response.error){
Notice.$noticeContainer().replaceWith(response.notice);
Notice.showMarkupNotice();
}else{
window.location.reload();
}},
complete: function(){
this.unblock();
$button
.removeClass('loading')
.addClass('added');
}})
}
addedToCart(e, response, hash, $button){
this.updateFragments({ fragments: response });
this.onCartUpdate();
var _this=this;
if(xoo_wsc_params.autoOpenCart==="yes"){
setTimeout(function(){
_this.openCart();
},20)
}}
blockAddedToCart(){
$(document.body).trigger('wc_fragment_refresh');
this.block();
var _this=this;
if(xoo_wsc_params.autoOpenCart==="yes"){
setTimeout(function(){
_this.openCart();
},20)
}}
closeCartOnClick(e){
e.preventDefault();
this.toggle('hide');
}
onPageShow(e){
if(e.originalEvent.persisted){
this.refreshMyFragments();
$(document.body).trigger('wc_fragment_refresh');
}}
deleteIconClick(e){
this.updateItemQty($(e.currentTarget).parents('.xoo-wsc-product').data('key'), 0);
}
updateItemQty(cart_key, qty){
if(!cart_key||qty===undefined) return;
this.block();
var formData={
cart_key: cart_key,
qty: qty
}
$.ajax({
url: get_wcurl('xoo_wsc_update_item_quantity'),
type: 'POST',
context: this,
data: this.setAjaxData(formData),
success: function(response){
this.updateFragments(response);
$(document.body).trigger('xoo_wsc_quantity_updated', [response]);
$(document.body).trigger('xoo_wsc_cart_updated', [response]);
this.unblock();
}})
}
onCartUpdate(){
super.onCartUpdate();
this.toggleBasket();
this.initMasonryLayout();
}
initMasonryLayout(){
if(xoo_wsc_params.productLayout!=='cards') return;
$('.xoo-wsc-products.xoo-wsc-pattern-card').masonry({
itemSelector: '.xoo-wsc-product-cont',
columnWidth: '.xoo-wsc-product-cont', 
percentPosition: true
});
}
toggleBasket(){
var $basket=$('.xoo-wsc-basket'),
show=xoo_wsc_params.showBasket,
hasProducts=this.$modal.find('.xoo-wsc-product').length;
if(show==="always_show"){
$basket.show();
}
else if(show==="hide_empty"){
if(hasProducts){
$basket.show();
}else{
$basket.hide();
}}else{
$basket.hide();
}
var $shortcode=$('.xoo-wsc-sc-cont');
if($shortcode.length&&xoo_wsc_params.menuCartHideOnEmpty.length){
var shortcodeEls=xoo_wsc_params.shortcodeEls;
$.each(xoo_wsc_params.menuCartHideOnEmpty, function(index, val){
if(shortcodeEls[val]){
if(hasProducts){
$(shortcodeEls[val]).show();
}else{
$(shortcodeEls[val]).hide();
}}
})
}}
}
var cart=new Cart($('.xoo-wsc-modal'));
var AnimateCard={
type: xoo_wsc_params.cardAnimate.type,
duration: xoo_wsc_params.cardAnimate.duration,
init: function(){
var onEvent=xoo_wsc_params.cardAnimate.event==='back_hover' ? 'mouseenter':'click';
$('body').on(onEvent, '.xoo-wsc-has-back', this.animate);
$('body').on('mouseleave', '.xoo-wsc-has-back', this.reverseAnimate);
},
animate: function(e){
if(e.target.classList.contains('xoo-wsc-smr-del')) return;
var $img=$(this).find('.xoo-wsc-img-col');
if(!$img.hasClass('xoo-wsc-caniming')){
e.preventDefault();
}else{
return;
}
$img.attr('data-exclasses', $img.attr('class'));
$img.removeClass()
$img.addClass($img.attr('data-exclasses'));
$img.addClass('xoo-wsc-caniming' + ' ' + AnimateCard.type);
},
reverseAnimate: function(){
var $img=$(this).find('.xoo-wsc-img-col');
if(!$img.hasClass('xoo-wsc-caniming') ) return;
$img.addClass(AnimateCard.type+'Return');
AnimateCard.clear=setTimeout(function(){
$img.removeClass().addClass($img.attr('data-exclasses'));
}, AnimateCard.duration * 1000);
}}
if(xoo_wsc_params.cardAnimate.enable==="yes"){
AnimateCard.init();
}});