2 lines
6.7 KiB
JavaScript
2 lines
6.7 KiB
JavaScript
(function(){"use strict";var P=/^[^\s@<>"']+@[^\s@<>"']+\.[^\s@<>"']+$/,W=/^\+?[0-9\s-]+$/;document.querySelectorAll("a[data-m]").forEach(function(e){try{var t=atob(e.getAttribute("data-m"));if(!P.test(t))return;e.href="mailto:"+t;var r=e.querySelector("[data-mt]");r&&(r.textContent=t)}catch(o){}}),document.querySelectorAll("a[data-t]").forEach(function(e){try{var t=atob(e.getAttribute("data-t"));if(!W.test(t))return;e.href="tel:"+t.replace(/[\s-]/g,"");var r=e.querySelector("[data-tt]");r&&(r.textContent=t)}catch(o){}});var x=document.getElementById("scrollProgress");function $(){if(x){var e=document.documentElement.scrollHeight-window.innerHeight,t=e>0?window.scrollY/e*100:0;x.style.width=t+"%"}}var k=document.getElementById("hdr"),N=!!document.querySelector(".hero");function B(){k&&k.classList.toggle("scrolled",!N||window.scrollY>80)}var T=document.getElementById("euInfoblokk"),_=!1;function C(){if(T){var e=window.scrollY>80;e!==_&&(_=e,T.classList.toggle("eu-infoblokk--min",e))}}var L=!1;window.addEventListener("scroll",function(){L||(requestAnimationFrame(function(){$(),B(),C(),L=!1}),L=!0)},{passive:!0}),B(),C();var a=document.getElementById("navGlass"),y=document.querySelector(".hdr__nav"),O=y?y.querySelectorAll('a[href^="#"]'):[],m=[];O.forEach(function(e){var t=e.getAttribute("href"),r=document.querySelector(t);r&&m.push({el:r,link:e})});var f=null,b=null;function R(e,t){if(!(!e||!a)&&f!==e){O.forEach(function(g){g.classList.remove("active")}),e.classList.add("active");var r=y.getBoundingClientRect(),o=e.getBoundingClientRect(),n=o.left-r.left-3,c=o.width+6;if(!f||t){a.style.transition="opacity 0.4s ease",a.style.left=n+"px",a.style.width=c+"px",a.style.opacity="1",f=e;return}var i=parseFloat(a.style.left)||0,s=parseFloat(a.style.width)||c,v=i+s,u=n+c,h=n>i;b&&clearTimeout(b),h?(a.style.transition="width 0.32s cubic-bezier(0.4, 0, 0.2, 1)",a.style.width=u-i+"px",b=setTimeout(function(){a.style.transition="left 0.28s cubic-bezier(0.4, 0, 0.2, 1), width 0.28s cubic-bezier(0.4, 0, 0.2, 1)",a.style.left=n+"px",a.style.width=c+"px"},140)):(a.style.transition="left 0.32s cubic-bezier(0.4, 0, 0.2, 1), width 0.32s cubic-bezier(0.4, 0, 0.2, 1)",a.style.left=n+"px",a.style.width=v-n+"px",b=setTimeout(function(){a.style.transition="width 0.28s cubic-bezier(0.4, 0, 0.2, 1)",a.style.width=c+"px"},140)),f=e}}function M(){for(var e=window.scrollY,t=null,r=m.length-1;r>=0;r--)if(e>=m[r].el.offsetTop-150){t=m[r];break}!t&&e<200&&m.length&&(t=m[0]),t&&R(t.link)}window.addEventListener("resize",function(){if(f){var e=f;f=null,R(e,!0)}});var I=!1;window.addEventListener("scroll",function(){I||(requestAnimationFrame(function(){M(),I=!1}),I=!0)},{passive:!0}),y&&setTimeout(M,150);var p=document.getElementById("mobMenu"),w=document.getElementById("mobOverlay"),z=document.getElementById("menuOpen"),F=document.getElementById("menuClose");function j(){p.classList.add("on"),w.classList.add("on"),document.body.style.overflow="hidden"}function E(){p.classList.remove("on"),w.classList.remove("on"),document.body.style.overflow=""}p&&w&&z&&F&&(z.addEventListener("click",j),F.addEventListener("click",E),w.addEventListener("click",E),p.querySelectorAll("a").forEach(function(e){e.addEventListener("click",E)}),document.addEventListener("keydown",function(e){e.key==="Escape"&&E()}));var A=document.querySelectorAll("[data-country-select]");A.length&&(document.addEventListener("click",function(e){A.forEach(function(t){t.contains(e.target)||(t.open=!1)})}),document.addEventListener("keydown",function(e){e.key==="Escape"&&A.forEach(function(t){t.open=!1})}));var Y=new IntersectionObserver(function(e){e.forEach(function(t){if(t.isIntersecting){var r=t.target,o=r.parentElement.querySelectorAll(".rv"),n=Array.prototype.indexOf.call(o,r);r.style.transitionDelay=n*.08+"s",r.classList.add("on"),Y.unobserve(r)}})},{threshold:.12,rootMargin:"0px 0px -40px 0px"});document.querySelectorAll(".rv").forEach(function(e){Y.observe(e)});function J(e){var t=parseInt(e.getAttribute("data-count"),10),r=t>1e3?2200:1800,o=null;function n(i){return i>=1e4?i.toString().replace(/\B(?=(\d{3})+(?!\d))/g," "):i.toString()}function c(i){o||(o=i);var s=Math.min((i-o)/r,1),v=1-Math.pow(1-s,4),u=Math.floor(v*t);e.textContent=n(u)+(t<5e4?"+":""),s<1?requestAnimationFrame(c):e.textContent=n(t)+(t<5e4?"+":"")}requestAnimationFrame(c)}var G=new IntersectionObserver(function(e){e.forEach(function(t){t.isIntersecting&&(J(t.target),G.unobserve(t.target))})},{threshold:.5});document.querySelectorAll("[data-count]").forEach(function(e){G.observe(e)}),document.querySelectorAll('a[href^="#"]').forEach(function(e){e.addEventListener("click",function(t){var r=this.getAttribute("href");if(r!=="#"){var o=document.querySelector(r);o&&(t.preventDefault(),window.scrollTo({top:o.getBoundingClientRect().top+window.scrollY-80,behavior:"smooth"}))}})});function H(){document.querySelectorAll(".tile-carousel__slide[data-bg]").forEach(function(e){e.style.backgroundImage="url('"+e.getAttribute("data-bg")+"')",e.removeAttribute("data-bg")})}document.readyState==="complete"?H():window.addEventListener("load",H),document.querySelectorAll(".tile-carousel").forEach(function(e){var t=e.querySelectorAll(".tile-carousel__slide"),r=e.querySelectorAll(".tile-carousel__dot"),o=parseInt(e.getAttribute("data-interval"),10)||5e3,n=0,c,i=!1;function s(l){t[n].classList.remove("active"),r[n].classList.remove("active"),n=l,t[n].classList.add("active"),r[n].classList.add("active")}function v(){s((n+1)%t.length)}function u(){c=setInterval(v,o)}function h(){clearInterval(c),u()}r.forEach(function(l,d){l.addEventListener("click",function(){s(d),h()})});var g=new IntersectionObserver(function(l){l.forEach(function(d){d.isIntersecting&&!i?(i=!0,u()):!d.isIntersecting&&i&&(clearInterval(c),i=!1)})},{threshold:.3});g.observe(e)}),document.querySelectorAll("[data-wh-carousel]").forEach(function(e){var t=e.querySelectorAll("img"),r=e.querySelectorAll(".wh-carousel__dot"),o=parseInt(e.getAttribute("data-interval"),10)||5e3,n=0,c,i=!1;function s(l){t[n].classList.remove("active"),r[n].classList.remove("active"),n=l,t[n].classList.add("active"),r[n].classList.add("active")}function v(){s((n+1)%t.length)}function u(){c=setInterval(v,o)}function h(){clearInterval(c),u()}r.forEach(function(l,d){l.addEventListener("click",function(){s(d),h()})});var g=new IntersectionObserver(function(l){l.forEach(function(d){d.isIntersecting&&!i?(i=!0,u()):!d.isIntersecting&&i&&(clearInterval(c),i=!1)})},{threshold:.3});g.observe(e)});var S=document.getElementById("langGlass"),q=document.querySelector(".hdr__lang");function D(){if(!(!S||!q)){var e=q.querySelector("a.active");if(e){var t=q.getBoundingClientRect(),r=e.getBoundingClientRect();S.style.left=r.left-t.left-1+"px",S.style.width=r.width+2+"px"}}}D(),window.addEventListener("resize",D)})();
|