-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfusilli.min.js
2 lines (2 loc) · 1.33 KB
/
fusilli.min.js
1
2
/* github.com/AnTheMaker/Fusilli.js - MIT License */
const modalStyles=".modal{display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,.6);justify-content:center;align-items:center;user-select:none;z-index:999}.modal.open{display:flex}.modal_box{background:#fff;color:#000;margin:7px;padding:18px 20px;border-radius:8px;width:450px;min-height:200px;max-width:100%;max-height:calc(100% - 20px);overflow:auto;box-sizing:border-box;z-index:99;user-select:auto;pointer-events:auto}.modal_close{float:right;margin:-6px -4px 0 10px;background:#fff;cursor:pointer;font-size:170%;z-index:999}";function openModal(e){e.setAttribute("aria-hidden","false"),e.classList.add("open")}function closeModal(e){e.setAttribute("aria-hidden","true"),e.classList.remove("open")}window.addEventListener("load",function(){var e=document.createElement("style");e.type="text/css",e.innerText=modalStyles,document.head.appendChild(e),[...document.getElementsByClassName("modal")].forEach(function(e){modal_box=e.querySelector(".modal_box"),modal_box.insertAdjacentHTML("afterbegin",'<div id="close_'+e.id+'" class="modal_close">×</div>'),document.getElementById("close_"+e.id).addEventListener("click",function(){closeModal(e)}),e.addEventListener("click",function(o){closeModal(e)}),modal_box.addEventListener("click",function(e){e.stopPropagation()})})});