jQuery.fn.highlight=function(c){function e(b,c){var d=0;if(3==b.nodeType){var a=b.data.toUpperCase().indexOf(c),a=a-(b.data.substr(0,a).toUpperCase().length-b.data.substr(0,a).length);if(0<=a){d=document.createElement("span");d.className="highlight";a=b.splitText(a);a.splitText(c.length);var f=a.cloneNode(!0);d.appendChild(f);a.parentNode.replaceChild(d,a);d=1}}else if(1==b.nodeType&&b.childNodes&&!/(script|style)/i.test(b.tagName))for(a=0;a<b.childNodes.length;++a)a+=e(b.childNodes[a],c);return d} return this.length&&c&&c.length?this.each(function(){e(this,c.toUpperCase())}):this};jQuery.fn.removeHighlight=function(){return this.find("span.highlight").each(function(){this.parentNode.firstChild.nodeName;with(this.parentNode)replaceChild(this.firstChild,this),normalize()}).end()};
function debounce(callback, wait){
let timeout;
return (...args)=> {
clearTimeout(timeout);
timeout=setTimeout(function (){ callback.apply(this, args); }, wait);
};}
(function($){
"use strict";
function productSearch(form,query,currentQuery,element){
var search=form.find('.search'),
inTag=form.attr('data-tag'),
inAttr=form.attr('data-attr'),
category=form.find('select.category').val(),
sku=form.attr('data-sku'),
description=form.attr('data-description'),
loading=false;
form.find('.search-results').html('').removeClass('active');
query=query.trim();
if(query.length >=3){
form.find('.search-results').removeClass('empty');
search.parent().addClass('loading');
if(query!=currentQuery){
$.ajax({
url:controller_opt.ajaxUrl,
type: 'post',
data: {
action: 'search_product',
keyword: query,
category: category,
sku: sku,
description: description,
in_attr:inAttr,
in_tag:inTag,
},
success: function(data){
currentQuery=query;
search.parent().removeClass('loading');
if(!form.find('.search-results').hasClass('empty')){
if(data.length){
let output='';
data=JSON.parse(data);
if(typeof(data['output'])!='undefined'){
output +='<ul class="product-list">'+data['output']+'</ul>';
}else{
output +='<ul><li class="no-results">'+controller_opt.noProduct+'</li></ul>';
}
if(typeof(data['terms'])!='undefined'){
output +=data['terms'];
}
form.find('.search-results').html(output).addClass('active');
if(form.find('.search-results .no-results').length){
form.find('.search-results').addClass('no-results');
}else{
form.find('.search-results').removeClass('no-results');
}
var scroll=element.querySelector('ul');
if(typeof scroll!="undefined"&&scroll!=null&&form.find('.search-results ul li').length > 2){
SimpleScrollbar.initEl(scroll);
}
query=query.split(' ');
for (var i=0; i < query.length; i++){
form.find('.search-results').highlight(query[i]);
}}
}}
});
}}else{
search.parent().removeClass('loading');
form.find('.search-results').empty().removeClass('active').addClass('empty');
}}
function createSearchURL(shopURL,data,reload=true){
if(shopURL.indexOf("?")==-1){
shopURL +='?';
}
$.each(data, function(key, value){
if(value.length){
if(key=='year'){key='yr';}
if(!shopURL.includes(key+'='+value)){
shopURL +='&'+key+'='+value;
}}
});
shopURL=shopURL.replace('?&', '?');
shopURL=encodeURI(shopURL);
if(reload){
window.location.assign(shopURL);
}else{
history.pushState({}, null, shopURL);
$('.reload-all-attribute').trigger('click');
}}
$('form[name="product-search"]').each(function(){
var element=this,
form=$(this),
search=form.find('.search'),
category=form.find('.category'),
inCat=form.attr('data-in-category'),
currentQuery='',
button=form.find('input[type="submit"]');
var mouse_is_inside=false;
var typingTimer;
category
.on('change',function(){
currentQuery='';
var query=search.val();
productSearch(form,query,currentQuery,element);
mouse_is_inside=true;
let text=$(this).parent().find('.select2-selection__rendered').text();
$(this).parent().find('.select2-selection__rendered').text(text.trim());
});
search.on('keyup',function(){
search.parent().addClass('loading');
});
window.addEventListener('keyup', debounce(()=> {
var query=search.val();
productSearch(form,query,currentQuery,element);
mouse_is_inside=true;
}, 200));
button.on('click',function(e){
e.preventDefault();
var ajx=($('.widget_product_filter_widget').length&&getParams()&&typeof(getParams()['ajax'])!="undefined") ? true:false,
url=ajx ? window.location.href:button.data('shop'),
reload=ajx ? false:true,
activeCat=category.find('option:selected').val(),
searchVal=search.val(),
data={};
if(typeof(activeCat)!='undefined'&&activeCat.length){
if(ajx){
data['ca']=activeCat;
}else{
data['product_cat']=activeCat;
}}
if(typeof(searchVal)!='undefined'&&searchVal.length){
data['s']=searchVal;
createSearchURL(url,data,reload);
}});
search.on('click',function(){
if(mouse_is_inside){
$('.search-results').removeClass('active');
}});
});
})(jQuery);
(function($){
var valid="invalid";
function validateValue($value, $target, $placeholder,$email){
if($email==true){
var n=$value.indexOf("@");
var r=$value.lastIndexOf(".");
if(n < 1||r < n + 2||r + 2 >=$value.length){
valid="invalid";
}else{
valid="valid";
}
if($value==null||$value==""||valid=="invalid"){
$target.addClass('visible');
}else{
$target.removeClass('visible');
}}else{
if($value==null||$value==""||$value==$placeholder){
$target.addClass('visible');
}else{
$target.removeClass('visible');
}}
};
$('.et-mailchimp-form').each(function(){
var $this=$(this);
$this.submit(function(event){
event.preventDefault();
var formData=$this.serialize();
var email=$this.find("input[name='email']"),
fname=$this.find("input[name='fname']"),
lname=$this.find("input[name='lname']"),
phone=$this.find("input[name='phone']"),
list=$this.find("input[name='list']");
validateValue(email.val(), email.next(".alert"), email.attr('data-placeholder'), true);
if(fname.length&&fname.attr('data-required')=="true"){validateValue(fname.val(), fname.next(".alert"), fname.attr('data-placeholder'), false);}
if(lname.length&&lname.attr('data-required')=="true"){validateValue(lname.val(), lname.next(".alert"), lname.attr('data-placeholder'), false);}
if(phone.length&&phone.attr('data-required')=="true"){validateValue(phone.val(), phone.next(".alert"), phone.attr('data-placeholder'), false);}
if(email.val()!=email.attr('data-placeholder')&&valid=="valid"){
if(fname.length&&fname.attr('data-required')=="true"&&fname.val()==fname.attr('data-placeholder')){event.preventDefault();}
if(lname.length&&lname.attr('data-required')=="true"&&lname.val()==lname.attr('data-placeholder')){event.preventDefault();}
if(phone.length&&phone.attr('data-required')=="true"&&phone.val()==phone.attr('data-placeholder')){event.preventDefault();}
$this.find(".sending").addClass('visible');
$.ajax({
type: 'POST',
url: $this.attr('action'),
data: formData
})
.done(function(response){
$this.find(".sending").removeClass('visible');
$this.find(".et-mailchimp-success").addClass('visible');
setTimeout(function(){
$this.find(".et-mailchimp-success").removeClass('visible');
},2000);
})
.fail(function(data){
$this.find(".sending").removeClass('visible');
$this.find(".et-mailchimp-error").addClass('visible');
setTimeout(function(){
$this.find(".et-mailchimp-error").removeClass('visible');
},2000);
})
.always(function(){
setTimeout(function(){
$this.find("input[name='email']").val(email.attr('data-placeholder'));
$this.find("input[name='fname']").val(fname.attr('data-placeholder'));
$this.find("input[name='lname']").val(lname.attr('data-placeholder'));
$this.find("input[name='phone']").val(phone.attr('data-placeholder'));
},2000);
});
}});
$this.find('input').on('focus',function(){
$(this).next('.visible').removeClass('visible');
});
});
})(jQuery);
(()=>{var e=0,r={};function i(t){if(!t)throw new Error("No options passed to Waypoint constructor");if(!t.element)throw new Error("No element option passed to Waypoint constructor");if(!t.handler)throw new Error("No handler option passed to Waypoint constructor");this.key="waypoint-"+e,this.options=i.Adapter.extend({},i.defaults,t),this.element=this.options.element,this.adapter=new i.Adapter(this.element),this.callback=t.handler,this.axis=this.options.horizontal?"horizontal":"vertical",this.enabled=this.options.enabled,this.triggerPoint=null,this.group=i.Group.findOrCreate({name:this.options.group,axis:this.axis}),this.context=i.Context.findOrCreateByElement(this.options.context),i.offsetAliases[this.options.offset]&&(this.options.offset=i.offsetAliases[this.options.offset]),this.group.add(this),this.context.add(this),r[this.key]=this,e+=1}i.prototype.queueTrigger=function(t){this.group.queueTrigger(this,t)},i.prototype.trigger=function(t){this.enabled&&this.callback&&this.callback.apply(this,t)},i.prototype.destroy=function(){this.context.remove(this),this.group.remove(this),delete r[this.key]},i.prototype.disable=function(){return this.enabled=!1,this},i.prototype.enable=function(){return this.context.refresh(),this.enabled=!0,this},i.prototype.next=function(){return this.group.next(this)},i.prototype.previous=function(){return this.group.previous(this)},i.invokeAll=function(t){var e,i=[];for(e in r)i.push(r[e]);for(var o=0,n=i.length;o<n;o++)i[o][t]()},i.destroyAll=function(){i.invokeAll("destroy")},i.disableAll=function(){i.invokeAll("disable")},i.enableAll=function(){for(var t in i.Context.refreshAll(),r)r[t].enabled=!0;return this},i.refreshAll=function(){i.Context.refreshAll()},i.viewportHeight=function(){return window.innerHeight||document.documentElement.clientHeight},i.viewportWidth=function(){return document.documentElement.clientWidth},i.adapters=[],i.defaults={context:window,continuous:!0,enabled:!0,group:"default",horizontal:!1,offset:0},i.offsetAliases={"bottom-in-view":function(){return this.context.innerHeight()-this.adapter.outerHeight()},"right-in-view":function(){return this.context.innerWidth()-this.adapter.outerWidth()}},window.VcWaypoint=i})(),(()=>{function e(t){window.setTimeout(t,1e3/60)}var i=0,o={},u=window.VcWaypoint,t=window.onload;function n(t){this.element=t,this.Adapter=u.Adapter,this.adapter=new this.Adapter(t),this.key="waypoint-context-"+i,this.didScroll=!1,this.didResize=!1,this.oldScroll={x:this.adapter.scrollLeft(),y:this.adapter.scrollTop()},this.waypoints={vertical:{},horizontal:{}},t.waypointContextKey=this.key,o[t.waypointContextKey]=this,i+=1,u.windowContext||(u.windowContext=!0,u.windowContext=new n(window)),this.createThrottledScrollHandler(),this.createThrottledResizeHandler()}n.prototype.add=function(t){var e=t.options.horizontal?"horizontal":"vertical";this.waypoints[e][t.key]=t,this.refresh()},n.prototype.checkEmpty=function(){var t=this.Adapter.isEmptyObject(this.waypoints.horizontal),e=this.Adapter.isEmptyObject(this.waypoints.vertical),i=this.element==this.element.window;t&&e&&!i&&(this.adapter.off(".vcwaypoints"),delete o[this.key])},n.prototype.createThrottledResizeHandler=function(){var t=this;function e(){t.handleResize(),t.didResize=!1}this.adapter.on("resize.vcwaypoints",function(){t.didResize||(t.didResize=!0,u.requestAnimationFrame(e))})},n.prototype.createThrottledScrollHandler=function(){var t=this;function e(){t.handleScroll(),t.didScroll=!1}this.adapter.on("scroll.vcwaypoints",function(){t.didScroll&&!u.isTouch||(t.didScroll=!0,u.requestAnimationFrame(e))})},n.prototype.handleResize=function(){u.Context.refreshAll()},n.prototype.handleScroll=function(){var t,e,i={},o={horizontal:{newScroll:this.adapter.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.adapter.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}};for(t in o){var n,r=o[t],s=r.newScroll>r.oldScroll?r.forward:r.backward;for(n in this.waypoints[t]){var a,l,h=this.waypoints[t][n];null!==h.triggerPoint&&(a=r.oldScroll<h.triggerPoint,l=r.newScroll>=h.triggerPoint,a&&l||!a&&!l)&&(h.queueTrigger(s),i[h.group.id]=h.group)}}for(e in i)i[e].flushTriggers();this.oldScroll={x:o.horizontal.newScroll,y:o.vertical.newScroll}},n.prototype.innerHeight=function(){return this.element==this.element.window?u.viewportHeight():this.adapter.innerHeight()},n.prototype.remove=function(t){delete this.waypoints[t.axis][t.key],this.checkEmpty()},n.prototype.innerWidth=function(){return this.element==this.element.window?u.viewportWidth():this.adapter.innerWidth()},n.prototype.destroy=function(){var t,e=[];for(t in this.waypoints)for(var i in this.waypoints[t])e.push(this.waypoints[t][i]);for(var o=0,n=e.length;o<n;o++)e[o].destroy()},n.prototype.refresh=function(){var t,e,i=this.element==this.element.window,o=i?void 0:this.adapter.offset(),n={};for(e in this.handleScroll(),t={horizontal:{contextOffset:i?0:o.left,contextScroll:i?0:this.oldScroll.x,contextDimension:this.innerWidth(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:i?0:o.top,contextScroll:i?0:this.oldScroll.y,contextDimension:this.innerHeight(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}}){var r,s=t[e];for(r in this.waypoints[e]){var a,l=this.waypoints[e][r],h=l.options.offset,p=l.triggerPoint,c=0,d=null==p;l.element!==l.element.window&&(c=l.adapter.offset()[s.offsetProp]),"function"==typeof h?h=h.apply(l):"string"==typeof h&&(h=parseFloat(h),-1<l.options.offset.indexOf("%"))&&(h=Math.ceil(s.contextDimension*h/100)),a=s.contextScroll-s.contextOffset,l.triggerPoint=Math.floor(c+a-h),c=p<s.oldScroll,a=l.triggerPoint>=s.oldScroll,h=!c&&!a,!d&&(c&&a)?(l.queueTrigger(s.backward),n[l.group.id]=l.group):(!d&&h||d&&s.oldScroll>=l.triggerPoint)&&(l.queueTrigger(s.forward),n[l.group.id]=l.group)}}return u.requestAnimationFrame(function(){for(var t in n)n[t].flushTriggers()}),this},n.findOrCreateByElement=function(t){return n.findByElement(t)||new n(t)},n.refreshAll=function(){for(var t in o)o[t].refresh()},n.findByElement=function(t){return o[t.waypointContextKey]},window.onload=function(){t&&t(),n.refreshAll()},u.requestAnimationFrame=function(t){(window.requestAnimationFrame||window.mozRequestAnimationFrame||window.webkitRequestAnimationFrame||e).call(window,t)},u.Context=n})(),(()=>{function r(t,e){return t.triggerPoint-e.triggerPoint}function s(t,e){return e.triggerPoint-t.triggerPoint}var e={vertical:{},horizontal:{}},i=window.VcWaypoint;function o(t){this.name=t.name,this.axis=t.axis,this.id=this.name+"-"+this.axis,this.waypoints=[],this.clearTriggerQueues(),e[this.axis][this.name]=this}o.prototype.add=function(t){this.waypoints.push(t)},o.prototype.clearTriggerQueues=function(){this.triggerQueues={up:[],down:[],left:[],right:[]}},o.prototype.flushTriggers=function(){for(var t in this.triggerQueues){var e=this.triggerQueues[t];e.sort("up"===t||"left"===t?s:r);for(var i=0,o=e.length;i<o;i+=1){var n=e[i];!n.options.continuous&&i!==e.length-1||n.trigger([t])}}this.clearTriggerQueues()},o.prototype.next=function(t){this.waypoints.sort(r);t=i.Adapter.inArray(t,this.waypoints);return t===this.waypoints.length-1?null:this.waypoints[t+1]},o.prototype.previous=function(t){this.waypoints.sort(r);t=i.Adapter.inArray(t,this.waypoints);return t?this.waypoints[t-1]:null},o.prototype.queueTrigger=function(t,e){this.triggerQueues[e].push(t)},o.prototype.remove=function(t){t=i.Adapter.inArray(t,this.waypoints);-1<t&&this.waypoints.splice(t,1)},o.prototype.first=function(){return this.waypoints[0]},o.prototype.last=function(){return this.waypoints[this.waypoints.length-1]},o.findOrCreate=function(t){return e[t.axis][t.name]||new o(t)},i.Group=o})(),(()=>{var i=window.jQuery,t=window.VcWaypoint;function o(t){this.$element=i(t)}i.each(["innerHeight","innerWidth","off","offset","on","outerHeight","outerWidth","scrollLeft","scrollTop"],function(t,e){o.prototype[e]=function(){var t=Array.prototype.slice.call(arguments);return this.$element[e].apply(this.$element,t)}}),i.each(["extend","inArray","isEmptyObject"],function(t,e){o[e]=i[e]}),t.adapters.push({name:"jquery",Adapter:o}),t.Adapter=o})(),(()=>{var n=window.VcWaypoint;function t(o){return function(){var e=[],i=arguments[0];return o.isFunction(arguments[0])&&((i=o.extend({},arguments[1])).handler=arguments[0]),this.each(function(){var t=o.extend({},i,{element:this});"string"==typeof t.context&&(t.context=o(this).closest(t.context)[0]),e.push(new n(t))}),e}}window.jQuery&&(window.jQuery.fn.vcwaypoint=t(window.jQuery)),window.Zepto&&(window.Zepto.fn.vcwaypoint=t(window.Zepto))})();