mp-design-system 1.2.65 → 1.2.67
Sign up to get free protection for your applications and to get access to all the features.
package/dist/build/js/app.js
CHANGED
@@ -1 +1,31 @@
|
|
1
|
-
|
1
|
+
function M(){Array.from(document.querySelectorAll(".c-accordion__title")).forEach(x)}function x(e){e.addEventListener("click",H())}function H(){return e=>{var t=e.currentTarget.parentElement;t.classList.toggle("c-accordion__item--open")}}function B(){let e=0;const t=document.querySelectorAll(".c-hero__image-bg"),o=document.querySelectorAll(".c-hero__image-fg");o.length>0&&setInterval(()=>{for(var n of t)n.style.opacity=0;e=e!=t.length-1?e+1:0,t[e].style.opacity=1;for(var c of o)c.style.opacity=0;o[e].style.opacity=1},5e3)}function $(){const e=document.getElementById("clearForm");e&&e.addEventListener("click",function(){this.closest("form").elements.forEach(o=>{if(o.value!=""){if(o.type.toLowerCase()=="text"||o.type.toLowerCase()=="email"||o.type.toLowerCase()=="tel"||o.type.toLowerCase()=="select-one"||o.type.toLowerCase()=="textarea"){o.value="";return}else if(o.type.toLowerCase()=="checkbox"){o.checked=!1;return}}})})}function O(){document.querySelectorAll(".c-comparison-table").forEach(I)}function I(e){const t=e.parentNode.parentNode,o=t.querySelector(".c-comparison-table tbody"),n=t.querySelector(".c-comparison-table thead"),c=t.parentElement.querySelector(".c-comparison-table__mobile");if(!o||!n||!c)return;const r=Array.from(n.children[0].children).filter((s,a)=>a).map(s=>({info:s.innerHTML})),i=Array.from(n.children[1].children).filter((s,a)=>a).map(s=>({buttons:s.innerHTML})),l=r.map((s,a)=>({...s,...i[a],table:[]}));Array.from(o.children).forEach(s=>{if(s.classList.contains("c-comparison-table__title"))l.forEach(a=>{a.table.push({type:"title",title:s.children[0].textContent})});else{const a=Array.from(s.children),h=a.shift();a.forEach((v,m)=>{l[m].table.push({type:"row",key:h.textContent,value:v.innerHTML})})}}),l.forEach(s=>{const a=N(s);c.appendChild(a)})}function N(e){const t=document.createElement("article");return t.innerHTML=`${e.info}${e.buttons}
|
2
|
+
<table class="c-comparison-table">
|
3
|
+
${e.table.map(o=>o.type==="title"?`<tr class="c-comparison-table__title"><th><span>${o.title}</span></th><th></th></tr>`:`<tr>
|
4
|
+
<td>${o.key}</td>
|
5
|
+
<td>${o.value}</td>
|
6
|
+
</tr>`).join("")}
|
7
|
+
</table>`,t}function F(){Array.from(document.querySelectorAll(".c-facet__toggle")).forEach(R)}function R(e){e.addEventListener("click",W())}function W(){return e=>{e.preventDefault();var t=e.currentTarget,o=t.parentElement;o.classList.toggle("c-facet--open");const n=o.classList.contains("c-facet--open")?"true":"false";t.setAttribute("aria-expanded",n)}}function z(){const e=document.querySelectorAll(".c-gallery__main .c-gallery__slide"),t=document.querySelectorAll(".c-gallery__thumbnails .c-gallery__slide");t.forEach(n=>n.addEventListener("click",function(c){t.forEach(function(r){r!=c.target.parentNode&&r.classList.remove("active")}),c.target.parentNode.classList.add("active"),e.forEach(function(r){r.dataset.slide==n.dataset.slide?r.classList.add("active"):r.classList.remove("active")})})),e.forEach(function(n){n.classList.contains("c-gallery__video")||n.addEventListener("click",o)});function o(){const n=document.querySelector(".c-gallery__main").cloneNode(!0);n.classList.remove("c-gallery__main"),n.classList.add("c-lightbox"),n.querySelectorAll(".c-gallery__slide").forEach(function(c){if(c.classList.contains("c-gallery__video")&&c.remove(),!c.classList.contains("c-gallery__video")){var r=c.querySelector("img");r.srcset!=""&&r.removeAttribute("srcset");var i=r.getAttribute("src");i?i.indexOf("?")!==-1?r.setAttribute("src",i.split("?")[0]+"?quality=90&width=2176"):r.setAttribute("src",i+"?quality=90&width=2176"):(console.log(r),console.log("has no src defined..."))}c.classList.add("c-lightbox__slide"),c.classList.remove("c-gallery__slide")}),document.body.appendChild(n),n.insertAdjacentHTML("beforeend",'<a class="c-lightbox__prev"></a><a class="c-lightbox__next"></a>'),n.querySelector(".c-lightbox__prev").addEventListener("click",function(){const c=n.querySelector(".active"),r=n.querySelector('[data-slide="'+(parseInt(c.dataset.slide)-1)+'"]');r!=null&&(c.classList.remove("active"),r.classList.add("active"))}),n.querySelector(".c-lightbox__next").addEventListener("click",function(){const c=n.querySelector(".active"),r=n.querySelector('[data-slide="'+(parseInt(c.dataset.slide)+1)+'"]');r!=null&&(c.classList.remove("active"),r.classList.add("active"))}),n.addEventListener("click",function(c){c.target===c.currentTarget&&n.remove()})}}function P(e){const t=[...e];for(let o=t.length-1;o>0;o--){let n=Math.floor(Math.random()*(o+1));[t[o],t[n]]=[t[n],t[o]]}return t}function D(){return!window.matchMedia("(prefers-reduced-motion: no-preference)").matches}const j=(e,t)=>{let o=!1;return()=>{o||(e(),o=!0,setTimeout(()=>o=!1,t))}},V=(e,t,o)=>e*(1-o)+t*o,Q=(e,t=0,o=1)=>Math.min(o,Math.max(t,e)),Y=(e,t,o)=>Q((o-e)/(t-e)),G=(e,t,o,n,c)=>V(o,n,Y(e,t,c));function K(){let e=0;const t=document.querySelector(".c-hero__canvas");if(!t)return;const o=t.getContext("2d"),n="rgb(19,170,19)",c=D(),r=147,i=0,l=.5,s=.25;let a,h,v,m,p=[],_;function L(){e=e+.005,o.clearRect(0,0,t.width,t.height),o.beginPath();for(let d=t.width;d>0;d--)o.lineTo(d,t.height*.5-Math.cos(e+d/5*.03)*(h*.3));o.lineWidth=.5,o.strokeStyle=n,o.stroke(),p.forEach(d=>{T(d.x,d.y,G(0,p.length,i,l,d.counter)),d.counter+=d.direction,d.counter>=p.length&&(d.direction=-1*s),d.counter<0&&(d.direction=s)}),c||window.requestAnimationFrame(L)}function E(){a=t.scrollWidth,h=t.scrollHeight,o.canvas.width=a,o.canvas.height=h,v=Math.ceil(a/r),m=Math.ceil(h/r),_=(v+1)*(m+1);const d=P(Array.from({length:_},(f,u)=>u));p=[];for(let f=0;f<=v;f++)for(let u=0;u<=m;u++)p.push({counter:d.shift(),direction:Math.random()>.5?s:-1*s,x:r*(f+1)-r/1,y:r*(u+1)-r/2})}function T(d,f,u){o.beginPath(),o.moveTo(d-14,f),o.lineTo(d+14,f),o.strokeStyle=`rgba(255, 255, 255, ${u}`,o.moveTo(d,f-14),o.lineTo(d,f+14),o.stroke()}window.addEventListener("resize",E),E(),L()}function U(){document.addEventListener("DOMContentLoaded",()=>{const e=document.getElementById("videoBackground");if(typeof e<"u"&&e!=null){let i=function(){c.classList.contains("u-hidden")?(e.paused&&e.play(),r.paused||r.pause()):e.paused||e.pause()};var t=i;const o=window.matchMedia("(prefers-reduced-motion: reduce)");(!o||o.matches)&&e.pause();const n=document.getElementById("playVideo"),c=document.getElementById("lightboxVideo"),r=c.querySelector(".c-lightbox__video");n.addEventListener("click",l=>{e.pause(),c.classList.remove("u-hidden"),i()}),c.addEventListener("click",l=>{l.target.classList.contains("c-lightbox__video")||(e.setAttribute("autoplay",""),c.classList.add("u-hidden"),i())}),window.addEventListener("keydown",function(l){l.key=="Escape"&&(e.setAttribute("autoplay",""),c.classList.add("u-hidden"),i())})}})}function J(){setTimeout(function(){document.querySelectorAll(".c-hotspot-image__button").forEach(t=>{t.addEventListener("click",X)}),document.addEventListener("keydown",ee),document.addEventListener("click",g)},2e3)}function X(e){e.preventDefault();const t=e.currentTarget,o=t.getAttribute("aria-controls"),n=document.getElementById(o);n.classList.contains("c-hotspot-image__tooltip--open")?b(t,n):Z(t,n)}function Z(e,t){t.classList.add("c-hotspot-image__tooltip--open"),t.setAttribute("aria-hidden","false"),e.setAttribute("aria-expanded","true"),document.addEventListener("click",g)}function b(e,t){t.classList.remove("c-hotspot-image__tooltip--open"),t.setAttribute("aria-hidden","true"),e.setAttribute("aria-expanded","false"),document.removeEventListener("click",g)}function ee(e){if(e.key==="Escape"){const t=document.querySelector(".c-hotspot-image__tooltip--open");if(t){const o=document.querySelector(`[aria-controls="${t.id}"]`);b(o,t)}}}function g(e){const t=document.querySelector(".c-hotspot-image__tooltip--open");if(t&&!t.contains(e.target)&&!e.target.closest(".c-hotspot-image__button")){const o=document.querySelector(`[aria-controls="${t.id}"]`);b(o,t)}}function te(){const e=document.querySelector(".c-internal-nav--sticky");if(!e)return;const t={root:null,rootMargin:"0px",threshold:1},o=(i,l)=>{const s=i[0].isIntersecting;e.classList.toggle("c-internal-nav--stuck",!s)};new IntersectionObserver(o,t).observe(e);let c=e.offsetHeight;const r=()=>{c=e.offsetHeight,Array.from(e.querySelectorAll("a")).forEach(l=>{const s=l.getAttribute("href").replace("#",""),a=document.getElementById(s);a&&(a.style.scrollMarginTop=`${c}px`)})};window.addEventListener("resize",r),r()}function oe(){const e=document.querySelectorAll(".c-off-canvas__toggle");e.length&&(e.forEach(t=>{C(t,A(t)),t.addEventListener("click",()=>re(t))}),window.addEventListener("resize",()=>{e.forEach(t=>{C(t,A(t))})}))}function A(e){const t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"}function C(e,t){const o=document.getElementById(e.getAttribute("data-target"));t===!0?ne(o):ce(o)}function ne(e){e.classList.add("c-off-canvas"),e.setAttribute("tabindex","-1"),e.setAttribute("aria-hidden","true");const t=e.querySelector('[data-off-canvas="header"]'),o=e.querySelector('[data-off-canvas="main"]'),n=e.querySelector('[data-off-canvas="footer"]'),c=t!==null?t.outerHTML:"",r=o!==null?o.outerHTML:"",i=n!==null?n.outerHTML:"";e.innerHTML=`
|
8
|
+
<div class="c-off-canvas__backdrop" role="presentation"></div>
|
9
|
+
<div class="c-off-canvas__content" role="dialog" aria-modal="true" aria-labelledby="offCanvasHeader">
|
10
|
+
<header id="offCanvasHeader" class="c-off-canvas__header">${c}</header>
|
11
|
+
<main class="c-off-canvas__main">${r}</main>
|
12
|
+
<footer class="c-off-canvas__footer">
|
13
|
+
${i}
|
14
|
+
<button class="mp c-twi c-twi--left c-off-canvas__close" data-off-canvas-close="true" onclick="return false">
|
15
|
+
<span>Cancel</span>
|
16
|
+
<svg role="img" aria-hidden="true" focusable="false" class="mp c-icon c-icon--cross">
|
17
|
+
<use xlink:href="/static/svg/sprite.svg#cross"></use>
|
18
|
+
</svg>
|
19
|
+
</button>
|
20
|
+
</footer>
|
21
|
+
</div>
|
22
|
+
`}function ce(e){e.classList.remove("c-off-canvas","c-off-canvas--active"),e.removeAttribute("tabindex"),e.removeAttribute("aria-hidden");const t=e.querySelector(".c-off-canvas__backdrop");t&&t.remove();const o=e.querySelector(".c-off-canvas__content");if(o){for(;o.firstChild;)e.insertBefore(o.firstChild,o);e.removeChild(o)}const n=e.querySelector(".c-off-canvas__header");if(n){for(;n.firstChild;)e.insertBefore(n.firstChild,n);e.removeChild(n)}const c=e.querySelector(".c-off-canvas__main");if(c){for(;c.firstChild;)e.insertBefore(c.firstChild,c);e.removeChild(c)}const r=e.querySelector(".c-off-canvas__footer");if(r){for(;r.firstChild;)e.insertBefore(r.firstChild,r);e.removeChild(r)}const i=e.querySelector(".c-off-canvas__close");i&&i.remove()}function re(e){const t=document.getElementById(e.getAttribute("data-target"));t.classList.contains("c-off-canvas--active")?t.classList.contains("c-off-canvas--active")&&y(t):ie(e,t)}function ie(e,t){e.setAttribute("aria-expanded","true"),t.classList.add("c-off-canvas--active"),t.setAttribute("aria-hidden","false");const o=t.querySelector(".c-off-canvas__backdrop");o&&o.addEventListener("click",se);const n=t.querySelectorAll('[data-off-canvas-close="true"]');n.length>0&&n.forEach(r=>{r.addEventListener("click",le)}),document.addEventListener("keydown",ae,{once:!0}),document.body.style.overflowY="hidden";const c=Array.from(document.querySelectorAll(".c-off-canvas")).filter(r=>r!==t);c.length>0&&c.forEach(r=>{y(r)})}function y(e){document.querySelector('[data-target="'+e.id+'"').setAttribute("aria-expanded","false"),e.classList.remove("c-off-canvas--active"),e.setAttribute("aria-hidden","true"),document.body.style.overflowY=""}function se(){const e=this.closest(".c-off-canvas");y(e)}function ae(e){if(e.key==="Escape"){const t=document.querySelector(".c-off-canvas--active");t&&y(t)}}function le(){const e=this.closest(".c-off-canvas");y(e)}const de=()=>{Array.from(document.querySelectorAll(".c-table--responsive")).forEach(t);function t(o){const n=o.querySelectorAll("thead > :first-child th"),c=Number(o.getAttribute("data-columns"))||2;if(n.length<c){o.classList.remove("c-table--responsive");return}Array.from(o.querySelectorAll("tbody tr")).forEach(r=>{Array.from(n).map(i=>i.textContent).forEach((i,l)=>{r.children[l]&&r.children[l].setAttribute("data-responsive-title",i)})})}};function fe(){w(),window.addEventListener("resize",j(w,250))}function w(){document.documentElement.style.setProperty("--scrollbarWidth",window.innerWidth-document.body.clientWidth+"px")}function ue(){const e=document.querySelector(".c-internal-nav--sticky"),t=e?e.offsetHeight:0;Array.from(document.querySelectorAll(".c-scroll-spy")).forEach(n=>{he(n,t)})}function he(e,t){const o=Array.from(e.querySelectorAll("a")),n=new IntersectionObserver(ve(o));o.forEach(r=>{const i=r.getAttribute("href").replace("#",""),l=document.getElementById(i);l&&n.observe(l)});const c=parseFloat(window.getComputedStyle(e).top);e.style.top=`${c+t}px`}function ve(e){return t=>{const o=t.find(n=>n.isIntersecting);o&&e.forEach(n=>{n.classList.toggle("c-scroll-spy-active",n.getAttribute("href")==="#"+o.target.id)})}}let S;function me(){Array.from(document.querySelectorAll(".c-tabs--anchor, .c-tabs--mobile-accordion")).forEach(t=>{q(t),window.addEventListener("resize",()=>{clearTimeout(S),S=setTimeout(()=>k(t),100)})})}function q(e){const t=Array.from(e.querySelectorAll(".c-tabs__control")),o=Array.from(e.querySelectorAll(".c-tab")),n=e.classList.contains("c-tabs--persist");if(!(!t.length||!o.length)&&(k(e),t.forEach(c=>{c.addEventListener("click",be(t,o,n))}),n&&window.location.hash)){const c=e.querySelector('[href="'+window.location.hash+'"]');c&&c.dispatchEvent(new Event("click"))}}function k(e){const t=e.classList.contains("c-tabs--mobile-accordion"),o=window.innerWidth<=880;e.dataset.viewMode!==(o?"accordion":"tabs")&&(e.dataset.viewMode=o?"accordion":"tabs",t&&o?pe(e):t&&!o&&ye(e))}function pe(e){const t=Array.from(e.querySelectorAll(".c-tabs__control")),o=Array.from(e.querySelectorAll(".c-tab"));e.innerHTML="",t.forEach((n,c)=>{const r=o[c];if(r){const i=document.createElement("div");i.classList.add("c-tabs__content"),i.appendChild(n),i.appendChild(r),e.appendChild(i)}})}function ye(e){const t=Array.from(e.querySelectorAll(".c-tabs__control")),o=Array.from(e.querySelectorAll(".c-tab"));!t.length||!o.length||(e.innerHTML=`
|
23
|
+
<nav class="c-tabs__controls">
|
24
|
+
<ul class="c-tabs__controls-list">
|
25
|
+
${t.map(n=>`<li>${n.outerHTML}</li>`).join("")}
|
26
|
+
</ul>
|
27
|
+
</nav>
|
28
|
+
<div class="c-tabs__content">
|
29
|
+
${o.map(n=>n.outerHTML).join("")}
|
30
|
+
</div>
|
31
|
+
`,setTimeout(()=>q(e),0))}function be(e,t,o){return n=>{var l;const c=n.currentTarget,r=(l=c.getAttribute("href"))==null?void 0:l.replace("#",""),i=t.find(s=>s.id===r);if(!i)return!0;if(n.preventDefault(),o&&history.pushState(null,null,c.getAttribute("href")),window.innerWidth<=880){const s=i.classList.contains("c-tab--active");e.forEach(a=>a.classList.remove("c-tabs__control--active")),t.forEach(a=>a.classList.remove("c-tab--active")),s||(c.classList.add("c-tabs__control--active"),i.classList.add("c-tab--active"))}else e.forEach(s=>s.classList.toggle("c-tabs__control--active",s===c)),t.forEach(s=>s.classList.toggle("c-tab--active",s===i))}}function ge(){window.NodeList&&!NodeList.prototype.forEach&&(NodeList.prototype.forEach=Array.prototype.forEach),window.HTMLCollection&&!HTMLCollection.prototype.forEach&&(HTMLCollection.prototype.forEach=Array.prototype.forEach),M(),B(),$(),O(),F(),z(),K(),U(),J(),te(),oe(),de(),fe(),ue(),me()}ge();
|