2 lines
2.6 KiB
JavaScript
2 lines
2.6 KiB
JavaScript
!function(){"use strict";function e(e,n,t){if(t||2===arguments.length)for(var i,o=0,s=n.length;o<s;o++)!i&&o in n||(i||(i=Array.prototype.slice.call(n,0,o)),i[o]=n[o]);return e.concat(i||Array.prototype.slice.call(n))}"function"==typeof SuppressedError&&SuppressedError;var n=function(e,n){return void 0===n&&(n=document),n.querySelector(e)},t=function(n,t){return void 0===t&&(t=document),e([],Array.from(t.querySelectorAll(n)),!0)},i=".x13gpsr__backdrop",o=".x13gpsr__box-inner",s={show:".x13gpsr__btn--show",close:".x13gpsr__btn--close"},l={link:".x13gpsr__nav-link",tab:".x13gpsr__tab-pane"},c={elements:{links:[],tabs:[]},init:function(){c.cacheElements(),c.setEvents()},cacheElements:function(){c.elements.links=t(l.link),c.elements.tabs=t(l.tab)},setEvents:function(){var e;null===(e=c.elements.links)||void 0===e||e.forEach((function(e){e.addEventListener("click",c.handleNavLink)}))},handleNavLink:function(t){t.preventDefault();var i=t.currentTarget,o=i.getAttribute("href");if(o){var s=n(o);s&&(e(e([],c.elements.links,!0),c.elements.tabs,!0).forEach((function(e){e.classList.remove("active")})),i.classList.add("active"),s.classList.add("active"))}}},a="x13gpsr-block",r="x13gpsr-hidden",d="x13gpsr-transition",u={elements:{closeBtn:null,backdrop:null},init:function(){!function(e,i){void 0===i&&(i="body");var o=t(e),s=n(i);s&&0!==o.length&&o.forEach((function(e){var n=e.parentElement;if(n&&!("body"===i&&"BODY"===n.tagName||"body"!==i&&n.matches(i))){var t=n.removeChild(e);s.appendChild(t)}}))}(i),u.cacheElements(),u.setEvents(),c.init()},cacheElements:function(){var e=i,t=s;u.elements.closeBtn=n(t.close),u.elements.backdrop=n(e)},setEvents:function(){var e,n;null===(e=u.elements.closeBtn)||void 0===e||e.addEventListener("click",u.handleClose),null===(n=u.elements.backdrop)||void 0===n||n.addEventListener("click",u.handleClick)},handleClose:function(e){e.preventDefault(),u.hide()},handleClick:function(e){var n=o;e.target.closest(n)||u.hide()},show:function(){var e;document.body.style.paddingRight=window.innerWidth-document.documentElement.clientWidth+"px",document.body.classList.add(a),null===(e=u.elements.backdrop)||void 0===e||e.classList.remove(r),setTimeout((function(){document.body.classList.add(d)}),10)},hide:function(){document.body.classList.remove(d),setTimeout((function(){var e;document.body.classList.remove(a),document.body.style.paddingRight="",null===(e=u.elements.backdrop)||void 0===e||e.classList.add(r)}),300)}},v={init:function(){var e;null===(e=n(s.show))||void 0===e||e.addEventListener("click",v.handleShow),u.init()},handleShow:function(e){e.preventDefault(),u.show()}};document.addEventListener("DOMContentLoaded",(function(){v.init()}))}();
|