UNPKG

29.3 kBJavaScriptView Raw
1/* v4.1.8 */let DOMLoaded=!1,windowLoaded=!1;window.addEventListener("DOMContentLoaded",(()=>{DOMLoaded=!0})),window.addEventListener("load",(()=>{windowLoaded=!0}));class Radix{constructor(e,t){this.version="4.1.8";const a={timeFrame:10,preload:{active:!1,selector:"",class:"hide",delay:200,preventScroll:!1},smoothScroll:{active:!0,duration:600,easing:"easeInOutExpo",header:""},fixExtLink:{active:!0},toggleNav:{active:!1,trigger:"",target:"",class:"opened",preventScroll:!1},icons:{active:!0,selector:".radix-icon"},dragScroll:{active:!0,selector:".radix-drag",hint:!0},flexFix:{active:!0,selector:".radix-flexfix",inherit:!0,min:0},modal:{active:!0,selector:".radix-modal",class:"white",resizeDuration:300,resizeEasing:"easeInOutBack",scaleStep:[.2,.4,.6,.8,1,1.5,2,2.5,3,3.5,4,4.5,5],fit:!0,drag:!0,magnify:!0,wrap:!1},scrollAppear:{active:!0,selector:".radix-appear",delay:200,reset:!0,class:"active"}},o="object"==this.typeJudge(e);Object.keys(a).forEach((l=>{!1===t&&"timeFrame"!=l&&(a[l].active=!1),o&&Object.assign(a[l],e[l])})),this.option=a,this.navState=!1,this.modalState=!1,this.initialized=!1,this.isMobile=void 0!==window.ontouchstart,this.DOM_ROOTS=document.querySelectorAll("html,body"),this.events={beforeInitialize:new CustomEvent("_radixInit"),afterInitialize:new CustomEvent("radixInit_"),beforeScroll:new CustomEvent("_radixScroll"),afterScroll:new CustomEvent("radixScroll_"),beforeNavOpen:new CustomEvent("_radixNavOpen"),afterNavOpen:new CustomEvent("radixNavOpen_"),beforeNavClose:new CustomEvent("_radixNavClose"),afterNavClose:new CustomEvent("radixNavClose_"),beforeModalOpen:new CustomEvent("_radixModalOpen"),afterModalOpen:new CustomEvent("radixModalOpen_"),beforeModalClose:new CustomEvent("_radixModalClose"),afterModalClose:new CustomEvent("radixModalClose_")}}init(){const e=this;new Promise((t=>{document.dispatchEvent(e.events.beforeInitialize),DOMLoaded?t():window.addEventListener("DOMContentLoaded",t)})).then((()=>new Promise((t=>{if(e.option.preload.active){e.option.preload.preventScroll&&e.preventScroll(!0);let t=e.option.preload.selector.length>0?document.querySelectorAll(e.option.preload.selector):[];window.addEventListener("load",(()=>{e.option.preload.active&&t&&e.initialized&&setTimeout((()=>{e.option.preload.preventScroll&&e.preventScroll(!1),t.forEach((t=>{t.classList.add(e.option.preload.class)}))}),e.option.preload.delay)})),document.addEventListener("radixInit_",(()=>{e.initialized=!0,e.option.preload.active&&t.length>0&&windowLoaded&&setTimeout((()=>{e.option.preload.preventScroll&&e.preventScroll(!1),t.forEach((t=>{t.classList.add(e.option.preload.class)}))}),e.option.preload.delay)}))}if(e.option.icons.active){const t={cross:{viewbox:"0 0 100 100",path:"M 2 17 L 17 2 L 50 35 L 83 2 L 98 17 L 65 50 L 98 83 L 83 98 L 50 65 L 17 98 L 2 83 L 35 50 L 2 17 Z",fill:!0,stroke:0,linejoin:"miter",linecap:"butt"},angle_top:{viewbox:"0 0 100 100",path:"M 50 19 L 97 66 L 84 79 L 50 45 L 16 79 L 3 66 L 50 19 Z",fill:!0,stroke:0},angle_right:{viewbox:"0 0 100 100",path:"M 81 50 L 34 97 L 21 84 L 55 50 L 21 16 L 34 3 L 81 50 Z",fill:!0,stroke:0},angle_bottom:{viewbox:"0 0 100 100",path:"M 50 81 L 97 34 L 84 21 L 50 55 L 16 21 L 3 34 L 50 81 Z",fill:!0,stroke:0},angle_left:{viewbox:"0 0 100 100",path:"M 19 50 L 66 3 L 79 16 L 45 50 L 79 84 L 66 97 L 19 50 Z",fill:!0,stroke:0},arrow_lr:{viewbox:"0 0 100 100",path:"M 10 50 L 35 20 L 35 42 L 65 42 L 65 20 L 90 50 L 65 80 L 65 58 L 35 58 L 35 80 L 10 50 Z",fill:!0,stroke:0},arrow_tb:{viewbox:"0 0 100 100",path:"M 50 10 L 80 35 L 58 35 L 58 65 L 80 65 L 50 90 L 20 65 L 42 65 L 42 35 L 20 35 L 50 10 Z",fill:!0,stroke:0},magnifying_glass:{viewbox:"0 0 500 500",path:"M 120 195 C 120 92.896 202.896 10 305 10 C 407.104 10 490 92.896 490 195 C 490 297.104 407.104 380 305 380 C 202.896 380 120 297.104 120 195 Z M 180 195 C 179.99 186.52 180.85 178.06 182.55 169.75 C 184.18 161.76 186.61 153.94 189.8 146.42 C 196.1 131.55 205.21 118.05 216.64 106.64 C 228.05 95.21 241.55 86.1 256.42 79.8 C 263.94 76.61 271.76 74.18 279.76 72.54 C 288.07 70.85 296.52 69.99 305 70 C 313.48 69.99 321.93 70.85 330.24 72.54 C 338.24 74.18 346.06 76.61 353.58 79.8 C 368.45 86.1 381.95 95.21 393.36 106.64 C 404.79 118.05 413.9 131.55 420.2 146.42 C 423.39 153.94 425.82 161.76 427.46 169.76 C 429.15 178.07 430.01 186.52 430 195 C 430.01 203.48 429.15 211.93 427.46 220.24 C 425.82 228.24 423.39 236.06 420.2 243.58 C 413.9 258.45 404.79 271.95 393.36 283.36 C 381.95 294.79 368.45 303.9 353.58 310.2 C 346.06 313.39 338.24 315.82 330.24 317.46 C 321.93 319.15 313.48 320.01 305 320 C 296.52 320.01 288.07 319.15 279.76 317.46 C 271.76 315.82 263.94 313.39 256.42 310.2 C 241.55 303.9 228.05 294.79 216.64 283.36 C 205.21 271.95 196.1 258.45 189.8 243.58 C 186.61 236.06 184.18 228.24 182.54 220.24 C 180.85 211.93 179.99 203.48 180 195 Z M 13 490 L 13 413.148 L 126.148 300 L 203 376.852 L 89.852 490 L 13 490 Z",fill:!0,fillRule:"evenodd",stroke:0},zoom_in:{viewbox:"0 0 500 500",path:"M 120 195 C 120 92.896 202.896 10 305 10 C 407.104 10 490 92.896 490 195 C 490 297.104 407.104 380 305 380 C 202.896 380 120 297.104 120 195 Z M 180 195 C 179.99 186.52 180.85 178.06 182.55 169.75 C 184.18 161.76 186.61 153.94 189.8 146.42 C 196.1 131.55 205.21 118.05 216.64 106.64 C 228.05 95.21 241.55 86.1 256.42 79.8 C 263.94 76.61 271.76 74.18 279.76 72.54 C 288.07 70.85 296.52 69.99 305 70 C 313.48 69.99 321.93 70.85 330.24 72.54 C 338.24 74.18 346.06 76.61 353.58 79.8 C 368.45 86.1 381.95 95.21 393.36 106.64 C 404.79 118.05 413.9 131.55 420.2 146.42 C 423.39 153.94 425.82 161.76 427.46 169.76 C 429.15 178.07 430.01 186.52 430 195 C 430.01 203.48 429.15 211.93 427.46 220.24 C 425.82 228.24 423.39 236.06 420.2 243.58 C 413.9 258.45 404.79 271.95 393.36 283.36 C 381.95 294.79 368.45 303.9 353.58 310.2 C 346.06 313.39 338.24 315.82 330.24 317.46 C 321.93 319.15 313.48 320.01 305 320 C 296.52 320.01 288.07 319.15 279.76 317.46 C 271.76 315.82 263.94 313.39 256.42 310.2 C 241.55 303.9 228.05 294.79 216.64 283.36 C 205.21 271.95 196.1 258.45 189.8 243.58 C 186.61 236.06 184.18 228.24 182.54 220.24 C 180.85 211.93 179.99 203.48 180 195 Z M 13 490 L 13 413.148 L 126.148 300 L 203 376.852 L 89.852 490 L 13 490 Z M 205 160 L 270 160 L 270 95 L 340 95 L 340 160 L 405 160 L 405 230 L 340 230 L 340 295 L 270 295 L 270 230 L 205 230 L 205 160 Z",fill:!0,fillRule:"evenodd",stroke:0},zoom_out:{viewbox:"0 0 500 500",path:"M 120 195 C 120 92.896 202.896 10 305 10 C 407.104 10 490 92.896 490 195 C 490 297.104 407.104 380 305 380 C 202.896 380 120 297.104 120 195 Z M 180 195 C 179.99 186.52 180.85 178.06 182.55 169.75 C 184.18 161.76 186.61 153.94 189.8 146.42 C 196.1 131.55 205.21 118.05 216.64 106.64 C 228.05 95.21 241.55 86.1 256.42 79.8 C 263.94 76.61 271.76 74.18 279.76 72.54 C 288.07 70.85 296.52 69.99 305 70 C 313.48 69.99 321.93 70.85 330.24 72.54 C 338.24 74.18 346.06 76.61 353.58 79.8 C 368.45 86.1 381.95 95.21 393.36 106.64 C 404.79 118.05 413.9 131.55 420.2 146.42 C 423.39 153.94 425.82 161.76 427.46 169.76 C 429.15 178.07 430.01 186.52 430 195 C 430.01 203.48 429.15 211.93 427.46 220.24 C 425.82 228.24 423.39 236.06 420.2 243.58 C 413.9 258.45 404.79 271.95 393.36 283.36 C 381.95 294.79 368.45 303.9 353.58 310.2 C 346.06 313.39 338.24 315.82 330.24 317.46 C 321.93 319.15 313.48 320.01 305 320 C 296.52 320.01 288.07 319.15 279.76 317.46 C 271.76 315.82 263.94 313.39 256.42 310.2 C 241.55 303.9 228.05 294.79 216.64 283.36 C 205.21 271.95 196.1 258.45 189.8 243.58 C 186.61 236.06 184.18 228.24 182.54 220.24 C 180.85 211.93 179.99 203.48 180 195 Z M 13 490 L 13 413.148 L 126.148 300 L 203 376.852 L 89.852 490 L 13 490 Z M 205 160 L 405 160 L 405 230 L 205 230 L 205 160 Z",fill:!0,fillRule:"evenodd",stroke:0}};e.icons={},Object.keys(t).forEach((a=>{let o=t[a],l=document.createElementNS("http://www.w3.org/2000/svg","svg");l.setAttribute("viewBox",o.viewbox),l.setAttribute("xmlns","http://www.w3.org/2000/svg"),l.classList.add("radix-icon"),l.classList.add("rdx-icon-"+a);let r=document.createElementNS("http://www.w3.org/2000/svg","path");r.setAttribute("d",o.path),o.fill?(r.setAttribute("fill","currentColor"),void 0!==o.fillRule&&r.setAttribute("fill-rule",o.fillRule)):r.setAttribute("fill","none"),0===o.stroke?r.setAttribute("stroke","none"):(r.setAttribute("stroke","currentColor"),r.setAttribute("stroke-linejoin",o.linejoin),r.setAttribute("stroke-linecap",o.linecap)),r.setAttribute("stroke","none"),l.appendChild(r),e.icons[a]=l}));let a=document.createElementNS("http://www.w3.org/2000/svg","svg"),o=document.createElementNS("http://www.w3.org/2000/svg","line"),l=document.createElementNS("http://www.w3.org/2000/svg","line"),r=document.createElementNS("http://www.w3.org/2000/svg","line");a.setAttribute("viewBox","0 0 50 50"),a.setAttribute("xmlns","http://www.w3.org/2000/svg"),a.classList.add("radix-icon"),a.classList.add("rdx-icon-hamburger"),o.setAttribute("x1",5),o.setAttribute("y1",13),o.setAttribute("x2",45),o.setAttribute("y2",13),o.classList.add("bar1"),l.setAttribute("x1",5),l.setAttribute("y1",25),l.setAttribute("x2",45),l.setAttribute("y2",25),l.classList.add("bar2"),r.setAttribute("x1",5),r.setAttribute("y1",37),r.setAttribute("x2",45),r.setAttribute("y2",37),r.classList.add("bar3"),a.appendChild(o),a.appendChild(l),a.appendChild(r),e.icons.hamburger=a;let s=document.querySelectorAll(e.option.icons.selector);s&&s.forEach((t=>{let a=t.textContent;e.replaceIcon(t,a)}))}t()})))).then((()=>new Promise((t=>{if(e.option.smoothScroll.active||e.option.fixExtLink.active){const t=document.querySelectorAll("a");let a=null,o=null;t.forEach((t=>{t.hasAttribute("href")&&0!=t.getAttribute("href").length||t.setAttribute("href","#");let l=t.getAttribute("href");if(e.option.smoothScroll.active){let r=l.substring(0,1),s=l.substring(1);"#"===r&&t.addEventListener("click",(l=>{l.preventDefault();const r=s.length>0?document.getElementById(s):document.body,n=t.dataset.scrollEasing,i=t.dataset.scrollDuration,d=e.option.smoothScroll.header?document.querySelector(e.option.smoothScroll.header):null,c="fixed"===(d?window.getComputedStyle(d).getPropertyValue("position"):null)?d.offsetHeight:0;a=window.scrollY,o=window.scrollY+r.getBoundingClientRect().top-c,e.smoothScroll(a,o,i,n)}))}if(e.option.fixExtLink.active){let e=null;if(l.match(/.+\.pdf$/))t.setAttribute("target","_blank"),t.setAttribute("rel","noopener"),t.classList.add("rdx-pdf");else if(l.match(/^http/)){e=window.location.hostname;const a=l.replace(/\\/g,"/").match(/\/\/([^/]*)/);(""===e||a&&a[1]!==e)&&(t.setAttribute("target","_blank"),t.setAttribute("rel","noopener"),t.classList.add("rdx-extlink"))}}}))}if(e.option.toggleNav.active&&""!==e.option.toggleNav.trigger&&""!==e.option.toggleNav.target){e.navState=!1,document.querySelectorAll(e.option.toggleNav.trigger).forEach((t=>{t.addEventListener("click",(()=>{e.toggleNav()}))}))}if(e.option.dragScroll.active&&""!==e.option.dragScroll.selector){let t=Array.from(document.querySelectorAll(e.option.dragScroll.selector)),a=document.createElement("div");a.classList.add("rdx-drag-hint");let o=document.createElement("div");o.classList.add("rdx-drag-hint-inner"),a.appendChild(o),o.innerHTML='<div class="rdx-drag-hint-text">DRAG</div>',o.prepend(e.icons.arrow_lr.cloneNode(!0)),t.length>0&&t.forEach((t=>{t.style.overflow="auto",t.style.position="relative",t.addEventListener("mousedown",(a=>{e.dragDown(t,a)}),!1),t.scrollWidth>t.clientWidth&&e.option.dragScroll.hint&&(t.appendChild(a.cloneNode(!0)),t.addEventListener("scroll",(()=>{let e=t.querySelector(".rdx-drag-hint");null!==e&&e.classList.add("hide")})))})),document.addEventListener("touchmove",(t=>{e.dragMove(t)}),!1),document.addEventListener("mousemove",(t=>{e.dragMove(t)}),!1),document.addEventListener("mouseup",(t=>{e.dragUp(t)}),!1)}if(e.option.flexFix.active){let t=document.querySelectorAll(e.option.flexFix.selector);if(t.length>0){let a=e.option.flexFix.inherit;t.forEach((t=>{let o=Array.from(t.children),l=o[0].cloneNode(a);l.classList.add("rdx-dummy-item");let r=e.option.flexFix.min>o.length?e.option.flexFix.min:o.length;for(let e=0;e<r;e++){let e=l.cloneNode(a);t.appendChild(e)}}))}}if(e.option.scrollAppear.active){const t=document.querySelectorAll(e.option.scrollAppear.selector);t.length>0&&(t.forEach((e=>{e.classList.add("rdx-scroll-appear")})),window.addEventListener("scroll",(()=>{let a=window.innerHeight;t.forEach((t=>{let o=t.hasAttribute("data-appear-reset")?t.dataset.appearReset:e.option.scrollAppear.reset,l=t.hasAttribute("data-appear-class")?t.dataset.appearClass:e.option.scrollAppear.class,r=t.hasAttribute("data-appear-delay")?t.dataset.appearDelay:e.option.scrollAppear.delay,s=t.hasAttribute("data-appear-fixed")?t.dataset.appearFixed:null;if(null===s){let e=t.getBoundingClientRect(),s=t.offsetHeight;e.top<.9*a&&e.top+s>.1*a?setTimeout((()=>{t.classList.add(l)}),r):o&&setTimeout((()=>{t.classList.remove(l)}),r)}else window.pageYOffset>s?setTimeout((()=>{t.classList.add(l)}),r):o&&setTimeout((()=>{t.classList.remove(l)}),r)}))})))}t()})))).then((()=>new Promise((t=>{if(e.option.modal.active){let t=document.querySelectorAll(e.option.modal.selector);t.length>0&&(e.modalParts={viewport:document.createElement("div"),area:document.createElement("div"),wrapper:document.createElement("div"),frame:document.createElement("div"),content:document.createElement("div"),closeButton:e.icons.cross.cloneNode(!0),toggles:document.createElement("div"),magnifier:document.createElement("div"),magnify:e.option.modal.magnify,enlarge:e.icons.zoom_in.cloneNode(!0),shrink:e.icons.zoom_out.cloneNode(!0),scaleDisp:document.createElement("div"),scaleSelector:document.createElement("ul"),scale:e.option.modal.defaultScale,size:{width:0,height:0},class:e.option.modal.class,drag:e.option.modal.drag,dragEvent:t=>{e.dragDown(e.modalParts.wrapper,t)},fit:e.option.modal.fit,duration:e.option.modal.resizeDuration,easing:e.option.modal.resizeEasing},e.modalParts.viewport.classList.add("rdx-modal-viewport"),e.modalParts.area.classList.add("rdx-modal-area"),e.modalParts.wrapper.classList.add("rdx-modal-wrapper"),e.modalParts.content.classList.add("rdx-modal-content"),e.modalParts.frame.classList.add("rdx-modal-frame"),e.modalParts.toggles.classList.add("rdx-modal-toggles"),e.modalParts.viewport.appendChild(e.modalParts.toggles),e.modalParts.viewport.appendChild(e.modalParts.area),e.modalParts.area.appendChild(e.modalParts.wrapper),e.modalParts.wrapper.appendChild(e.modalParts.frame),e.modalParts.frame.appendChild(e.modalParts.content),e.modalParts.magnifier.classList.add("rdx-modal-magnifier"),e.modalParts.enlarge.classList.add("rdx-modal-enlarge"),e.modalParts.shrink.classList.add("rdx-modal-shrink"),e.modalParts.scaleDisp.classList.add("rdx-modal-scale"),e.modalParts.toggles.appendChild(e.modalParts.magnifier),e.modalParts.magnifier.appendChild(e.modalParts.scaleDisp),e.modalParts.magnifier.appendChild(e.modalParts.enlarge),e.modalParts.magnifier.appendChild(e.modalParts.shrink),e.modalParts.closeButton.classList.add("rdx-modal-close"),e.modalParts.toggles.appendChild(e.modalParts.closeButton),e.modalParts.scaleSelector.classList.add("rdx-modal-scaler"),e.modalParts.magnifier.appendChild(e.modalParts.scaleSelector),document.body.appendChild(e.modalParts.viewport),e.modalParts.scaleDisp.addEventListener("click",(t=>{t.preventDefault();let a=e.option.modal.scaleStep.indexOf(e.modalParts.scale);e.modalParts.scaleSelector.scrollTop=40*a,e.modalParts.scaleSelector.classList.add("active")})),e.option.modal.scaleStep.forEach((t=>{let a=document.createElement("li");a.innerHTML=e.floatRound(t,1)+"x",a.dataset.scale=t,e.modalParts.scaleSelector.appendChild(a),a.addEventListener("click",(o=>{o.preventDefault(),e.modalResize(a.dataset.scale),e.modalParts.scale=t}))})),e.modalParts.enlarge.addEventListener("click",(t=>{t.preventDefault();let a=e.option.modal.scaleStep.indexOf(e.modalParts.scale),o=a<e.option.modal.scaleStep.length-1?e.option.modal.scaleStep[a+1]:e.option.modal.scaleStep[a];e.modalResize(o),e.modalParts.scale=o})),e.modalParts.shrink.addEventListener("click",(t=>{t.preventDefault();let a=e.option.modal.scaleStep.indexOf(e.modalParts.scale),o=a>0?e.option.modal.scaleStep[a-1]:e.option.modal.scaleStep[a];e.modalResize(o),e.modalParts.scale=o})),t.forEach((t=>{let a=[];t.hasAttribute("data-modal-target")?(a=document.querySelectorAll(t.dataset.modalTarget),a&&a.forEach((e=>{e.classList.add("rdx-modal-source")}))):(a=[t],t.classList.add("rdx-modal-source")),t.addEventListener("click",(o=>{o.preventDefault();let l=t.hasAttribute("data-modal-duration")?t.dataset.modalDuration:null,r=t.hasAttribute("data-modal-easing")?t.dataset.modalEasing:null,s=t.hasAttribute("data-modal-scale")?t.dataset.modalScale:null,n=t.hasAttribute("data-modal-drag")?t.dataset.modalDrag:null,i=t.hasAttribute("data-modal-magnify")?t.dataset.modalMagnify:null,d=t.hasAttribute("data-modal-fit")?t.dataset.modalFit:null,c=t.hasAttribute("data-modal-class")?t.dataset.modalClass:null,m=t.hasAttribute("data-modal-wrap")?t.dataset.modalWrap:null;e.modalOpen(a,c,l,r,s,n,i,d,m)}))})),e.modalParts.viewport.addEventListener("mouseup",(t=>{let a=t.target;a.classList.contains("rdx-modal-item")||null===a.closest(".rdx-modal-content")&&null===a.closest(".rdx-modal-toggles")&&e.modalClose()}),!1),e.modalParts.closeButton.addEventListener("click",(()=>{e.modalClose()}),!1))}t()})))).then((()=>{document.dispatchEvent(e.events.afterInitialize)}))}smoothScroll(e,t,a,o){const l=this,r=(t=t<0?0:t)-e;a=void 0===a?l.option.smoothScroll.duration:a,o=void 0===o?l.option.smoothScroll.easing:o;let s=l.getEasing(o),n=0,i=null;document.dispatchEvent(l.events.beforeScroll);i=setInterval((()=>{n++;let o=n*l.option.timeFrame,d=s(o,e,r,a);window.scrollTo(0,d),o>a&&(window.scrollTo(0,t),clearInterval(i),document.dispatchEvent(l.events.afterScroll))}),l.option.timeFrame)}preventScroll(e){this.DOM_ROOTS.forEach((t=>{t.style.overflowY=e?"hidden":"initial"}))}toggleNav(e){const t=this;let a=document.querySelectorAll(t.option.toggleNav.trigger),o=document.querySelectorAll(t.option.toggleNav.target);void 0===e?t.navState?(document.dispatchEvent(t.events.beforeNavClose),t.option.toggleNav.preventScroll&&t.preventScroll(!1),t.navState=!1,a.forEach((e=>{e.classList.remove(t.option.toggleNav.class)})),o.forEach((e=>{e.classList.remove(t.option.toggleNav.class)})),document.dispatchEvent(t.events.afterNavClose)):(document.dispatchEvent(t.events.beforeNavOpen),t.option.toggleNav.preventScroll&&t.preventScroll(!0),t.navState=!0,a.forEach((e=>{e.classList.add(t.option.toggleNav.class)})),o.forEach((e=>{e.classList.add(t.option.toggleNav.class)})),document.dispatchEvent(t.events.afterNavOpen)):!0===e||"close"===e?(document.dispatchEvent(t.events.beforeNavClose),t.option.toggleNav.preventScroll&&t.preventScroll(!1),t.navState=!1,a.forEach((e=>{e.classList.remove(t.option.toggleNav.class)})),o.forEach((e=>{e.classList.remove(t.option.toggleNav.class)})),document.dispatchEvent(t.events.afterNavClose)):!1!==e&&"open"!==e||(document.dispatchEvent(t.events.beforeNavOpen),t.option.toggleNav.preventScroll&&t.preventScroll(!0),t.navState=!0,a.forEach((e=>{e.classList.add(t.option.toggleNav.class)})),o.forEach((e=>{e.classList.add(t.option.toggleNav.class)})),document.dispatchEvent(t.events.afterNavOpen))}replaceIcon(e,t){const a=this;t=void 0===t?e.innerText:t,Object.keys(a.icons).includes(t)?e.replaceWith(a.icons[t].cloneNode(!0)):console.log(t+" is not icon name.")}dragDown(e,t){self.isMobile||(e.style.cursor="move",e.setAttribute("rdx-drag-on",!0),e.setAttribute("rdx-drag-scrolled-x",e.scrollLeft),e.setAttribute("rdx-drag-scrolled-y",e.scrollTop),e.setAttribute("rdx-drag-click-x",t.clientX),e.setAttribute("rdx-drag-click-y",t.clientY))}dragMove(e){let t=document.querySelector('[rdx-drag-on="true"]');null!==t&&(e.preventDefault(),t.scrollLeft=Number(t.getAttribute("rdx-drag-scrolled-x"))+Number(t.getAttribute("rdx-drag-click-x"))-e.clientX,t.scrollTop=Number(t.getAttribute("rdx-drag-scrolled-y"))+Number(t.getAttribute("rdx-drag-click-y"))-e.clientY)}dragUp(e){e.preventDefault(),e.stopImmediatePropagation();let t=document.querySelector('[rdx-drag-on="true"]');t&&(t.style.cursor="",t.setAttribute("rdx-drag-on",!1))}modalOpen(e,t,a,o,l,r,s,n,i){const d=this;d.modalState||new Promise((e=>{document.dispatchEvent(d.events.beforeModalOpen),e()})).then((()=>new Promise((e=>{d.modalParts.content.innerHTML="",d.modalParts.magnify=null!==s?s:d.option.modal.magnify,d.modalParts.drag=null!==r?r:d.option.modal.drag,d.modalParts.fit=null!==n?n:d.option.modal.fit,d.modalParts.duration=void 0===a?d.option.modal.resizeDuration:a,d.modalParts.easing=void 0===o?d.option.modal.resizeEasing:o,d.modalParts.wrap=void 0===i?d.option.modal.wrap:i;let l=null!==t?t:d.option.modal.class;l=String(l).split(" "),d.modalParts.class=l,d.preventScroll(!0),e()})))).then((()=>new Promise((t=>{e.forEach((e=>{let t=e.cloneNode(!0);t.classList.remove("rdx-modal-source"),t.classList.add("rdx-modal-item"),d.modalParts.content.appendChild(t)})),t()})))).then((()=>new Promise((e=>{d.modalParts.magnifier.style.display=d.str2bool(d.modalParts.magnify)&&!d.str2bool(d.modalParts.wrap)?"flex":"none",d.modalParts.size={width:d.modalParts.content.offsetWidth,height:d.modalParts.content.offsetHeight},e()})))).then((()=>new Promise((e=>{if(d.modalParts.scale=1,null!==l)d.modalParts.scale=d.floatRound(l,1);else if(d.str2bool(d.modalParts.fit)){let e=d.modalParts.area.clientHeight,t=d.modalParts.area.clientWidth;d.modalParts.scale=d.option.modal.scaleStep[0];for(let a=0;a<d.option.modal.scaleStep.length&&!(d.modalParts.size.width*d.option.modal.scaleStep[a]>t||d.modalParts.size.height*d.option.modal.scaleStep[a]>e);a++)d.modalParts.scale=d.option.modal.scaleStep[a]}d.str2bool(d.modalParts.drag)&&!d.str2bool(d.modalParts.wrap)?d.modalParts.wrapper.addEventListener("mousedown",d.modalParts.dragEvent,!1):d.modalParts.wrapper.removeEventListener("mousedown",d.modalParts.dragEvent,!1),e()})))).then((()=>new Promise((e=>{d.str2bool(d.modalParts.wrap)?(d.modalParts.content.style.maxHeight="100%",d.modalParts.content.style.maxWidth="100%"):(d.modalParts.content.style.transform="scale("+d.modalParts.scale+")",d.modalParts.wrapper.style.height="min("+d.floatCeil(d.modalParts.size.height*d.modalParts.scale,0)+"px, 100%)",d.modalParts.wrapper.style.width="min("+d.floatCeil(d.modalParts.size.width*d.modalParts.scale,0)+"px, 100%)",d.modalParts.scaleDisp.innerHTML=d.floatRound(d.modalParts.scale,1)+"x",d.modalParts.frame.style.height=d.floatCeil(d.modalParts.size.height*d.modalParts.scale,0)+"px",d.modalParts.frame.style.width=d.floatCeil(d.modalParts.size.width*d.modalParts.scale,0)+"px"),d.modalParts.class.forEach((e=>{d.modalParts.viewport.classList.add(e)})),d.modalParts.viewport.classList.add("active"),d.modalState=!0,e()})))).then((()=>{document.dispatchEvent(d.events.afterModalOpen)}))}modalClose(){const e=this;e.modalState&&"true"!==e.modalParts.wrapper.getAttribute("rdx-drag-on")&&new Promise((t=>{document.dispatchEvent(e.events.beforeModalClose),t()})).then((()=>new Promise((t=>{e.modalParts.scaleSelector.classList.remove("active"),e.modalParts.content.innerHTML="",e.preventScroll(!1),e.modalParts.content.style="",e.modalParts.frame.style="",e.modalParts.wrapper.style="",e.modalParts.viewport.classList.remove("active"),setTimeout((()=>{e.modalParts.class.forEach((t=>{e.modalParts.viewport.classList.remove(t)}))}),250),e.modalState=!1,t()})))).then((()=>{document.dispatchEvent(e.events.afterModalClose)}))}modalResize(e){const t=this;if(!t.modalState)return;let a=t.option.modal.resizeDuration,o=t.option.timeFrame,l=0,r=null,s=t.getEasing(t.option.modal.resizeEasing),n=t.modalParts.scale,i=t.modalParts.size.width*n,d=t.modalParts.size.height*n;e=t.floatRound(e,1);let c=t.modalParts.size.width*e,m=t.modalParts.size.height*e,p=e-n,u=t.modalParts.size.width*p,h=t.modalParts.size.height*p;t.modalParts.scaleDisp.innerHTML=t.floatRound(e,1)+"x",t.modalParts.scaleSelector.classList.remove("active"),0!=p&&(r=setInterval((()=>{l++;let v=l*o,f=s(v,i,u,a),g=s(v,d,h,a),L=s(v,n,p,a);t.modalParts.content.style.transform="scale("+L+")",t.modalParts.wrapper.style.width="min("+f+"px, 100%)",t.modalParts.wrapper.style.height="min("+g+"px, 100%)",t.modalParts.frame.style.height=g+"px",t.modalParts.frame.style.width=f+"px",v>a&&(t.modalParts.content.style.transform="scale("+t.floatRound(e,1)+")",t.modalParts.wrapper.style.height="min("+t.floatCeil(m,0)+"px, 100%)",t.modalParts.wrapper.style.width="min("+t.floatCeil(c,0)+"px, 100%)",t.modalParts.frame.style.height=t.floatCeil(m,0)+"px",t.modalParts.frame.style.width=t.floatCeil(c,0)+"px",clearInterval(r))}),o))}typeJudge(e){return toString.call(e).slice(8,-1).toLowerCase()}str2bool(e){return!0===e||!!["true","on","1"].includes(String(e).toLocaleLowerCase())}floatRound(e,t){let a=10**(t=void 0===t?2:Number.parseInt(t));return(Math.round(e*a)/a).toFixed(t)}floatCeil(e,t){let a=10**(t=void 0===t?2:Number.parseInt(t));return(Math.ceil(e*a)/a).toFixed(t)}floatFloor(e,t){let a=10**(t=void 0===t?2:Number.parseInt(t));return(Math.floor(e*a)/a).toFixed(t)}getEasing(e){let t;switch("ease"==e?e="easeInOutCirc":"ease-in"==e||"easeIn"==e?e="easeInQuad":"ease-out"==e||"easeOut"==e?e="easeOutQuad":"ease-in-out"!=e&&"easeInOut"!=e||(e="easeInOutQuad"),e){case"linear":t=function(e,t,a,o){return a*e/o+t};break;case"easeInSine":t=function(e,t,a,o){return-a*Math.cos(e/o*(Math.PI/2))+a+t};break;case"easeOutSine":t=function(e,t,a,o){return a*Math.sin(e/o*(Math.PI/2))+t};break;case"easeInOutSine":t=function(e,t,a,o){return-a/2*(Math.cos(Math.PI*e/o)-1)+t};break;case"easeInQuad":t=function(e,t,a,o){return a*(e/=o)*e+t};break;case"easeOutQuad":t=function(e,t,a,o){return-a*(e/=o)*(e-2)+t};break;case"easeInOutQuad":t=function(e,t,a,o){return(e/=o/2)<1?a/2*e*e+t:-a/2*(--e*(e-2)-1)+t};break;case"easeInCubic":t=function(e,t,a,o){return a*(e/=o)*e*e+t};break;case"easeOutCubic":t=function(e,t,a,o){return a*((e=e/o-1)*e*e+1)+t};break;case"easeInOutCubic":t=function(e,t,a,o){return(e/=o/2)<1?a/2*e*e*e+t:a/2*((e-=2)*e*e+2)+t};break;case"easeInQuart":t=function(e,t,a,o){return a*(e/=o)*e*e*e+t};break;case"easeOutQuart":t=function(e,t,a,o){return-a*((e=e/o-1)*e*e*e-1)+t};break;case"easeInOutQuart":t=function(e,t,a,o){return(e/=o/2)<1?a/2*e*e*e*e+t:-a/2*((e-=2)*e*e*e-2)+t};break;case"easeInQuint":t=function(e,t,a,o){return a*(e/=o)*e*e*e*e+t};break;case"easeOutQuint":t=function(e,t,a,o){return a*((e=e/o-1)*e*e*e*e+1)+t};break;case"easeInOutQuint":t=function(e,t,a,o){return(e/=o/2)<1?a/2*e*e*e*e*e+t:a/2*((e-=2)*e*e*e*e+2)+t};break;case"easeInExpo":t=function(e,t,a,o){return 0==e?t:a*Math.pow(2,10*(e/o-1))+t};break;case"easeOutExpo":t=function(e,t,a,o){return e==o?t+a:a*(1-Math.pow(2,-10*e/o))+t};break;case"easeInOutExpo":t=function(e,t,a,o){return 0==e?t:e==o?t+a:(e/=o/2)<1?a/2*Math.pow(2,10*(e-1))+t:a/2*(2-Math.pow(2,-10*--e))+t};break;case"easeInCirc":t=function(e,t,a,o){return-a*(Math.sqrt(1-(e/=o)*e)-1)+t};break;case"easeOutCirc":t=function(e,t,a,o){return a*Math.sqrt(1-(e=e/o-1)*e)+t};break;case"easeInOutCirc":t=function(e,t,a,o){return(e/=o/2)<1?-a/2*(Math.sqrt(1-e*e)-1)+t:a/2*(Math.sqrt(1-(e-=2)*e)+1)+t};break;case"easeInElastic":t=function(e,t,a,o){var l=1.70158,r=0,s=a;if(0==e)return t;if(1==(e/=o))return t+a;if(r||(r=.3*o),s<Math.abs(a)){s=a;l=r/4}else l=r/(2*Math.PI)*Math.asin(a/s);return-s*Math.pow(2,10*(e-=1))*Math.sin((e*o-l)*(2*Math.PI)/r)+t};break;case"easeOutElastic":t=function(e,t,a,o){var l=1.70158,r=0,s=a;if(0==e)return t;if(1==(e/=o))return t+a;if(r||(r=.3*o),s<Math.abs(a)){s=a;l=r/4}else l=r/(2*Math.PI)*Math.asin(a/s);return s*Math.pow(2,-10*e)*Math.sin((e*o-l)*(2*Math.PI)/r)+a+t};break;case"easeInOutElastic":t=function(e,t,a,o){var l=1.70158,r=0,s=a;if(0==e)return t;if(2==(e/=o/2))return t+a;if(r||(r=o*(.3*1.5)),s<Math.abs(a)){s=a;l=r/4}else l=r/(2*Math.PI)*Math.asin(a/s);return e<1?s*Math.pow(2,10*(e-=1))*Math.sin((e*o-l)*(2*Math.PI)/r)*-.5+t:s*Math.pow(2,-10*(e-=1))*Math.sin((e*o-l)*(2*Math.PI)/r)*.5+a+t};break;case"easeInBack":t=function(e,t,a,o,l){return null==l&&(l=1.70158),a*(e/=o)*e*((l+1)*e-l)+t};break;case"easeOutBack":t=function(e,t,a,o,l){return null==l&&(l=1.70158),a*((e=e/o-1)*e*((l+1)*e+l)+1)+t};break;case"easeInOutBack":t=function(e,t,a,o,l){return null==l&&(l=1.70158),(e/=o/2)<1?a/2*(e*e*((1+(l*=1.525))*e-l))+t:a/2*((e-=2)*e*((1+(l*=1.525))*e+l)+2)+t};break;case"easeInBounce":t=function(e,t,a,o){return e=o-e,(e/=o)<1/2.75?a-a*(7.5625*e*e)+t:e<2/2.75?a-a*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?a-a*(7.5625*(e-=2.25/2.75)*e+.9375)+t:a-a*(7.5625*(e-=2.625/2.75)*e+.984375)+t};break;case"easeOutBounce":t=function(e,t,a,o){return(e/=o)<1/2.75?a*(7.5625*e*e)+t:e<2/2.75?a*(7.5625*(e-=1.5/2.75)*e+.75)+t:e<2.5/2.75?a*(7.5625*(e-=2.25/2.75)*e+.9375)+t:a*(7.5625*(e-=2.625/2.75)*e+.984375)+t};break;case"easeInOutBounce":t=function(e,t,a,o){return e<o/2?(e=o-2*e,(e/=o)<1/2.75?.5*a-a*(7.5625*e*e)*.5+t:e<2/2.75?.5*a-a*(7.5625*(e-=1.5/2.75)*e+.75)*.5+t:e<2.5/2.75?.5*a-a*(7.5625*(e-=2.25/2.75)*e+.9375)*.5+t:.5*a-a*(7.5625*(e-=2.625/2.75)*e+.984375)*.5+t):(e=2*e-o,(e/=o)<1/2.75?a*(7.5625*e*e)*.5+.5*a+t:e<2/2.75?a*(7.5625*(e-=1.5/2.75)*e+.75)*.5+.5*a+t:e<2.5/2.75?a*(7.5625*(e-=2.25/2.75)*e+.9375)*.5+.5*a+t:a*(7.5625*(e-=2.625/2.75)*e+.984375)*.5+.5*a+t)}}return t}}