This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
FireUI.min.js
1 lines (1 loc) · 6.75 KB
/
FireUI.min.js
1
document.addEventListener("DOMContentLoaded",()=>{localStorage.getItem("theme-color")?document.body.dataset.disableSwitchingTheme?document.body.dataset.theme||document.body.setAttribute("data-theme","light"):document.body.setAttribute("data-theme",localStorage.getItem("theme-color")):document.body.dataset.theme||document.body.setAttribute("data-theme","light"),document.querySelectorAll("[data-switch-theme]").forEach(btn=>{btn.addEventListener("click",()=>{if(!document.body.dataset.disableSwitchingTheme){if(btn.dataset.switchTheme&&""!==btn.dataset.switchTheme){let availableTheme=btn.dataset.switchTheme.split(",").map(i=>i.trim());-1===availableTheme.indexOf(document.body.getAttribute("data-theme"))?localStorage.setItem("theme-color",availableTheme[0]):availableTheme.indexOf(document.body.getAttribute("data-theme"))+1===availableTheme.length?localStorage.setItem("theme-color",availableTheme[0]):localStorage.setItem("theme-color",availableTheme[availableTheme.indexOf(document.body.getAttribute("data-theme"))+1])}else"dark"===document.body.getAttribute("data-theme")?localStorage.setItem("theme-color","light"):localStorage.setItem("theme-color","dark");document.body.setAttribute("data-theme",localStorage.getItem("theme-color"))}})}),document.querySelectorAll(".topnav-hamburger-menu").forEach(menu=>{document.getElementById(menu.dataset.target).classList.add("topnav-list"),menu.addEventListener("click",()=>{"block"===window.getComputedStyle(document.getElementById(menu.dataset.target)).getPropertyValue("display")?(menu.innerHTML="☰",document.getElementById(menu.dataset.target).style.display="none"):(menu.innerHTML="×",document.getElementById(menu.dataset.target).style.display="block")})}),document.querySelectorAll(".sidenav-menu-btn").forEach(menu=>{menu.addEventListener("click",()=>{document.querySelectorAll(".sidenav-close-btn").forEach(btn=>{btn.addEventListener("click",()=>{document.getElementById(btn.dataset.target).style.width="0%"})}),window.innerWidth<=768?document.getElementById(menu.dataset.target).style.width="100%":document.getElementById(menu.dataset.target).style.width="250px"})}),document.querySelectorAll("[open-modal]").forEach(btn=>{btn.addEventListener("click",()=>{let modal=document.getElementById(btn.dataset.modal);window.onclick=e=>{e.target==modal&&(modal.style.display="none")},"block"===window.getComputedStyle(modal).getPropertyValue("display")?modal.style.display="none":modal.style.display="block"})}),document.querySelectorAll(".modal-close-btn").forEach(btn=>{btn.addEventListener("click",()=>{document.getElementById(btn.dataset.modal).style.display="none"})}),document.querySelectorAll(".fixed-sidenav-dropdown-btn").forEach(btn=>{btn.addEventListener("click",()=>{"block"===window.getComputedStyle(document.getElementById(btn.dataset.dropdown)).getPropertyValue("display")?document.getElementById(btn.dataset.dropdown).style.display="none":document.getElementById(btn.dataset.dropdown).style.display="block"})}),document.querySelectorAll(".tab").forEach(tab=>{tab.childNodes.forEach(btn=>{btn.classList&&btn.classList.contains("tab-btn")&&btn.addEventListener("click",()=>{document.querySelectorAll(".tab-content").forEach(content=>{content.parentElement.id===tab.dataset.tab&&(content.style.display="none")}),document.getElementById(btn.dataset.content).style.display="block"})})}),document.querySelectorAll(".accordion").forEach(accordion=>{accordion.addEventListener("click",()=>{accordion.classList.toggle("accordion-active");var panel=document.getElementById(accordion.dataset.panel);panel.style.maxHeight?panel.style.maxHeight=null:panel.style.maxHeight=panel.scrollHeight+"px"})}),document.querySelectorAll(".textarea-auto-adjust").forEach(textarea=>{textarea.addEventListener("input",()=>{textarea.style.height="5px",textarea.style.height=textarea.scrollHeight+"px"}),textarea.style.height=textarea.scrollHeight+parseInt(getComputedStyle(textarea).paddingTop)+parseInt(getComputedStyle(textarea).paddingBottom)+"px"}),document.querySelectorAll("pre").forEach(pre=>{if(Boolean(pre.getElementsByTagName("code").length)&&(!pre.hasAttribute("data-copyable")||"false"!==pre.dataset.copyable)){var copyBtn=document.createElement("button");copyBtn.classList.add("code-copyBtn"),copyBtn.innerText="Copy",pre.insertBefore(copyBtn,pre.firstChild),copyBtn.addEventListener("click",()=>{const code=pre.querySelector("code").innerText,textarea=document.createElement("textarea");textarea.value=code,textarea.style.opacity="0",textarea.setAttribute("readonly",""),document.body.appendChild(textarea),textarea.select(),document.execCommand("copy"),document.body.removeChild(textarea),copyBtn.innerText="Copied",document.addEventListener("copy",()=>{copyBtn.innerText="Copy"})})}});var marquee=document.querySelectorAll("marquee");for(let i=0;i<marquee.length;i++)marquee[i].setAttribute("scrollamount","10");for(let x=0;x<marquee.length;x++)if(marquee[x].hasAttribute("data-speed")){var speed=document.getElementsByTagName("marquee")[x].getAttribute("data-speed");document.getElementsByTagName("marquee")[x].setAttribute("scrollamount",speed)}document.querySelectorAll(".toggle-switch").forEach(toggle=>{let element=document.createElement("label");element.classList.add("toggle-animation"),toggle.querySelector("input[type=checkbox]")&&element.setAttribute("for",toggle.querySelector("input[type=checkbox]").getAttribute("id")),toggle.appendChild(element)}),document.querySelectorAll(".input-animate").forEach(input=>{let form=input.parentNode;form.classList.add("form-animate");let element=document.createElement("span");element.classList.add("input-onFocus"),form.querySelector(".input-onFocus")||form.insertBefore(element,input.nextSibling)}),document.querySelectorAll(".marquee").forEach(marquee=>{let direction="up"===marquee.dataset.direction||"down"===marquee.dataset.direction?"vertical":"horizontal";marquee.dataset.speed&&(marquee.querySelector(".marquee-content").style.animation=`marquee-${direction} ${marquee.dataset.speed}s linear infinite`)}),document.querySelectorAll(".slideshow-container").forEach(slideshow=>{slideshow.querySelectorAll(".slideshow").forEach(sl=>{sl!==slideshow.querySelector(".slideshow")&&sl.classList.add("slideshow-none")})})});var defaultIndex=1;function btnSlide(n){activeSlide(defaultIndex+=n)}function currentSlide(n){activeSlide(defaultIndex=n)}function activeSlide(n){var i,slides=document.getElementsByClassName("slideshow"),info=document.getElementsByClassName("slideshow-dot");for(n>slides.length&&(defaultIndex=1),n<1&&(defaultIndex=slides.length),i=0;i<slides.length;i++)slides[i].classList.add("slideshow-none");for(i=0;i<info.length;i++)info[i].className=info[i].className.replace(" slideshow-active","");slides[defaultIndex-1]&&slides[defaultIndex-1].classList.toggle("slideshow-none"),info[defaultIndex-1]&&(info[defaultIndex-1].className+=" slideshow-active")}activeSlide(defaultIndex);