ventilatornakachle.sk
Open in
urlscan Pro
172.104.148.129
Public Scan
URL:
https://ventilatornakachle.sk/scripts/_functions-v4.js.min.js?1729585343
Submission: On November 21 via api from US — Scanned from US
Submission: On November 21 via api from US — Scanned from US
Form analysis
0 forms found in the DOMText Content
function upFunctions(){this.shipment_id=null;this.affiliate_id=null;this.payment_id=null;this.checkPaymentStartTime;this.disableOnHashChange=false;this.historyPushState=true;this.getQuantitiesOfProductsInCart=function(){var serialized='';$('.CartRow .QuantityObject').each(function(){serialized=serialized+$(this).val()+';';});return serialized;};this.serializeProductVariants=function(){var serialized='';var variantSelectionComplete=true;$('select.variantsObject').each(function(){var $this=$(this);var name='';var value='';if($this.val()!=='--'){name=$this.attr('name');value=$this.val();}else{variantSelectionComplete=false;} serialized=serialized+name+';'+value+',';});return{data:serialized,variantSelectionComplete:variantSelectionComplete};};this.serializeProductConfigurations=function(){var serialized=[];var complete=true;$('#ConfigurationSelect .configurationObject').each(function(){var $this=$(this);var name=$this.data("serialize-name");if(typeof name==='undefined'){return;} var value=$this.val();var required=$this.data("is-required");if($.isArray(value)){if(value.length===0&&required===true){complete=false;}else if(value.length>0){serialized.push(name+":"+value.join(','));}}else{if(value!=='--'&&value!==null&&value!==""){serialized.push(name+":"+value);}else if(required===true){complete=false;}}});return{data:serialized.join(";"),configurationSelectionComplete:complete};};this.getProductLength=function(){let lengthEl=$('.lengthObject');return up.elExist(lengthEl)?lengthEl.val().replace(',','.'):false;};this.filterGetPage=function(){let p=window.location.pathname.split('/').pop();return new RegExp(/^pg-\d+$/).test(p)?parseInt(p.replace('pg-','')):null;};this.filterDecodeUrl=function(){var url=decodeURIComponent(window.location.hash.replace('#','')),data={},seg=url.replace(/^.*\?/,'').split('&');for(var i=0;i<seg.length;i++){if(!seg[i]){continue;} var s=seg[i].split('=');if(s.length>=2){if(s[1].toLowerCase()==='true'){s[1]=true;}else if(s[1].toLowerCase()==='false'){s[1]=false;} data[s[0]]=s[1];}else{data[s[0]]=null;}} delete data.order;var page=upFn.filterGetPage();if(page>1){data['page']=page;} return data;};this.filtersUpdateHash=function(newParams){var page;if(newParams===null){var params={};}else{var params=this.filterDecodeUrl();for(var id in newParams){var value=newParams[id];id=upFn.filterGetPartialId(id);if(id==='page'){page=newParams[id];delete params[id];}else if(value==false||value=='--'||(id==='sort'&&value===up.filterSettings.defSort)||(id==='min_price'&&value===up.filterSettings.defMinPrice)||(id==='max_price'&&value===up.filterSettings.defMaxPrice)||(id.indexOf('attrSl-')===0&&up.filterSettings[id]===value)){delete params[id];}else{if(value===true){params[id]=1;}else if(value===false){params[id]=0;}else{params[id]=value;}}}} var path=window.location.pathname;var hash=$.isEmptyObject(params)?'':'#'+$.param(params);if($.isNumeric(page)){var curPage=upFn.filterGetPage();if(curPage){path=path.replace('/pg-'+curPage,page>1?'/pg-'+page:'');} else if(page>1){path+='/pg-'+page;}} if(history.pushState){if(upFn.historyPushState){history.pushState(JSON.stringify(newParams),null,path+hash);}}else{window.location.href=path+hash;} upFn.filtersUpdateProductList();};this.pushState=true;this.getFiltersData=function(){let data=upFn.filterDecodeUrl();if(!data.hasOwnProperty('page')){data.page=1;} if(!data.hasOwnProperty('sort')){data.sort=up.filterSettings.defSort;} $.each(data,function($id,$value){data['frmProductsFilters-'+$id]=$value;data['frmProductsList-'+$id]=$value;delete data[$id];});return data;};this.filtersUpdateProductList=function(){$.ajax({url:up.filterSettings.URL,type:'post',data:upFn.getFiltersData(),error:up.error(),complete:function(){if(!up.filterSettings.pagingSni){$('#snippet-products-productList').fadeOut('fast',function(){$('#snippet-products-productList').fadeIn('fast',function(){up.trigger('filtersAfterUpdateProductList');up.filterSettings.firstLoad=false;});});} up.filterSettings.pagingSni=false;},success:function(payload){if(!up.filterSettings.pagingSni){$.nette.success(payload);upFn.filterStateLoad();} else{up.trigger('productsListSni',payload);}}});};this.filterStateLoad=function(){if(typeof filterStateUrl!='undefined'&&up.filterSettings.filterStateDisabled!==true){if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} up.trigger('hidePreloader');up.spinnerDisabled=true;up.ajaxRequest=$.ajax({url:filterStateUrl,type:'post',data:upFn.getFiltersData(),error:up.error(),success:function(payload){if(payload.filtersState){up.trigger('filtersStateInit',payload.filtersState);}}});up.spinnerDisabled=false;} up.filterSettings.filterStateDisabled=false;};this.filterGetPartialId=function(id){return id.replace('frmProductsList-','').replace('frmProductsFilters-','');};this.filtersUpdateElements=function(params){$.each(params,function(i,s){var inputs=$('#frmProductsList-'+i+', #frmProductsFilters-'+i);if(up.elExist(inputs)){if(inputs.is(':checkbox')){inputs.prop('checked',s==true);} else if(inputs.is('select')){inputs.val(s);} else if(inputs.is('img')){if(s){inputs.addClass(up.cls.active);}else{inputs.removeClass(up.cls.active);}} else if(inputs.is(':hidden')){inputs.val(s);}}});};this.filtersRemovePagingSuffix=function(){var lastPage=0;$('.FiltersPaging [data-page]').each(function(){var $this=$(this);if($this.data('page')>lastPage){lastPage=$this.data('page');}});var suffix=pagging_suffix.replace('{page_current}',up.filters.page).replace('{number_of_pages}',lastPage);let h1=$('h1').first();h1.text(h1.text().replace(suffix,'').trim());document.title=document.title.replace(suffix,'').trim();};this.loadImages=function(el){var e=up.validateSelector(el),src=e.data('src'),srcset=e.data('srcset'),addClass=false;if(src){e.attr('src',src).removeAttr('data-src');addClass=true;} if(srcset){e.attr('srcset',srcset).removeAttr('data-srcset');addClass=true;} if(addClass){e.addClass('img-loaded');} return true;};this.loadVideos=function(el){var v=up.validateSelector(el),s=v.find('source'),src=s?s.data('src'):null;if(src){s.attr('src',src).removeAttr('data-src');v.addClass('video-loaded').get(0).load();} return true;};this.load=function(el){up.validateSelector(el).addClass('load');return true;};this.loadBackground=function(el){let e=up.validateSelector(el),bg=e.data('background-image');if(bg&&!e.hasClass('bg-loaded')){e.css('background-image','url('+bg+')').removeAttr('data-background-image');e.addClass('bg-loaded');}};this.init=function(){var $BODY=$('body');$BODY.addClass(up.isTouchDevice?'isTouch':'noTouch');$(document).ajaxStart(function(){if(up.spinnerDisabled){up.spinnerDisabled=false;}else{up.trigger('showPreloader');}}).ajaxStop(function(){up.trigger('hidePreloader');});$.ajaxPrefilter(function(o){if(typeof o.url!='undefined'){try{var url=new URL(o.url);if(url.host!=location.host){up.spinnerDisabled=true;}}catch(e){if(o.url.indexOf('/search/suggest')==0){up.spinnerDisabled=true;}}}});up.on('initImgLazy',function(){up.observe($('img.ImgLazy'),upFn.loadImages);up.observe($('picture source.ImgLazy'),upFn.loadImages);up.observe($('.BgLazy'),upFn.loadBackground);up.observe($('.carousel'),function(el){$.each(up.validateSelector(el).find('.CoverBgLazy'),function(k,i){upFn.loadBackground(i);});});up.observe($('.VideoLazy'),upFn.loadVideos);});up.trigger('initImgLazy');window.onbeforeprint=function(){$('img.ImgLazy, picture source.ImgLazy').each(function(i,v){upFn.loadImages(v);});};if($BODY.hasClass('page-site')||$BODY.hasClass('page-manufacturer')){this.initFilters();} this.initProducts();this.initCart();this.initForms();if($BODY.hasClass(up.cls.search)){var updateSearchPage=function(page,sni){window.location.hash=page==1?"":"page="+page;$.ajax({url:searchPagingUrl,data:{page:page},error:up.error(),success:function(payload){if(!sni){$.nette.success(payload);} else{up.trigger('searchedProductsListSni',payload);}},complete:function(){if(!sni){up.trigger('filtersAfterUpdateProductListSearched');}}});};if(window.location.hash.length>0){var params=upFn.filterDecodeUrl();if(typeof params.page!=='undefined'){updateSearchPage(params.page);}} $(window).bind('hashchange',function(){if(!upFn.disableOnHashChange){var params=upFn.filterDecodeUrl();updateSearchPage(typeof params.page!=='undefined'?params.page:1);} upFn.disableOnHashChange=false;});$BODY.on('click','.FiltersPaging a',function(e){e.preventDefault();var page=$(this).data('page');upFn.disableOnHashChange=true;updateSearchPage(page);return false;});$BODY.on('click','.FiltersSni',function(){upFn.disableOnHashChange=true;var params=upFn.filterDecodeUrl();if(typeof params.page!=='undefined'){updateSearchPage(parseInt(params.page)+1,true);}else{updateSearchPage(2,true);} return false;});} if(up.elExist($('#frm-review-productReviewForm'))){$.each(['positives','negatives'],function(i,el){let form=$('#frmproductReviewForm-'+el),numChars=form.val().length,max=form.attr('maxlength'),num=$('#'+el+'CharactersLeft').find('.NumChars');if(numChars>=max){num.text(0);}else if(numChars<max){num.text(max-numChars);}else{num.text(max);}});} $BODY.on('keyup','.ReviewTextarea',function(){let $this=$(this),max=$this.attr('maxlength'),len=$this.val().length,id=$this.attr('id').replace('frmproductReviewForm-',''),num=$('#'+id+'CharactersLeft').find('.NumChars');if(len>=max){num.text(0);}else{num.text(max-len);}});$BODY.on('click','.ProductReviews .ReviewHelpful',function(){var $this=$(this);$.ajax({url:reviewHelpfulUrl,data:{product_id:$this.parents('[data-product-id]').data('product-id'),customer_id:$this.parents('[data-customer-id]').data('customer-id'),helpful:$this.data('helpful')},error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('dialog','alert');}});});$BODY.on('click','.ShowMoreReview',function(){let $reviewType=$(this).parent().attr('id');$('#'+$reviewType).addClass(up.cls.hidden);$('#'+$reviewType+'-all').removeClass(up.cls.hidden);return false;});if($BODY.hasClass(up.cls.compare)){$BODY.on('click','.RemoveProduct',function(){let item=$(this).parents('.CompareTable'),product_id=item.data('product-id');$.ajax({url:removeFromCompareListUrl,data:{product_id:product_id,reload:0},error:up.error(),success:function(payload){$.nette.success(payload);if(payload.redirect){window.location.href=payload.redirect;} up.trigger('afterDeleteCompareListItem',item);}});});} if($BODY.hasClass(up.cls.favourites)){$BODY.on('click','.RemoveProduct',function(){$.ajax({url:deleteFavouriteUrl,data:{product_id:$(this).data('product-id')},error:up.error(),success:function(payload){$.nette.success(payload);},complete:function(){up.trigger('filtersAfterUpdateProductList',true);}});});} if($BODY.hasClass(up.cls.watched)){$BODY.on('click','.RemoveWatched',function(){$.ajax({url:deleteWatchedUrl,data:{customer_watchdog_id:$(this).data('customer-watchdog-id')},error:up.error(),success:function(payload){up.trigger('dialog','alert');$('.watchedCount').text(payload.watched_count);$.nette.success(payload);}});});} if($BODY.hasClass(up.cls.profile)){$BODY.on('click','.AddDeliveryAddressButton',function(){$('input[name="add_new_address"]').prop('checked',$('#DeliveryAddressForm').is(':visible')?false:true);});} if($BODY.hasClass(up.cls.registration)){var checkEmailTimeout=null;$BODY.on('input keydown paste','#frmcustomerRegistrationForm-email',function(e){var $this=$(this);var inputValue=e.which;if(!(inputValue>=65&&inputValue<=120)&&(inputValue!=32&&inputValue!=0&&inputValue!==undefined)){return;} clearTimeout(checkEmailTimeout);var email=$this.val();if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} up.trigger('showHideCheckoutEmailAlert',null,false);if(email.length==0){return;} if(nette.validateControl($this.get(0))){return;} var type=e.handleObj.origType;var timeout=0;if(type==='input'||(type==='keydown'&&e.keyCode!==13)){timeout=600;} checkEmailTimeout=setTimeout(function(){up.ajaxRequest=$.ajax({url:'?do=checkEmail',data:{email:email},error:up.error(),success:function(payload){if(payload.alertType){up.trigger('showHideCheckoutEmailAlert',payload.alertType,true);} else{up.trigger('showHideCheckoutEmailAlert',null,false);}},complete:function(){up.ajaxRequest=undefined;}});},timeout);if(e.keyCode===13){e.preventDefault();e.stopPropagation();}});} if(up.elExist('.MenuTreeAjax')){$('body .MenuTreeAjax').on('click','.MenuTreePlus, .MenuTreeMinus',function(e){e.stopPropagation();if($(this).data('href')!==undefined){return;} var $li=$(this).closest('li'),showHideSpeed=200,$category_id=$li.data('category_id'),$level=$li.data('level'),componentName=$(this).parents('.MenuTreeAjax').data('component-name');if(!componentName){componentName='leftMenu';} var closeOthers=function(){$('.MenuTreeOpened').each(function(){if($level==$(this).data('level')&&$category_id!=$(this).data('category_id')){$(this).removeClass('MenuTreeOpened');$(this).addClass('MenuTreeClosed');$(this).children('ul').hide(showHideSpeed);}});};if($li.data('loaded')==1){if($li.hasClass('MenuTreeOpened')){$li.removeClass('MenuTreeOpened');$li.addClass('MenuTreeClosed');$li.children('ul').hide(showHideSpeed);} else{$li.removeClass('MenuTreeClosed');$li.addClass('MenuTreeOpened');$li.children('ul').show(showHideSpeed);} closeOthers();} else{if(up.ajaxRequest==undefined){up.spinnerDisabled=true;let data={};data[componentName+"-parent_id"]=$category_id;data[componentName+"-level"]=$level;up.ajaxRequest=$.ajax({url:window.location.origin+(up.elExist('body.page-404')?'':window.location.pathname)+"/?do="+componentName+"-load",data:data,error:up.error(),success:function(payload){if(payload.snippets!==undefined){var snippet=payload.snippets["snippet-"+componentName+"-menuTree"];if(snippet!=undefined){$li.append(snippet);$li.data('loaded',1);$li.removeClass('MenuTreeClosed');$li.addClass('MenuTreeOpened');$li.children('ul').show(showHideSpeed);}} closeOthers();},complete:function(){up.ajaxRequest=undefined;}});}} closeOthers();return false;});let navList=$('.left-menu-parents-only .nav-list');if(up.elExist(navList)){let $active=navList.find('.active:not(.lev-1)');if(!$active.length){$('.left-menu-parents-only .nav-list li.lev-1:not(.parent):not(.active)').removeClass('MenuTreeClosed').addClass('MenuTreeOpened MenuTreeHidden');}}} up.on('initPopup',function(){var config=$("#PopupConfig").data();if(typeof config==='undefined'){up.setCookie('visitedPopup',null,-1);return;} var visited=up.getCookie('visitedPopup');if(typeof config.validity!=='undefined'&&(visited===""||visited>config.validity)){var popup=$('.popupPromo');var pathname=window.location.pathname.replace('/','');if(pathname.length<=3||!config.only_homepage){setTimeout(function(){popup.modal("show");var iframe=popup.find('iframe');if(iframe){iframe.attr('src',iframe.data('src'));} var c=popup.find('.PopupSelectCountry');if(c.length){c.on('click',function(){up.setCookie('visitedPopup',config.validity,config.interval*60);});} if(config.contenttype=='countrySelect'||config.contenttype=='entryRestriction'){popup.on('hidden.bs.modal',function(){up.setCookie('visitedPopup',config.validity,config.interval*60);});} $('.popupPromo button.close').on('click',function(){$('.popupPromo div.text').remove();});if(config.contenttype!='countrySelect'&&config.contenttype!='entryRestriction'){up.setCookie('visitedPopup',config.validity,config.interval*60);}},config.delay*1000);}}});if(up.inits.bootstrap){up.trigger('initPopup');} up.on('initCookies',function(){if(typeof cookiesAgreement!=='object'){return;} var ca=cookiesAgreement,$BODY=$('body'),dialog=up.elExist($BODY.find('#cookiesDialog'));if(!ca.active||up.elExist('.CA')){return;} var caGetCookie=function(){let cookiesRules=up.getCookie('cookiesRules');return cookiesRules!==''?JSON.parse(cookiesRules):'';};var caSaveCookie=function(values){let cookiesRules=caGetCookie();var d=new Date();d.setTime(d.getTime()+(2592000*1000));document.cookie="cookiesRules="+JSON.stringify(values)+"; expires="+d.toUTCString()+"; path=/";if(JSON.stringify(cookiesRules)!==JSON.stringify(values)){upgates.emit('cookies');}};var caSaveSettings=function(value){var caItems={analytics:true,personalized:true,ads:true};$('#cookiesDialog').find('.CaSection input:checkbox:not(:disabled)').each(function(){let $this=$(this);if(typeof value!=='undefined'){$this.prop('checked',value);} caItems[$this.attr('name')]=$this.prop('checked');});caSaveCookie(caItems);};var cookiesRules=caGetCookie();if(cookiesRules!==''&&dialog){$('#cookiesDialog').find('.CaSection input:checkbox:not(:disabled)').each(function(){let $this=$(this);$this.prop('checked',cookiesRules[$this.attr('name')]);});} if(cookiesRules===''){let isRule=$('#cookiesDialog').find('.CaSection input:checkbox:not(:disabled)').length>1;if(ca.type=='window'&&dialog){setTimeout(function(){up.trigger('dialog','cookies');},500);} else if(ca.type=='bar_lg'&&typeof upC.caLgCls!='undefined'){let svg=$('#cookiesDialog svg');svg=svg.length>0?svg.clone().removeClass('hidden').prop('outerHTML'):'';if(typeof upC.caLgCls.btn_none=='undefined'){upC.caLgCls.btn_none=upC.caLgCls.btn_set;} $BODY.append($('<div class="'+upC.caLgCls.container+' CA">'+'<div class="'+upC.caLgCls.heading+'">'+svg+' Cookies</div>'+'<div class="'+upC.caLgCls.text+'">'+ca.text+'</div>'+'<div>'+ (isRule?'<a href="#" class="'+upC.caLgCls.btn_set+' CaSettings" role="button">'+ca.settings_text+'</a>':'')+ (isRule?'<a href="#" class="'+upC.caLgCls.btn_none+' CaSaveNone" role="button">'+ca.btn_dis_text+'</a>':'')+'<a href="#" role="button" class="'+upC.caLgCls.btn+' CaSaveAll" target="_blank" role="button">'+ca.btn_text+'</a>'+'</div>'+'</div>').css('z-index','2147483647'));} else{if(typeof upC.caCls.btn_none=='undefined'){upC.caCls.btn_none=upC.caCls.btn_set;} $BODY.append($('<div class="'+upC.caCls.container+' CA">'+'<small class="'+upC.caCls.text+'">'+ca.text+'</small>'+ (dialog&&isRule?('<a href="#" class="'+upC.caCls.btn_set+' CaSettings" role="button">'+ca.settings_text+'</a>'):'')+ (isRule?'<a href="#" class="'+upC.caCls.btn_none.replace('btn-secondary','btn-default')+' CaSaveNone" role="button">'+ca.btn_dis_text+'</a>':'')+'<a href="#" class="'+upC.caCls.btn+' CaSaveAll" target="_blank" role="button">'+ca.btn_text+'</a>'+'</div>').css('z-index','2147483647'));}} else{caSaveCookie(cookiesRules);} if(dialog){$BODY.on('click','.CaSettings',function(e){e.preventDefault();up.trigger('dialog','cookies');});$BODY.on('click','.CaSaveSelected',function(e){e.preventDefault();$('.CA').addClass(up.cls.hidden);caSaveSettings();});$BODY.on('click','.CaSaveAll',function(e){e.preventDefault();$('.CA').addClass(up.cls.hidden);caSaveSettings(true);});let soc=$('#frmca-social-add');soc.addClass(up.cls.hidden);$('label[for='+soc.attr('id')+']').addClass(up.cls.hidden);$BODY.on('click','.CaSaveNone',function(e){e.preventDefault();$('.CA').addClass(up.cls.hidden);caSaveSettings(false);});} else{$BODY.on('click','.CaSaveNone',function(e){e.preventDefault();$('.CA').addClass(up.cls.hidden);caSaveCookie({analytics:false,personalized:false,ads:false});});$BODY.on('click','.CaSaveAll',function(e){e.preventDefault();$('.CA').addClass(up.cls.hidden);caSaveCookie({analytics:true,personalized:true,ads:true});});}});if(typeof upC==='object'){up.trigger('initCookies');} upgates.emit('page.view');upgates.callEvents.forEach(function(event){upgates.emit.apply(null,[event.name,...event.params]);});if($BODY.hasClass('page-hp')){this.currentPage=1;$BODY.on('click','.FiltersPaging [data-page]',function(){upFn.currentPage=$(this).data('page');$.ajax({url:'/?do=products-paginate&products-page='+$(this).data('page'),error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('filtersAfterUpdateProductList');}});return false;});$BODY.on('click','.FiltersSni',function(){upFn.currentPage+=1;$.ajax({url:'/?do=products-paginate&products-page='+upFn.currentPage,error:up.error(),success:function(payload){up.trigger('productsListSni',payload);}});return false;});}} this.initFilters=function(){var $BODY=$('body');$(window).on('popstate',function(e){if(e.originalEvent.state===null){if(up.elExist(up.filterSettings.horizontal)||up.elExist(up.filterSettings.vertical)){var filters=upFn.filterDecodeUrl();}} else{try{var filters=JSON.parse(e.originalEvent.state);}catch(e){}} if(typeof filters!=='object'||filters===null){filters={};} if(!filters.hasOwnProperty('min_price')){filters.min_price=up.filterSettings.defMinPrice;} if(!filters.hasOwnProperty('max_price')){filters.max_price=up.filterSettings.defMaxPrice;} if(!filters.hasOwnProperty('sort')){filters.sort=up.filterSettings.defSort;} if(!filters.hasOwnProperty('page')){var curPage=upFn.filterGetPage();filters.page=curPage?curPage:1;} $.each(up.filters,function(id){if(!filters.hasOwnProperty(id)){filters[id]=false;}});upFn.filtersRemovePagingSuffix();upFn.historyPushState=false;up.setFilters(filters);upFn.historyPushState=true;});up.on('filtersChange',function(){upFn.filtersUpdateElements(up.filters);upFn.filtersUpdateHash(up.filters);if(up.filters.sort){$('.FilterSorting [data-sorting]').removeClass(up.cls.active);$('.FilterSorting [data-sorting='+up.filters.sort+']').addClass(up.cls.active);} $.each(up.filters,function(k,v){if(k==='min_price'){$(up.filterSettings.priceSlider).slider('values',0,up.filters.min_price);} if(k==='max_price'){$(up.filterSettings.priceSlider).slider('values',1,up.filters.max_price);} if(k.indexOf('attrSl')===0&&typeof v==='string'){let slider=$('.AttributeSlider_'+k.split('-')[1]+' .AttributeSlider');if(up.elExist(slider)){let minSign='';if(v.indexOf('-')==0){v=v.substring(1);minSign='-';} let maxSign='';if(v.indexOf('--')!=-1){v=v.replace('--','-');maxSign='-';} slider.slider('values',0,minSign+v.split('-')[0]).slider('values',1,maxSign+v.split('-')[1]);}}});up.trigger('filtersRedrawActiveFilters');});$BODY.on('click','.FilterReset',function(e){let $this=$(this),link=$this.attr('href');if(link!=='#'){window.location=link;} else{e.preventDefault();var filters={};$.each(up.filters,function(id,value){filters[id]=false;});priceSlider=$(up.filterSettings.priceSlider);if(up.elExist(priceSlider)){priceSlider.slider('values',0,up.filterSettings.defMinPrice).slider('values',1,up.filterSettings.defMaxPrice);filters.min_price=up.filterSettings.defMinPrice;filters.max_price=up.filterSettings.defMaxPrice;} $('.AttributeSlider').each(function(){let $this=$(this),attribute_id=$this.data('attribute_id');if(filters.hasOwnProperty('attrSl-'+attribute_id)){$this.slider('values',0,$this.data('min')).slider('values',1,$this.data('max'));filters['attrSl-'+attribute_id]=$this.data('min')+'-'+$this.data('max');}});upFn.filtersRemovePagingSuffix();up.setFilters(filters);} return false;});$BODY.on('click','.FilterSorting [data-sorting]',function(e){upFn.filtersRemovePagingSuffix();let $this=$(this);up.filterSettings.filterStateDisabled=true;up.setFilters({page:1,sort:$this.data('sorting')});$this.trigger('show.bs.tab');e.preventDefault();});$BODY.on('click','.FiltersPaging [data-page]',function(){upFn.filtersRemovePagingSuffix();up.filterSettings.filterStateDisabled=true;up.setFilters({page:$(this).data('page')});up.trigger('afterPaging');return false;});$BODY.on('click','.FiltersSni',function(){upFn.filtersRemovePagingSuffix();up.filterSettings.filterStateDisabled=true;up.filterSettings.pagingSni=true;up.setFilters({page:up.filters.page+1});up.trigger('afterPaging');return false;});var priceSlider=$(up.filterSettings.priceSlider);if(up.elExist(priceSlider)){up.on('priceSliderSlide',function(e,min,max){$('.price-min').html(up.formatNumber(min));$('.FilterPriceMin').val(up.formatCurrency(min,true));$('.price-max').html(up.formatNumber(max));$('.FilterPriceMax').val(up.formatCurrency(max,true));let minEl=$('.PriceSlider .HandleMin'),maxEl=$('.PriceSlider .HandleMax');if(minEl.length&&maxEl.length){minEl.attr('aria-valuenow',min).attr('aria-valuemax',max);maxEl.attr('aria-valuenow',max).attr('aria-valuemin',min);}});up.on('priceSliderChange',function(e,min,max,isOriginalEvent){if(min===up.filterSettings.defMinPrice&&max===up.filterSettings.defMaxPrice){up.filterSettings.priceDefault=true;$('#PriceFilter .value').removeClass(up.cls.active);}else{up.filterSettings.priceDefault=false;$('#PriceFilter .value').addClass(up.cls.active);} if(isOriginalEvent){$(up.filterSettings.priceSlider).slider('values',0,min).slider('values',1,max);upFn.filtersRemovePagingSuffix();up.setFilters({page:1,min_price:min,max_price:max});}});let setFilterPriceTimeout;let setFilterPrice=function(){let minInput=$('input.FilterPriceMin'),min=parseInt(minInput.val().match(/(\d|\.|,)/g).join('')),maxInput=$('input.FilterPriceMax'),max=parseInt(maxInput.val().match(/(\d|\.|,)/g).join(''));if(!Number.isInteger(min)){min=up.filterSettings.defMinPrice;} if(!Number.isInteger(max)){max=up.filterSettings.defMaxPrice;} if(max<min){max=min;} if(max>up.filterSettings.defMaxPrice){max=up.filterSettings.defMaxPrice;} if(min>max){min=max;} if(min<up.filterSettings.defMinPrice){min=up.filterSettings.defMinPrice;} minInput.val(up.formatCurrency(min,true));maxInput.val(up.formatCurrency(max,true));up.trigger('priceSliderChange',min,max,true);};$BODY.on('keyup paste','input.FilterPriceMin',function(){clearTimeout(setFilterPriceTimeout);$('input.FilterPriceMin').val($(this).val());setFilterPriceTimeout=setTimeout(setFilterPrice,900);});$BODY.on('keyup paste','input.FilterPriceMax',function(){clearTimeout(setFilterPriceTimeout);$('input.FilterPriceMax').val($(this).val());setFilterPriceTimeout=setTimeout(setFilterPrice,900);});$BODY.on('focus','input.FilterPriceMin, input.FilterPriceMax',function(){$(this).val(parseInt($(this).val().replace(/\s/g,'')));this.select();});$BODY.on('blur','input.FilterPriceMin, input.FilterPriceMax',function(){$(this).val(up.formatCurrency(parseInt($(this).val().match(/(\d|\.|,)/g).join('')),true));});} if(up.elExist('.AttributeSlider')){up.on('attrSliderSlide',function(e,slider,min,max){$(slider).parent().find(".ValueMin").html(min);$(slider).parent().find(".ValueMax").html(max);let minEl=slider.find('.HandleMin'),maxEl=slider.find('.HandleMax');if(minEl.length&&maxEl.length){minEl.attr('aria-valuenow',min).attr('aria-valuemax',max);maxEl.attr('aria-valuenow',max).attr('aria-valuemin',min);}});up.on('attrSliderChange',function(e,slider,min,max,isOriginalEvent){if(isOriginalEvent){let defMin=slider.data('min'),defMax=slider.data('max'),attribute_id=slider.data('attribute_id'),actualSlider='.AttributeSlider_'+attribute_id,range=min+'-'+max;$(actualSlider+' .AttributeSlider').slider('values',0,min).slider('values',1,max);up.setFilter("attrSl-"+attribute_id,defMin!==min||defMax!==max?range:false);}});} $BODY.on('change',up.filterSettings.horizontal+' input, '+up.filterSettings.horizontal+' select, '+up.filterSettings.vertical+' input, '+up.filterSettings.vertical+' select',function(){let $this=$(this);if(!$this.attr('id')){return;} let id=upFn.filterGetPartialId($this.attr('id')),n={page:1};if($this.is(':checkbox')||$this.is(':radio')){n[id]=$this.prop('checked');}else if($this.is('select')){n[id]=$this.val();} upFn.filtersRemovePagingSuffix();up.setFilters(n);});$BODY.on('click',up.filterSettings.horizontal+' img.FilterParameterImg:not(.FilterPageDisabled), '+up.filterSettings.vertical+' img.FilterParameterImg:not(.FilterPageDisabled)',function(){let $this=$(this),id=upFn.filterGetPartialId($this.attr('id')),imagesEl=$('img.FilterParameterImg[data-name="'+$this.data('name')+'"]');if($this.hasClass(up.cls.active)){imagesEl.removeClass(up.cls.active);up.setFilter(id,false);}else{imagesEl.addClass(up.cls.active);up.setFilter(id,true);} return false;});$BODY.on('click','.ActiveFiltersDelete',function(){let filter_id=$(this).data('filter_id');if(filter_id==='PriceSlider'){$(up.filterSettings.priceSlider).slider('values',0,up.filterSettings.defMinPrice).slider('values',1,up.filterSettings.defMaxPrice);upFn.filtersRemovePagingSuffix();up.setFilters({page:1,min_price:up.filterSettings.defMinPrice,max_price:up.filterSettings.defMaxPrice});}else if(filter_id.startsWith('attrSl-')){let slider=$('.AttributeSlider_'+filter_id.split('-')[1]+' .AttributeSlider');slider.slider('values',0,slider.data('min')).slider('values',1,slider.data('max'));up.setFilter(filter_id,false);}else{up.setFilter(filter_id,false);} return false;});var filters=upFn.filterDecodeUrl();if(window.location.hash.length>0){up.spinnerDisabled=true;upFn.filtersRemovePagingSuffix();up.setFilters(filters);} if(filters.page>1){up.filters.page=filters.page;} if(up.elExist(up.filterSettings.vertical)){$BODY.on('click','.MoreButton, .LessButton',function(){let $this=$(this),$filterEl=$this.parents('.FilterContent'),$show=true,$filterMoreEl=$filterEl.find('.MoreButton'),$filterLessEl=$filterEl.find('.LessButton');if($this.hasClass('LessButton')){$show=false;} if($show){$filterEl.find('.FilterItem:not(".DefaultFilterItem")').removeClass(up.cls.hidden);$filterMoreEl.addClass(up.cls.hidden);$filterLessEl.removeClass(up.cls.hidden);}else{$filterEl.find('.FilterItem:not(".DefaultFilterItem")').addClass(up.cls.hidden);$filterMoreEl.removeClass(up.cls.hidden);$filterLessEl.addClass(up.cls.hidden);}});$('.FilterHeader').each(function(){let $this=$(this),$filterEl=$('#'+$this.data('filter-type')),$itemsToShow=$this.data('show-items'),$itemsCount=$filterEl.find('.FilterItem').length,$filterNextEl=$this.find('.FilterNext'),$filterHideEl=$this.find('.FilterHide'),$filterMoreEl=$filterEl.find('.MoreButton'),$filterLessEl=$filterEl.find('.LessButton');if($itemsToShow){$filterEl.removeClass(up.cls.hidden);$filterNextEl.addClass(up.cls.hidden);$filterHideEl.removeClass(up.cls.hidden);let $count=1;$filterEl.find('.FilterItem').each(function(){if($count<=$itemsToShow){$(this).addClass('DefaultFilterItem').removeClass(up.cls.hidden);$count++;}});if($itemsToShow>=$itemsCount){$filterMoreEl.addClass(up.cls.hidden);$filterLessEl.addClass(up.cls.hidden);}else{$filterMoreEl.removeClass(up.cls.hidden);$filterLessEl.addClass(up.cls.hidden);}}else{$filterEl.addClass(up.cls.hidden);$filterNextEl.removeClass(up.cls.hidden);$filterHideEl.addClass(up.cls.hidden);}});$BODY.on('click','.FilterHeader',function(e){e.preventDefault();let $filterHeaderEl=$(this),$filterEl=$('#'+$filterHeaderEl.data('filter-type')),$show=true,$filterNextEl=$filterHeaderEl.find('.FilterNext'),$filterHideEl=$filterHeaderEl.find('.FilterHide');if(!$filterHideEl.hasClass(up.cls.hidden)){$show=false;} if($show){$filterEl.removeClass(up.cls.hidden);$filterNextEl.addClass(up.cls.hidden);$filterHideEl.removeClass(up.cls.hidden);if(!$filterHeaderEl.data('show-items')){$filterEl.find('.FilterItem').removeClass(up.cls.hidden);}}else{$filterEl.addClass(up.cls.hidden);$filterNextEl.removeClass(up.cls.hidden);$filterHideEl.addClass(up.cls.hidden);}});var filtersEjectSection=function($this){if(typeof $this=='undefined'){return;} let $filterContentEl=$this.parents('.FilterContent'),$filterContentId=$filterContentEl.attr('id'),$filterHeaderEl=$('.FilterHeader[data-filter-type="'+$filterContentId+'"]');if($this.parents('.FilterItem').hasClass(up.cls.hidden)){$filterContentEl.find('.MoreButton').click();} if($filterHeaderEl.data('show-items')===undefined){$filterContentEl.find('.MoreButton, .LessButton').addClass(up.cls.hidden);} if($filterContentEl.hasClass(up.cls.hidden)){$filterHeaderEl.click();}};if(up.elExist($('#TypeFilter'))){$('#TypeFilter :input').each(function(){let $this=$(this);if($this.prop('checked')||$this.hasClass(up.cls.disabled)){filtersEjectSection($this);return false;}});} if(up.elExist($('#PriceFilter'))){if(!up.filterSettings.priceDefault){filtersEjectSection($(this));}} if(up.elExist($('#ManufacturerFilter'))){$('#ManufacturerFilter input:checkbox').each(function(){let $this=$(this);if($this.prop('checked')||$this.hasClass(up.cls.disabled)){filtersEjectSection($this);return false;}});} if(up.elExist($('#BenefitFilter'))){$('#BenefitFilter :input').each(function(){let $this=$(this);if($this.prop('checked')||$this.hasClass(up.cls.disabled)){filtersEjectSection($this);return false;}});} if(up.elExist($('#AttributeSelectFilter'))){$('#AttributeSelectFilter :input').each(function(){let $this=$(this),$thisVal=$this.val();if($thisVal&&($thisVal!=='null'||$thisVal!=='false')){filtersEjectSection($this);return false;}});} $('[id^="Attribute_"] :input').each(function(){let $this=$(this);if($this.prop('checked')||$this.hasClass(up.cls.disabled)){filtersEjectSection($this);}});$('[id^="Attribute_"] img').each(function(){let $this=$(this);if($this.hasClass(up.cls.active)){filtersEjectSection($this);}});} if(typeof filterPage!='undefined'&&filterPage){this.filterStateLoad();}};this.initProducts=function(){var $BODY=$('body');$BODY.on('click','.ProductMoreInfo',function(e){e.preventDefault();let $this=$(this),$productId=$this.data('product-id')===undefined?$this.parents('[data-product-id]').data('product-id'):$this.data('product-id'),$content=up.elExist($this.parents('.ChooseGift'))?'gift':null,$showAddToCartButton=$this.data('show-add-to-cart')===undefined?true:$this.data('show-add-to-cart'),$showDetailButton=$this.data('show-detail')===undefined?true:$this.data('show-detail'),$showCompareButton=$this.data('show-compare')===undefined?true:$this.data('show-compare'),$showFavouritesButton=$this.data('show-add-to-favourites')===undefined?true:$this.data('show-add-to-favourites');$.ajax({url:getProductInfoBoxUrl,data:{product_id:$productId,show_add_to_cart:$showAddToCartButton,show_detail:$showDetailButton,show_compare:$showCompareButton,show_add_to_favourites:$showFavouritesButton},error:up.error(),success:function(payload){$.nette.success(payload);},complete:function(){up.trigger('dialog','product-info-box',null,$content,'afterProductInfoBox');}});return false;});$BODY.on('click','.AddProductToCart',function(e){e.preventDefault();var $this=$(this),$productId=$this.parents('[data-product-id]').data('product-id'),$quantityEl=$('input[name="'+$productId+'_quantity"]'),$quantity=up.elExist($quantityEl)?$quantityEl.val():1;$.ajax({url:addToBasketUrl,data:{product_id:$productId,quantity:$quantity,option_set_id:null},error:up.error(),success:function(payload){$.nette.success(payload);if(payload.error){up.trigger('dialog','alert');}else{var bodyHasClass=$BODY.hasClass(up.cls.cart);if(!payload.redirect&&!bodyHasClass){up.trigger('dialog','cart');if(payload.cartAddEventParams&&payload.cartAddEventParams.product!==null){upgates.emit('cart.add',payload.cartAddEventParams.product,payload.cartAddEventParams.event);}}else if(bodyHasClass){up.trigger('cartInvalidateProducts');}}},complete:function(){up.trigger('afterProductItemAction','cart',$productId);}});return false;});$('.AddProductToCart').addClass('AddProductToCartInitialized');$(window).on('ajaxComplete',function(){$('.AddToCartButton').addClass('AddToCartButtonInitialized');$('.AddProductToCart').addClass('AddProductToCartInitialized');setTimeout(function(){$('.AddToCartButton').addClass('AddToCartButtonInitialized');$('.AddProductToCart').addClass('AddProductToCartInitialized');},300);});up.on('cartInvalidateProducts',function(){$.ajax({url:invalidateProductsUrl,error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('afterCartUpdate');}});});$BODY.on('click','.AddProductFavourites',function(){var $this=$(this);if(!$this.hasClass(up.cls.active)){var productId=$this.parents('[data-product-id]').data('product-id');if($this.hasClass('LoggedIn')){$.ajax({url:addToFavouritesUrl,data:{product_id:productId},error:up.error(),success:function(payload){$.nette.success(payload);if(payload.snippets){up.trigger('dialog','alert');}},complete:function(){up.trigger('afterProductItemAction');}});$this.addClass(up.cls.active);}else{up.trigger('dialog','login');} return false;}else{window.location.href=favouritesLink;}});$BODY.on('click','.AddProductCompareList',function(){var $this=$(this);if(!$this.hasClass(up.cls.active)){var productId=$this.parents('[data-product-id]').data('product-id');$.ajax({url:addToCompareListUrl,data:{product_id:productId},error:up.error(),success:function(payload){$.nette.success(payload);if(payload.snippets){up.trigger('dialog','alert');}},complete:function(){up.trigger('afterProductItemAction');}});$this.addClass(up.cls.active);return false;}else{window.location.href=compareLink;}});$BODY.on('click','#ProductListBoxes, #ProductListTable',function(e){e.preventDefault();var $this=$(this);$.ajax({url:$this.attr('href'),error:up.error(),complete:function(payload){$('#ProductListBoxes, #ProductListTable').removeClass('active');$this.addClass('active');if(upFn.filterDecodeUrl().length==0){$.nette.success(payload);up.trigger('filtersAfterUpdateProductList');up.filterSettings.firstLoad=false;}else{upFn.filtersUpdateProductList();}}});});if($BODY.hasClass(up.cls.product)){var path=window.location.pathname;if(new RegExp(/\/p\/.*?\/\d+/).test(path)){var option_set_id=path.split('/').pop();if(option_set_id){var hash_location=path;var path_location=path;hash_location=hash_location.substr(hash_location.lastIndexOf("/")+1);path_location=path_location.substr(0,path_location.lastIndexOf("/"));history.pushState(undefined,undefined,path_location+window.location.search+"#"+hash_location);}} $BODY.on('change','.variantsObject',function(){var $this=$(this),preselect_inject=$this.closest('.VariantSelect'),name='',serialized=upFn.serializeProductVariants();if($this.val()!=='--'){name=$this.attr('name');} up.trigger('destroyTooltip');if(serialized.variantSelectionComplete){var serialized_configuration=upFn.serializeProductConfigurations();var length=upFn.getProductLength();let data={serialized:serialized.data,length:length,serialized_configuration:serialized_configuration.data};if(preselect_inject.length&&preselect_inject.hasClass('VariantsPreselect')){data.preselect_yn=true;data.name=name;} $.ajax({url:changeVariantsUrl,data:data,error:up.error(),success:function(payload){if(!payload.variantNotComplete){$.nette.success(payload);var $optionSetEl=$('#frmproductForm-option_set_id');upFn.disableOnHashChange=true;if(payload.option_set_id){$optionSetEl.val(payload.option_set_id);history.replaceState(undefined,undefined,"#"+payload.option_set_id);}else{$optionSetEl.val(null);if(window.location.hash!==""){history.replaceState(undefined,undefined,"");}} payload.configurationSelectionComplete=upFn.serializeProductConfigurations().configurationSelectionComplete;up.trigger('productUpdateVariants',payload,false);} $('#options_cancel').removeClass('hidden');}});}else{let preselect_inject=$this.closest('.VariantSelect');if(preselect_inject.length&&preselect_inject.hasClass('VariantsPreselect')){variantPreselectChange(serialized.data,name);}}});var variantPreselectChange=function(data,name){$.ajax({url:variantPreselectUrl,data:{serialized:data,name:name},error:up.error(),success:function(payload){upC.initAfterAjaxFunctions();$.nette.success(payload);var $optionSetEl=$('#frmproductForm-option_set_id');$optionSetEl.val(null);if(window.location.hash!==""){history.replaceState(undefined,undefined,"");history.pushState(null,null,' ');}}}).done(function(){up.trigger('produchtPreselectChangeActive');});};if($BODY.hasClass(up.cls.product)&&$BODY.hasClass('vs')&&$('#frmproductForm-option_set_id').val()===''){$('select.variantsObject').each(function(){var $this=$(this),$optionsEls=$this.children('option[value!="--"]');if($optionsEls.length===1){$this.val($optionsEls.val());if(upFn.serializeProductVariants().variantSelectionComplete){$this.change();}}});} $BODY.on('click','.SelectAttributeVariant',function(){var $this=$(this),option_id=$this.data('option-id'),value=$this.data('attr-value-id');if($this.hasClass(up.cls.active)){value='--';} $this.children().each(function(){if($(this).hasClass(up.cls.active)){value='--';}});up.trigger('productSelectVariantFromSelects',option_id,value);$('#frmproductForm-options-'+option_id).val(value).trigger('change');});$('.addWatchDog').on('shown.bs.modal',function(){var $optionSetEl=$('#frmproductForm-option_set_id');var $optionSetWatchDogEl=$('#frmwatchDogForm-option_set_id');if(($optionSetWatchDogEl.val()===null||$optionSetWatchDogEl.val()==='')&&($optionSetEl.val()!==null||$optionSetEl.val()!=='')){$optionSetWatchDogEl.val($optionSetEl.val());}});var configurationChange=function(e){if(e.relatedTarget){if($(e.relatedTarget).hasClass('AddToCartButton')){return;}} var serialized=upFn.serializeProductConfigurations();var serialized_option_set=upFn.serializeProductVariants();var length=upFn.getProductLength();if(serialized.configurationSelectionComplete){$(".ModifyConfigurations").slideUp(200);}else{$(".ModifyConfigurations").slideDown(200);} let data={serialized:serialized.data,serialized_option_set:serialized_option_set.data,length:length};let preselect_inject=$('.VariantsPreselect');if(preselect_inject.length){data.preselect_yn=true;} $.ajax({url:changeConfigurationUrl,data:data,error:up.error(),success:function(payload){$.nette.success(payload);payload.variantSelectionComplete=upFn.serializeProductVariants().variantSelectionComplete;payload.configurationSelectionComplete=serialized.configurationSelectionComplete;up.trigger('productUpdateConfigurations',payload);up.trigger('produchtPreselectChangeActive');}});};$BODY.on('change','#ConfigurationSelect select.configurationObject, #ConfigurationSelect input:checkbox.configurationObject',configurationChange);$BODY.on('blur','#ConfigurationSelect textarea.configurationObject, #ConfigurationSelect input:text.configurationObject',configurationChange);$BODY.on('change','#ConfigurationSelectTabs .configurationObject',function(){var $this=$(this);var connectedWith=$this.closest("span[data-connected-with]").data("connected-with");$("#"+connectedWith).val($this.val()).trigger("change");$("#"+connectedWith).val($this.val()).trigger("blur");});$BODY.on('click','.SelectAttributeConfiguration',function(){var $this=$(this);var configuration_id=$this.data('configuration-id');var value=$this.data('attr-value-id').toString();var $input;if($this.data("is-group")){var attribute_id=$this.data('attr-id');$input=$('#frmproductForm-configurations-group-'+configuration_id+'-'+attribute_id);configuration_id=configuration_id+"_"+attribute_id;}else{$input=$('#frmproductForm-configurations-'+configuration_id);} var selectedValues=$input.val();if(selectedValues===null){selectedValues=[];} if($.isArray(selectedValues)){if($.inArray(value,selectedValues)>=0){selectedValues=jQuery.grep(selectedValues,function(localvalue){return localvalue!==value;});}else{selectedValues.push(value);} up.trigger('productSelectConfigurationFromSelects',configuration_id,selectedValues);$input.val(selectedValues);}else{if($input.is('select')&&!isNaN(parseInt($input.val()))&&value==$input.val()){value='--';} up.trigger('productSelectConfigurationFromSelects',configuration_id,value);$input.val(value);} $input.trigger('change');});$BODY.on('click','.SelectAttributeConfigurationTab',function(){var $this=$(this);var configuration_id=$this.data('configuration-id');var value=$this.data('attr-value-id').toString();var $originalInput;var $input;if($this.data("is-group")){var attribute_id=$this.data('attr-id');$input=$('#tabs-frmproductForm-configurations-group-'+configuration_id+'-'+attribute_id);$originalInput=$('#frmproductForm-configurations-group-'+configuration_id+'-'+attribute_id);configuration_id=configuration_id+"_"+attribute_id;}else{$originalInput=$input=$('#tabs-frmproductForm-configurations-'+configuration_id);} var selectedValues=$input.val();if(selectedValues===null){selectedValues=[];} if($.isArray(selectedValues)){if($.inArray(value,selectedValues)>=0){selectedValues=jQuery.grep(selectedValues,function(localvalue){return localvalue!==value;});}else{selectedValues.push(value);} up.trigger('productSelectConfigurationFromSelects',configuration_id,selectedValues);$input.val(selectedValues);$originalInput.val(selectedValues);}else{up.trigger('productSelectConfigurationFromSelects',configuration_id,value);$input.val(value);$originalInput.val(value);} $input.trigger('change');$originalInput.trigger('change');});var changeLengthTimeout;var changeLength=function(e){clearTimeout(changeLengthTimeout);if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} let $this=$('.lengthObject'),length=upFn.getProductLength(),steps=$this.data('steps'),length_from=$this.data('length_from'),decimal_places=$this.data('decimal_places');if(steps&&length!==false&&length!==''){if(Number(length)!==length){length=parseFloat(length);} if(Number(steps)!==steps){steps=parseFloat(steps);} let rest=(length%steps).toFixed(6);if(rest!=0){length=length-rest+steps;} if(length_from!==undefined){if(Number(length_from)!==length_from){length_from=parseFloat(length_from);} if(length<length_from&&length_from%steps==0){length=length_from;}} $this.val(length);} if(length!==false&&length!==''&&decimal_places){if(Number(length)!==length){length=parseFloat(length);} if(decimal_places){length=parseFloat(length.toFixed(decimal_places));} $this.val(length);} if(typeof e!='undefined'&&e.relatedTarget){if($(e.relatedTarget).hasClass('AddToCartButton')){return;}} if($this.data('send-value')!=length){let data={serialized:upFn.serializeProductVariants().data,length:length,serialized_configuration:upFn.serializeProductConfigurations().data};let preselect_inject=$('.VariantsPreselect');if(preselect_inject.length){data.preselect_yn=true;} up.ajaxRequest=$.ajax({url:changeVariantsUrl,data:data,error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('productUpdateVariants',payload,true);$this.data('send-value',length);if(length_from!=undefined){if($this.val()<=parseFloat(length_from)){$this.addClass('MinimumValue');}else{$this.removeClass('MinimumValue');}}else{if($this.val()<=1){$this.addClass('MinimumValue');}else{$this.removeClass('MinimumValue');}} $('.lengthObject').focus();up.ajaxRequest=undefined;}});}else{if(length_from!=undefined){if(parseFloat(length)<=parseFloat(length_from)){$this.addClass('MinimumValue');}else{$this.removeClass('MinimumValue');}}else{if(parseFloat(length)){$this.addClass('MinimumValue');}else{$this.removeClass('MinimumValue');}}}};$BODY.on('change','select.lengthObject',changeLength);$BODY.on('keyup input change','input.lengthObject',function(){clearTimeout(changeLengthTimeout);changeLengthTimeout=setTimeout(changeLength,800);});var length=$('.lengthObject');if(up.elExist(length)&&!length.hasClass('NotInit')){if(length.data('length_from')){length.val(length.data('length_from'));length.trigger('change');}} up.on('productAddToCart',function(e,data){if((data).error){if(data.noLength){$('.variantsLengthObject').slideDown();$('.lengthBetweenObject').fadeIn();} up.trigger('dialog','alert');}else{up.trigger('dialog','cart');if(data.cartAddEventParams&&data.cartAddEventParams.product!==null){upgates.emit('cart.add',data.cartAddEventParams.product,data.cartAddEventParams.event);} if(data.snippets!==undefined&&data.snippets['snippet--flashes']!==undefined&&data.snippets['snippet--flashes']!=""){up.trigger('dialog','alert');}} $('#frmproductForm-quantity').val(1);if($('.ChangeQuantity').length){$('.ChangeQuantity').trigger('change');}else if($('.lengthObject').length){let length=$('#frmproductForm-length');length.val(length.is('select')?'--':0);changeLength();}});$BODY.on('click','.AddToCart button.AddToCartButton, #frmproductForm-order',function(){$(this).parents('#frm-productForm').ajaxSubmit(function(payload){$.nette.success(payload);up.trigger('productAddToCart',payload);});return false;});$('.AddToCartButton').addClass('AddToCartButtonInitialized');up.on('productSetVariant',function(e,doneVar,asynch){var length=upFn.getProductLength();var id=window.location.hash.replace('#','');if(id===''){id=$('#frmproductForm-option_set_id').val();} let data={optionSetId:id,length:length,product_gift_id:$('input[name="product_gift_id"]:checked').val()};let preselect_inject=$('.VariantsPreselect');if(preselect_inject.length){data.preselect_yn=true;} $.ajax({url:setVariantsUrl,data:data,error:up.error(),success:function(payload){$.nette.success(payload);$('#frmproductForm-option_set_id').val(payload.option_set_id);up.trigger('productUpdateVariants',payload,false);},async:typeof asynch=='undefined'?true:asynch,}).done(function(){if(doneVar){$('#frmproductForm-order').trigger('click');} var $lengthEl=$('.lengthObject');if(up.elExist($lengthEl)){$lengthEl.val(length);} $('#options_cancel').removeClass('hidden');});});var updateVariantByHash=function(asynch){if($.isNumeric(window.location.hash.replace('#',''))){up.trigger('productSetVariant',false,asynch);}};updateVariantByHash(false);$(window).bind('hashchange',function(e){if(!upFn.disableOnHashChange){updateVariantByHash(true);upFn.disableOnHashChange=false;}});$BODY.on('click','.AddVariantToCart',function(){var option_set_id=$(this).data('option-set-id'),quantity_id='quantity-'+option_set_id,length=$("#frmproductForm-length").val();window.location.hash=option_set_id;if(length===""||length==="0"){up.scrollToEl("#detail-buy");}else if($("#"+quantity_id).length>0){$("#frmproductForm-quantity").val($("#"+quantity_id).val());} up.trigger('productSetVariant',true);});$BODY.on('click','.SetVariantForWachDog',function(){$('#frmwatchDogForm-option_set_id').val($(this).data('option-set-id'));});$('.deleteWatchDog').on('click',function(){$.ajax({url:deleteWatchDogUrl,data:{product:$(this).data('product-id'),optionset:$(this).data('option-set-id')},error:up.error(),success:function(payload){$.nette.success(payload);}});});up.on('productQuantityChange',function(e,id,quantity){const $optionSetEl=$('#frmproductForm-option_set_id');var length=upFn.getProductLength();$.ajax({url:changeQuantityUrl,data:{product_id:id,option_set_id:$optionSetEl.length?$optionSetEl.val():NULL,quantity:quantity,length:length},error:up.error(),success:function(payload){$.nette.success(payload);}});});var productQuantityChangeTimeout;$BODY.on('keyup change','.ChangeQuantity',function(e){if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} var $this=$(this);if($this.attr('data-product-id')!==undefined){clearTimeout(productQuantityChangeTimeout);productQuantityChangeTimeout=setTimeout(function(){up.trigger('productQuantityChange',$this.attr('data-product-id'),$this.val());},500);} if($this.val()<=1){$this.addClass('MinimumValue');}else{$this.removeClass('MinimumValue');}});if(up.elExist($('#ConfigurationSelect'))){if(up.elExist($('#ConfigurationSelectTabs'))){$('#ConfigurationSelect :input').each(function(){var clonedInput=$(this).clone();clonedInput.attr("id","tabs-"+clonedInput.attr("id"));$('#ConfigurationSelectTabs span[data-connected-with="'+$(this).attr("id")+'"]').html(clonedInput);});} var required=$("#ConfigurationSelect .configurationObject[data-is-required='true'], #ConfigurationSelect .configurationObject[data-has-default-value='true']");if(up.elExist(required)){required.first().trigger('change');}} var optionSetIdEl=$('#frmproductForm-option_set_id');if(up.elExist(optionSetIdEl)&&optionSetIdEl.val()!==""){upFn.disableOnHashChange=true;window.location.hash=optionSetIdEl.val();}}};this.initCart=function(){var $BODY=$('body');if($BODY.hasClass(up.cls.cart)){up.on('cartQuantityChange',function(e,id){var key=id.replace('quantity-object_','');$.ajax({url:changeQuantityUrl,data:{product:key+';'+$('#'+id).val()+';',serialized:upFn.getQuantitiesOfProductsInCart()},error:up.error(),success:function(payload){$.nette.success(payload);if(payload.quantity_exceed===true){up.trigger('dialog','alert');if(payload.data_id!==undefined){$('tr[data-id="'+payload.data_id+'"] .LowStockWarning').removeClass(up.cls.hidden);}}else{up.trigger('cartTicks',key);} up.trigger('afterCartUpdate');up.trigger('afterCartGiftsUpdate');if(payload.cartGiftChangedYn!==undefined){up.trigger('dialog','alert');}}});});var cartTicksDelayTimeout;up.on('cartTicks',function(e,key){$('.TickCart_'+key).removeClass(up.cls.hidden);clearTimeout(cartTicksDelayTimeout);cartTicksDelayTimeout=setTimeout(function(){$('.TickCart_'+key).addClass(up.cls.hidden);},1500);});up.on('useDiscount',function(e,type,status){$.ajax({url:useDiscountUrl,data:{type:type,status:status?1:0,serialized:upFn.getQuantitiesOfProductsInCart()},error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('afterCartUpdate');up.trigger('afterCartGiftsUpdate');if(payload.cartGiftChangedYn!==undefined){up.trigger('dialog','alert');}}});});up.on('cartSetVoucher',function(){var $code=$('.VoucherCode');var type=$code.data('voucher-type');up.ajaxRequest=$.ajax({url:findVoucherUrl,data:{code:$code.val(),serialized:upFn.getQuantitiesOfProductsInCart(),type:type!==undefined?type:null},global:false,error:up.error(),success:function(payload){$.nette.success(payload);var $code=$('.VoucherCode');$code.focus();$code[0].setSelectionRange($code.val().length,$code.val().length);up.trigger('afterCartUpdate');up.trigger('afterCartGiftsUpdate');if(payload.cartGiftChangedYn!==undefined){up.trigger('dialog','alert');}},complete:function(){up.ajaxRequest=undefined;}});});up.on('cartSetPoints',function(){var $pointsVal=$('.PointsObject').val();var $points=$pointsVal!==""?parseInt($pointsVal):0;var $availablePoints=parseInt($('.AvailablePoints').val());if($points>0&&$points<=$availablePoints){up.ajaxRequest=$.ajax({url:setPointsUrl,data:{points:$points,serialized:upFn.getQuantitiesOfProductsInCart()},global:false,error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('afterCartGiftsUpdate');if(payload.cartGiftChangedYn!==undefined){up.trigger('dialog','alert');}},complete:function(){$points=$('.PointsObject').val();$('.PointsObject').focus().val('').val($points);up.trigger('afterCartUpdate');up.ajaxRequest=undefined;}});}else if($points>$availablePoints){$('.MaxPointsAlert').removeClass(up.cls.hidden);} up.trigger('afterCartUpdate');});let isHandleCheckExceedQuantitiesSetYn=typeof checkExceedQuantitiesUrl!=='undefined';if(up.elExist('.QuantityObject')&&isHandleCheckExceedQuantitiesSetYn){$.ajax({url:checkExceedQuantitiesUrl,global:false,error:up.error(),success:function(payload){$.nette.success(payload);if(payload.exceed_products!==''&&payload.exceed_products!==undefined){var products=payload.exceed_products.split(';');for(var $i=0,$len=products.length;$i<$len;$i++){$('tr[data-id="'+products[$i]+'"] .LowStockWarning').removeClass(up.cls.hidden);}}}});} var $inputVoucher=$('.VoucherCode');if(up.elExist($inputVoucher)&&($inputVoucher.val().length>0)){up.trigger('cartSetVoucher');} var $inputPoints=$('.PointsObject');if(up.elExist($inputPoints)&&($inputPoints.val().length>0)){up.trigger('cartSetPoints');} var cartQuantityChangeTimeout;$BODY.on('keyup change','.QuantityObject',function(e){if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} var $id=$(this).attr('id');if($('#'+$id).val()!==''){clearTimeout(cartQuantityChangeTimeout);cartQuantityChangeTimeout=setTimeout(function(){up.trigger('cartQuantityChange',$id);},700);}});var cartSetVoucherWaitTimeout;$BODY.on('input keydown paste','.VoucherCode',function(){if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} clearTimeout(cartSetVoucherWaitTimeout);cartSetVoucherWaitTimeout=setTimeout(function(){up.trigger('cartSetVoucher');},600);});var cartSetPointsWaitTimeout;var $oldPoints=$('.PointsObject').val();$BODY.on('keyup','.PointsObject',function(){if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} clearTimeout(cartSetPointsWaitTimeout);var $newPoints=$(this).val();if($oldPoints!==$newPoints){cartSetPointsWaitTimeout=setTimeout(function(){up.trigger('cartSetPoints');$oldPoints=$newPoints;},400);}});$BODY.on('click','.DeleteProduct',function(){var $row=$(this).parents('.CartRow');var $key=$row.data('keyname');$row.fadeOut('slow');$.ajax({url:deleteProductUrl,data:{key:$key},error:up.error(),success:function(payload){$.nette.success(payload);if(payload.cartRemoveEventParams){upgates.emit('cart.remove',payload.cartRemoveEventParams);} up.trigger('afterCartGiftsUpdate');if(payload.cartGiftChangedYn!==undefined){up.trigger('dialog','alert');}}});});$BODY.on('click','.DeleteVoucher',function(){let type=null;let checked=$('.DiscountCard:checked');if(checked.length&&checked.attr('id')!==undefined){switch(checked.attr('id').replace('ShowVoucher-','')){case"DiscountCard":type="voucher";break;case"ShowSphereCard":type="sphere_card";break;case"ShowCarte":type="carte";break;}} $('.DiscountCard').prop('checked',false);up.trigger('useDiscount',type,false);});$BODY.on('click','.DeletePoints',function(){$('#ShowPoints input:checkbox').prop('checked',false).change();});up.on('setCartGift',function(e,carts_gifts_setting_id,status){$.ajax({url:changeCartGiftUrl,data:{carts_gifts_setting_id:carts_gifts_setting_id,status:status},error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('afterCartGiftsUpdate');if(payload.cartGiftChangedYn!==undefined){up.trigger('dialog','alert');}}});});$BODY.on('click','.ChooseCartGift',function(){let $this=$(this);let status=$this.attr('data-status')!==undefined?$this.attr('data-status'):0;let carts_gifts_setting_id=$this.attr('data-carts_gifts_setting_id');if(carts_gifts_setting_id!=undefined){up.trigger('setCartGift',carts_gifts_setting_id,status);}});} if($BODY.hasClass(up.cls.shipment)){up.on('setShipment',function(e,shipment_id,affiliate_id){up.trigger('beforeSetShipment',shipment_id);$.ajax({url:setShipmentUrl,data:{shipment_id:shipment_id,affiliate_id:affiliate_id},error:up.error(),success:function(payload){$.nette.success(payload);upFn.shipment_id=shipment_id;upFn.affiliate_id=affiliate_id;if(!payload.individual){$.each(payload.availablePayments.split(';'),function(i,v){if(v!==''){v=v.split('_');var payment_id=v[0],state=v[1],row=$('.Payment_'+payment_id),radio=row.find('input:radio');if(row.length===0){$('input:radio[data-payment_id='+payment_id+']').each(function(){var row=$(this).parents('.ChoosePayment');var radio=$(this);if(state==='0'){radio.prop('disabled',true);row.addClass(up.cls.disabled);}else{radio.prop('disabled',false);row.removeClass(up.cls.disabled);}});}else{if(state==='0'){radio.prop('disabled',true);row.addClass(up.cls.disabled);}else{radio.prop('disabled',false);row.removeClass(up.cls.disabled);}}}});if(payload.unsetPaymentId){var radio=$('.Payment_'+payload.unsetPaymentId+' input:radio');if(radio.length===0){var radio=$('input:radio[data-payment_id='+payload.unsetPaymentId+']');if(radio.parents('.ChoosePayment').hasClass('PayUPayments')){radio=$('.PayUPayments input:radio');}} radio.prop('checked',false);if(upFn.payment_id==payload.unsetPaymentId){upFn.payment_id=null;} up.trigger('afterSetPayment');} $('input:radio').each(function(){if($(this).data('shipment_id')!=shipment_id){$(this).removeAttr('data-affiliate_id');}});$('.AffiliateName').addClass(up.cls.hidden);if(payload.affiliate_name){$('#AffiliateName-'+payload.shipment_id).html(payload.affiliate_name).removeClass(up.cls.hidden);} if(payload.shipment_affiliates_yn&&!payload.autoChoose){let shipment=$('input[data-shipment_id='+payload.shipment_id+']'),apiKey=shipment.data('zasilkovna_shop_id'),carrierId=null,country=shipment.data('selected_country_id'),options=shipment.data('options');if(options&&options.zasilkovna_shop_id){apiKey=options.zasilkovna_shop_id;} if(options&&options.packeta_carrier_id){carrierId=options.packeta_carrier_id;} if(payload.shipment_type=='custom'&&payload.affiliates_count<=300){$.ajax({url:loadAllAffiliatesUrl,data:{shipment_id:payload.shipment_id},error:up.error(),success:function(payload){$.nette.success(payload);let $affiliates=$('#ChooseCustomAffiliatesDialog');up.trigger('dialog','info',$affiliates.data('popup-title'),$('#snippet--affiliateChoose').detach(),null,$affiliates.data('add-dialog-class'));$('.ChooseAffiliateSet').first().click();}});} else if(payload.shipment_type=='zasilkovna'&&apiKey){upPacketa.init({apiKey:apiKey,country:country,carrierId:carrierId},function(name){var el=$('#AffiliateName-'+upFn.shipment_id);el.html(name).removeClass(up.cls.hidden);up.scrollToEl(el);},function(){up.error();});} else if(payload.shipment_type=='ceskaPosta'&&typeof upCp!='undefined'){upCp.init({balikovna_yn:payload.balikovna_yn},function(name){var el=$('#AffiliateName-'+upFn.shipment_id);el.html(name).removeClass(up.cls.hidden);up.scrollToEl(el);},function(){up.error();});} else if(payload.shipment_type=='wedo'&&typeof upWd!='undefined'){upWd.init({type:payload.wedo_type,country:country},function(name){var el=$('#AffiliateName-'+upFn.shipment_id);el.html(name).removeClass(up.cls.hidden);up.scrollToEl(el);},function(){up.error();});} else if(payload.shipment_type=='depo'&&typeof upDepo!='undefined'){upDepo.init({clientId:430},function(name){var el=$('#AffiliateName-'+upFn.shipment_id);el.html(name).removeClass(up.cls.hidden);up.scrollToEl(el);},function(){up.error();});} else if(payload.shipment_type=='ppl'&&typeof upPpl!='undefined'){upPpl.init({type:payload.ppl_type,country:country},function(name){var el=$('#AffiliateName-'+upFn.shipment_id);el.html(name).removeClass(up.cls.hidden);up.scrollToEl(el);},function(){up.error();});} else{let $affiliates=$('#ChooseAffiliatesDialog');$('.InputCityZip').val('');$('.AffiliateInfo').addClass(up.cls.hidden);up.trigger('dialog','info',$affiliates.data('popup-title'),$affiliates.html(),null,$affiliates.data('add-dialog-class'));up.trigger('initAffilTypeahead');}}else{up.trigger('afterSetShipment');}}}});});up.on('showMap',function(e,sel,address){$(sel).html('<iframe width="100%" height="400" src="https://www.google.com/maps/embed/v1/place?key=API_KEY&q=ADDRESS" frameborder="0" scrolling="no"></iframe>'.replace('API_KEY','AIzaSyBVO9tjpPXDhw-X0NmAjSr1gtAsdb_z2Cw').replace('ADDRESS',address));});up.on('hideMap',function(e,sel){$(sel).empty().addClass(up.cls.hidden);});$BODY.on('change','#ShipmentCountrySelect',function(){var $this=$(this);$.ajax({url:$this.data('href'),data:{country_id:$this.val()},error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('shipmentPaymentReloaded');}});});$BODY.on('change','.ChooseShipment input:radio',function(){var $this=$(this);if($this.prop('checked')){up.trigger('setShipment',$this.data('shipment_id'),$this.data('affiliate_id'));}});$BODY.on('click tap','.ChooseShipment',function(e){var target=$(e.target);if(!target.is('input:radio')&&target.parents('[data-toggle="tooltip"]').length===0&&!$(this).hasClass(up.cls.disabled)){$(this).find('input:radio').prop('checked',true).change();}});var $shipments=$('.ChooseShipment');if($shipments.length===1){$shipments.first().find('input:radio').click();} var ship=$('#ShipmentsList input:radio:checked');if(ship){upFn.shipment_id=ship.data('shipment_id');} var pay=$('#PaymentsList input:radio:checked');if(pay){upFn.payment_id=pay.data('payment_id');} up.on('setPayment',function(e,payment_id,paytype){up.trigger('beforeSetPayment',payment_id,paytype);$.ajax({url:setPaymentUrl,data:{payment_id:payment_id,pay_type:paytype},error:up.error(),success:function(payload){$.nette.success(payload);upFn.payment_id=payment_id;if(payload.unsetShipmentId){$('input:radio[data-shipment_id='+payload.unsetShipmentId+']').prop('checked',false);if(upFn.shipment_id==payload.unsetShipmentId){upFn.shipment_id=null;} up.trigger('afterSetShipment');} up.trigger('afterSetPayment');upgates.emit('checkout.payment.select',{payment:{},events:payload.events});}});});$BODY.on('change','.ChoosePayment input:radio',function(){var $this=$(this);if($this.prop('checked')){up.trigger('setPayment',$this.data('payment_id'),$this.data('payu-type'));}});$BODY.on('click','.ChoosePayment',function(e){var target=$(e.target);if(!target.is('input:radio')&&target.parents('[data-toggle="modal"]').length===0&&target.parents('[data-toggle="tooltip"]').length===0&&!$(this).hasClass(up.cls.disabled)){$(this).find('input:radio:not(:disabled)').prop('checked',true).change();}});$BODY.on('click','.hotspot',function(){var $this=$(this);up.trigger('dialog','info',$this.data('hotspot-title'),$this.data('hotspot-text'));});$BODY.on('click','.ChooseAffiliateSet',function(){var $this=$(this);up.trigger('onSetAffiliate',{affiliate_id:$this.data('affiliate_id'),name:$this.text(),zip:$this.data('zip'),street:$this.data('street'),city:$this.data('city')});});upgates.emit('checkout.initiate');up.on('afterSetShipment',function(){upgates.emit('checkout.shipment.select',{});});} if($BODY.hasClass(up.cls.checkout)){$BODY.on('click','.tabs-order a, .order-buttons button, .order-buttons a, .CheckoutAlert a, .InvoiceCountryShipmentAlert a, .CountryShipmentAlert a',function(e){var $this=$(this);if($this.hasClass(up.cls.disabled)||$this.parent().hasClass(up.cls.disabled)){return;} var $href=$this.data('href');if(!$href){$href=$this.attr('href');} if($href){var form=$('#frm-registerSummaryForm');if(up.elExist(form)&&form.is(':visible')){form.removeAttr('onsubmit');e.preventDefault();$('#frmregisterSummaryForm-redirect').val($href);form.submit();} var deliveryAddressForm=$('#DeliveryAddressForm');if(up.elExist(deliveryAddressForm)&&!deliveryAddressForm.hasClass(up.cls.hidden)){e.preventDefault();$('#frmchangeDeliveryAddressForm-redirect').val($href);deliveryAddressForm.find('form:first').submit();}}});var checkEmailTimeout=null;$BODY.on('input keydown paste','#frmregisterSummaryForm-email',function(e){var $this=$(this);if($this.attr('readonly')||$this.attr('disabled')){return;} var inputValue=e.which;if(!(inputValue>=65&&inputValue<=120)&&(inputValue!=32&&inputValue!=0&&inputValue!==undefined)){return;} clearTimeout(checkEmailTimeout);var email=$this.val();if(up.ajaxRequest!==undefined){up.ajaxRequest.abort();} up.trigger('showHideCheckoutEmailAlert',null,false);if(email.length==0){return;} if(nette.validateControl($this.get(0))){return;} var type=e.handleObj.origType;var timeout=0;if(type==='input'||(type==='keydown'&&e.keyCode!==13)){timeout=600;} checkEmailTimeout=setTimeout(function(){up.ajaxRequest=$.ajax({url:'?do=checkEmail',data:{email:email},error:up.error(),success:function(payload){if(payload.alertType){up.trigger('showHideCheckoutEmailAlert',payload.alertType,true);} else{up.trigger('showHideCheckoutEmailAlert',null,false);} var becomeCustomer=$('#frmregisterSummaryForm-become_customer_yn');if(payload.disableBecomeCustomerYn){becomeCustomer.prop('disabled',true).prop('checked',false);}else{becomeCustomer.prop('disabled',false);} if(payload.setEmailIntoLogonForm){$('#frmcustomerLoginForm-email').val(email);}},complete:function(){up.ajaxRequest=undefined;}});},timeout);if(e.keyCode===13){e.preventDefault();e.stopPropagation();}});$BODY.on('change','#frmregisterSummaryForm-company_yn_checkbox',function(){let becomeCustomer=$('#frmregisterSummaryForm-become_customer_yn');if(becomeCustomer.data('allow_only_companies_registration')==1){if($(this).prop('checked')){becomeCustomer.prop('disabled',false);}else{becomeCustomer.prop('disabled',true).prop('checked',false);}}});up.on('onSendOrder',function(e,form){var sendOrder=function(){up.ajaxRequest=$.ajax({url:form.attr('action'),type:form.attr('method'),data:data,error:function(){$(window).off('beforeunload');up.trigger('dialog','info',':-(',error_ajax_order);},success:function(payload){$(window).off('beforeunload');if(payload.redirect){window.location.href=payload.redirect;} if(payload.snippets){$.nette.success(payload);up.trigger('dialog','alert');}},complete:function(){up.ajaxRequest=undefined;}});};up.trigger('showPreloader');if(up.ajaxRequest!==undefined){return;} $(window).on('beforeunload',function(){return'Vaše objednávka se zpracovává, opravdu chcete opustit stránku?';});var data={};var formData=form.serializeArray();for(var i in formData){data[formData[i].name]=formData[i].value;} if(typeof Twisto==='object'&&cart.payment.type=='twisto'){$.ajax({url:prepareTwistoDataUrl,type:'POST',data:data,error:up.error(),success:function(payload){if(typeof payload.error!=='undefined'){console.log(payload.error);}else{Twisto.check(payload.payload,function(response){if(response.status=='accepted'){data['transaction_id']=response.transaction_id;sendOrder();}else{up.trigger('dialog','info','Twisto',response.reason);}},function(error){console.log(error);});}}});}else{sendOrder();}});$BODY.on('change','#frmregisterSummaryForm-optional_data_yn',function(){up.trigger('optionalDataCheckout',$(this));});$BODY.on('click','.SendNewPassword',function(){var $email=$('#frmcheckoutLoginForm-email').val();$.ajax({url:sendNewPassUrl,data:{email:$email},error:up.error(),success:function(payload){$.nette.success(payload);up.trigger('dialog','alert');}});$BODY.off('click','.SendNewPassword');$(".SendNewPassword").addClass(up.cls.hidden).removeAttr("href");var parentSendNewPassword=$(".SendNewPassword").parent();if(parentSendNewPassword.hasClass("help-block")){parentSendNewPassword.addClass(up.cls.hidden);} $(".SendNewPassword-Sent").removeClass(up.cls.hidden);});$BODY.on('click','.ContinueWithoutLogging',function(){var $email=$('#frmcheckoutLoginForm-email').val();$.ajax({url:continueWithoutLoggingUrl,data:{email:$email},error:up.error(),success:function(payload){$.nette.success(payload);}});});$('#frm-checkoutEmailForm').submit(function(){$(this).ajaxSubmit(function(payload){$.nette.success(payload);if(payload.novalid){up.trigger('dialog','alert');}else{if(payload.customer_exist){$("#frm-checkoutLoginForm").fadeIn("slow");$("#frmcheckoutLoginForm-password").focus();}else{$("#frm-registerSummaryForm").fadeIn("slow");}}});return false;});$BODY.on('click','.GoToShipment',function(){var $this=$(this);var $deliveryAddressForm=$('#DeliveryAddressForm');if(up.elExist($deliveryAddressForm)&&!$deliveryAddressForm.hasClass(up.cls.hidden)){$deliveryAddressForm.find('form:first').submit();}else{$this.removeClass('GoToShipment');window.location.href=$this.data('shipment-href');}});$BODY.on('change','#DeliveryAddressSelect',function(){$.ajax({url:changeDeliveryAddressUrl,data:{address_id:$(this).val()},error:up.error(),success:function(payload){$.nette.success(payload);}});});$BODY.on('change','#DeliveryAddressSelect2',function(){var $form=$(this).parents('form'),$option=$(this).find('option:selected'),inputs=['firstname_postal','surname_postal','street','city','state','zip','country_id','company_postal','address_id'];for(var index in inputs){var key=inputs[index],$el=$form.find('[name='+key+']');if($el.length){$el.val($option.data(key)).trigger('change');}}});} if($BODY.hasClass(up.cls.paymentGateway)){up.on('checkPayment',function(){$.ajax({url:checkPaymentUrl+$('.ProcessingPayment').find('input[name="PaymentParams"]').val(),global:false,error:up.error(),success:function(payload){if(($.now()-upFn.checkPaymentStartTime)>20000){window.location.href=payload.redirectPage;}else{up.trigger('checkPayment');}}});});this.checkPaymentStartTime=$.now();up.trigger('checkPayment');} if($BODY.hasClass(up.cls.recieved)){if(typeof markOrderRecievedUrl!=='undefined'){$.ajax({url:markOrderRecievedUrl,error:up.error()});}}};this.initForms=function(){var $BODY=$('body');$BODY.on('submit','form.ajax',function(e){e.preventDefault();var $this=$(this);var nospam=$this.find('input[name=nospam]');if(!up.elExist(nospam)||(up.elExist(nospam)&&$this.data("verified"))){$this.ajaxSubmit(function(payload){$.nette.success(payload);up.trigger('dialog','alert');up.trigger('afterAjaxSubmitForm',$this.attr('id'));});} return false;});$('.form-readonly input, .form-readonly select').attr('disabled',true);var $dynamicFormEmailEl=$('#DynamicFormEmail');if(up.elExist($('#frm-dynamicForm-dynamicFormForm'))){if(up.elExist($dynamicFormEmailEl)){$('#frmdynamicFormForm-formEmailCarbonCopy').val($dynamicFormEmailEl.html());} $BODY.on('submit','#frm-dynamicForm-dynamicFormForm',function(){$("#frmdynamicFormForm-formUrl").val(window.location.href);});} var $questionForm=$('form.dialogQuestionForm');if(up.elExist($('form input[name=nospam]'))&&up.elExist($questionForm)){$BODY.on('click','form.dialogQuestionForm button[name=send]',function(){var $answerInput=$questionForm.find('input[name=answer]');var $answer=$answerInput.val();if($answer.length==0){$answerInput.parents('div').addClass('has-error');alert($answerInput.data("no_answer_message"));}else{var $form_id='#'+$questionForm.find('input[name=form_id]').val();var $check=$($form_id).find("input[name=check]").val();$.ajax({url:$questionForm.data('url'),data:{answer:$answer,check:$check},error:up.error(),success:function(payload){if(payload.formAnswerCorrect==true){$($form_id).find("input[name=answer]").val($answer);$($form_id).data("verified",1);$($form_id).submit();}else{$answerInput.parents('div').addClass('has-error');alert($answerInput.data("wrong_answer_message"));}}});}});$BODY.on('submit','form',function(e){var $this=$(this);if(up.elExist($this.find('input[name=question]'))&&up.elExist($this.find('input[name=nospam]'))){if($this.data("verified")!=1){var formValid=true;$this.find('input, select, textarea').each(function(){if($(this).attr('id')!==undefined){if(nette.validateControl($(this).get(0))){formValid=false;}}});if(formValid){$questionForm.find('.Question').text($this.find("input[name=question]").val());var $answerInput=$questionForm.find('input[name=answer]');$answerInput.val("");$answerInput.parents('div').removeClass('has-error');$questionForm.find('input[name=form_id]').val($this.attr('id'));$questionForm.removeClass(up.cls.hidden);up.trigger('dialog',"info",$questionForm.data('title'),$questionForm);setTimeout(function(){$answerInput.focus();},500);e.stopPropagation();e.preventDefault();return false;}} else{$this.data("verified",0);$questionForm.removeData('form_id');$questionForm.parents('.dialogInfo').find('button.close').click();$questionForm.addClass(up.cls.hidden);}}});} $(window).on('load ajaxComplete',function(){$.each(['customerRegistrationForm','customerEditForm','registerSummaryForm'],function(index,value){let $form=$('#frm-'+value);if(up.elExist($form)&&up.elExist($form.find('input[name="company_yn_checkbox"]'))){$form.find('input[name="company_yn_checkbox_exist"]').val(1);}});});$BODY.on('click','.SearchCompany',function(){if(up.elExist('.SearchCompanyIco')){let el=$('.SearchCompanyIco'),ico=el.val(),notFoundMessage=$(this).data("notfound-message"),validation=nette.validateControl(document.getElementById(el.attr('id')));if(validation){alert(validation);return false;} $.ajax({url:searchCompanyUrl,data:{ico:ico},error:up.error(),success:function(payload){if(payload.companyData){let d=payload.companyData,form=$('.SearchCompanyIco').parents('form'),vat_payer=form.find('input[name=vat_payer_yn]');$.each(['company','dic','invoice_street','invoice_city','invoice_zip'],function(k,v){form.find('input[name='+v+']').val(d[v]).trigger('change');});if(up.elExist(vat_payer)){vat_payer.prop('checked',!vat_payer.prop('disabled')&&d.dic);} vat_payer.trigger('change');form.find('select[name=invoice_country_id]').val(d.invoice_country_id).trigger('change');}else if(notFoundMessage){alert(notFoundMessage);}}});} return false;});$BODY.on('change','.VerifyVatPayer',function(){let $this=$(this),form=$this.parents('form'),dic=form.find('input[name=dic]'),company=form.find('input[name=company]'),country_id=form.find('select[name=invoice_country_id]'),sendCheckoutForm=function(){if($BODY.hasClass(up.cls.checkout)){up.trigger('showPreloader');var form=$('#frm-registerSummaryForm');form.removeAttr('onsubmit');$('#frmregisterSummaryForm-redirect').val(location.pathname);form.submit();}},isValid=true;if(!$this.prop('checked')){dic.change();sendCheckoutForm();return;} $.each([dic,company,country_id],function(k,v){let validation=nette.validateControl(document.getElementById(v.attr('id')));if(validation){v.change();alert(validation);isValid=false;return false;}});if(!isValid){$this.prop('checked',false);return;} $.ajax({url:verifyVatPayerUrl,data:{dic:dic.val(),company:company.val(),country_id:country_id.val()},error:up.error(),success:function(payload){if(payload.result){if(!payload.result.valid){$this.prop('checked',false);}else{sendCheckoutForm();} if(payload.result.message){alert(payload.result.message);}}}});});if(up.elExist('.PhoneValidation')){$BODY.on('input keydown keyup mousedown mouseup select contextmenu drop','.PhoneValidation',function(){if(/^\+?(\s*\d*)*$/.test(this.value)){this.oldValue=this.value;this.oldSelectionStart=this.selectionStart;this.oldSelectionEnd=this.selectionEnd;}else if(this.hasOwnProperty("oldValue")){this.value=this.oldValue;this.setSelectionRange(this.oldSelectionStart,this.oldSelectionEnd);}});$BODY.on('focus','.PhoneValidation',function(){$(this).val(String($(this).val()).replace(/ /g,'').trim());});$BODY.on('change blur','.PhoneValidation',function(){let $this=$(this),value=String($this.val()).replace(/ /g,'').trim(),sign=false;if(value.startsWith('+')){sign=true;} if(value.startsWith('00')){value=value.substring(2);sign=true;} value=value.match(/\d/g);if(value){value=value.join('');if(sign){value='+'+value;let calling_codes=$this.data('calling_codes');if(calling_codes){$.each(calling_codes.split(' '),function(i,v){let code='+'+v.split(':')[1];if(value.startsWith(code)){value=value.replace(code,code+' ');return false;}});}} $this.val(value.trim());}else{$this.val(sign?'+':'');}});$BODY.on('change','.PhoneValidationCountry',function(){let $this=$(this),id=$this.data('phone_validation_input_id');if(id){let phone=$('#'+id);if(phone.val().startsWith(phone.data('default_calling_code'))){let calling_code=null,calling_codes=phone.data('calling_codes');if(calling_codes){$.each(calling_codes.split(' '),function(i,v){if(v.split(':')[0]==$this.val()){calling_code=v.split(':')[1];}});} if(calling_code){phone.val(phone.val().replace(phone.data('default_calling_code'),'+'+calling_code));phone.data('default_calling_code','+'+calling_code);}}}});}};} var upFn=new upFunctions();upFn.init();