var currentPage = false; var accsShown = false; var denyProductPlacements = false; function on_mousestop(callback){ var callback = typeof callback !== 'undefined' ? callback : false; if(jQuery().mousestop){ if(callback){ callback(); } }else{ setTimeout(function(){on_mousestop(callback)},250); } } if(typeof gtag === 'undefined'){ function gtag(){} } function on_orientationchange(callback){ var callback = typeof callback !== 'undefined' ? callback : false; if(jQuery().orientationchange){ if(callback){ callback(); } }else{ setTimeout(function(){on_orientationchange(callback)},250); } } /* function on_sly(callback){ var callback = typeof callback !== 'undefined' ? callback : false; if(jQuery().sly){ if(callback){ callback(); } }else{ setTimeout(function(){on_sly(callback)},250); } } */ function on_visible(callback){ var callback = typeof callback !== 'undefined' ? callback : false; if(jQuery().visible){ if(callback){ callback(); } }else{ setTimeout(function(){on_visible(callback)},250); } } function on_history(callback){ var callback = typeof callback !== 'undefined' ? callback : false; if(History.getState==undefined){ setTimeout(function(){on_history(callback)},250); }else{ if(callback){ callback(); } } } var deviceGalleryTO; function deviceGalleryLazy(){ lazyLoadImgs(); clearTimeout(deviceGalleryTO); deviceGalleryTO = setTimeout(deviceGalleryLazy,1000); } $(window).on('load',function(){ setTimeout(lazyLoadImgs,250); $(window).on('scrollstop scrollleft resize scroll checkLazyImg',lazyLoadImgs); setTimeout(lazyLoadDivs,250); $(window).on('scrollstop scrollleft resize scroll',lazyLoadDivs); if(mobile==1){ deviceGalleryTO = setTimeout(deviceGalleryLazy,1000); } $('#carSame').on('jcarousel:animateend', lazyLoadImgs); $(".jsonProductContainer").each(function(i,el){ loadJsonProduct_standalone(el); }); $(document).on("click",".chooseModButton",function(){ $(this).fadeOut(); $(this).parent().parent().find(".variants").slideDown(); }); }); var jsonProduct_standalone_firstload=true; var toAdd=500; function loadJsonProduct_standalone(el){ if(jsonProduct_standalone_firstload==true){ jsonProduct_standalone_firstload = false; attrs = "?jsonLoad=1&getHeaders=1&summary=1"; }else{ attrs = "?jsonLoad=1&summary=1"; } url = $(el).attr('data-href')+attrs; $.ajax({ type: 'GET', url: url, success: function(data){ $(el).html(data).addClass('noOpacity'); setTimeout(function(){ setTimeout(function(){ $(el).removeClass('noOpacity'); },350); productOnPageLoad('.jsonProductContainer.product_'+$(el).attr('data-pid')); onceOnLoad(); setTimeout(function(){ $('.jsonProductContainer.product_'+$(el).attr('data-pid')).removeClass('placeholder').fadeIn(); toAdd = toAdd + 50},toAdd); },250); }, async: true, dataType: "json" }); } function lazyLoadImgs(){ on_visible(function(){ $('img.lazy:not(.loaded),.mce-content-body img').each(function(i,el){ if($(el).hasClass('full')){ halfVisiblility = false; }else{ halfVisiblility = true; } if($(el).visible(halfVisiblility)==true){ $(el).attr('src',$(el).attr('data-src')).addClass('loaded'); } }); }); } function lazyLoadDivs(){ on_visible(function(){ $('div.lazyDiv:not(.loaded)').each(function(i,el){ if($(el).hasClass('full')){ halfVisiblility = false; }else{ halfVisiblility = true; } if($(el).visible(halfVisiblility)==true){ $(el).addClass('loaded'); $.ajax({ type: 'GET', url: $(el).attr('data-href'), success: function(data){ $(el).html(data); }, async: true, dataType: "json" }); } }); }); } function loadLater(filename, filetype, timeout, callback, rel, as){ setTimeout(function(){load(filename,filetype,callback,rel,as);},timeout); } function load(filename, filetype, callback, rel, as){ if (filetype=="js"){ //if filename is a external JavaScript file if($("script[src='"+filename+"']").attr('type')==undefined){ var fileref=document.createElement('script') fileref.setAttribute("type","text/javascript") fileref.setAttribute("src", filename) } } else if (filetype=="css" || filetype=="link"){ //if filename is an external CSS file if($("link[href='"+filename+"']").attr('type')==undefined){ var fileref=document.createElement("link") fileref.setAttribute("href", filename) fileref.setAttribute("type", "text/css") fileref.setAttribute("rel", "stylesheet") } } if (typeof fileref!="undefined") document.getElementsByTagName("head")[0].appendChild(fileref) // console.log(filename+' loaded'); if(typeof callback!=='undefined'){ setTimeout(callback,250); } } function globalScriptsLoad(callback){ var callback = typeof callback !== 'undefined' ? callback : false; load("/cache/js/jquery_libs.min.js","js"); load("/cache/js/libs/jquery.visible.js","js"); /* loadLater("https://code.jivosite.com/widget/a7cLisp1Gc","js",4000); */ /* loadLater("https://cdn.jsdelivr.net/npm/@widgetbot/crate@3","js",4000,function(){ new Crate({ server: '785129374054875156', channel: '785129374054875159', }) crate.notify('Нид хэлп?'); }); */ loadLater("/cache/js/site_cart_widget.js","js",2000); if(currentPage=='cart'){ load("/cache/js/site_delivery.js","js",function(){ load("/cache/js/site_region_run_later.js","js"); }); }else{ loadLater("/cache/js/site_delivery.js","js",1500,function(){ load("/cache/js/site_region_run_later.js","js"); }); } // load("/cache/css/fontawesome.css","css",false); // if (darkmode==1) { // load("/cache/css/menuicons-sprite-linked_wt.css","css",false); // }else{ // load("/cache/css/menuicons-sprite-linked.css","css",false); // } if(mobile){ load("/cache/js/libs/jquery.migrate.js","js"); load("/cache/js/libs/jquery.mobile.custom2.min.js","js"); load("/cache/js/window_mobile.js","js"); } if(currentPage=='product'){ loadLater("/cache/css/content.min.css","css",1000); // load("/js/product.js","js"); } if(callback!=false){ callback(); } } $(window).on('load',function(){globalScriptsLoad();});