area-51/assets/js/scripts.min.js

1 line
1.9 KiB
JavaScript
Raw Permalink Normal View History

2025-01-14 06:54:26 +01:00
document.addEventListener("DOMContentLoaded",(()=>{const t=document.querySelector(".navbar__toggle"),e=document.querySelector(".navbar__menu");t&&e&&t.addEventListener("click",(()=>{const n=e.classList.contains("is-active");e.classList.toggle("is-active",!n),e.classList.toggle("is-hidden",n),t.classList.toggle("is-active",!n),t.setAttribute("aria-expanded",!n)}))})),function(){const t=document.querySelector(".js-content__share-button"),e=document.querySelector(".js-content__share-popup");t&&e&&(e.addEventListener("click",(function(t){t.stopPropagation()})),t.addEventListener("click",(function(t){t.preventDefault(),t.stopPropagation(),e.classList.toggle("is-visible")})),document.body.addEventListener("click",(function(){e.classList.remove("is-visible")})));const n=".js-share",i=500,o=500;function s(t){t.preventDefault();const s=t.target.closest(n);if(!s)return;e&&e.classList.remove("is-visible");const c=Math.floor((window.innerWidth-i)/2),r=Math.floor((window.innerHeight-o)/2),a=s.href,l=window.open(a,"social",`\n\t\t\t width=${i},\n\t\t\t height=${o},\n\t\t\t left=${c},\n\t\t\t top=${r},\n\t\t\t location=0,\n\t\t\t menubar=0,\n\t\t\t toolbar=0,\n\t\t\t status=0,\n\t\t\t scrollbars=1,\n\t\t\t resizable=1\n\t\t `);l&&l.focus()}document.querySelectorAll(n).forEach((t=>{t.addEventListener("click",s)}))}(),function(){let t=document.querySelectorAll(".post__video, .post__iframe");for(let e=0;e<t.length;e++){let n=t[e].querySelector("iframe, embed, video, object");if(!n)continue;if("false"===n.getAttribute("data-responsive"))continue;let i=n.getAttribute("width"),o=n.getAttribute("height"),s=!1;if(i&&o&&(i.indexOf("%")>-1&&o.indexOf("%")>-1?(i=parseFloat(i.replace("%","")),o=parseFloat(o.replace("%","")),s=o/i):-1===i.indexOf("%")&&-1===o.indexOf("%")&&(i=parseInt(i,10),o=parseInt(o,10),s=o/i),!1!==s)){let n=100*s+"%";t[e].setAttribute("style","--embed-aspect-ratio:"+n)}}}();