mirror of
https://github.com/the-djmaze/snappymail.git
synced 2025-01-10 00:38:04 +08:00
7 lines
3.9 KiB
JavaScript
7 lines
3.9 KiB
JavaScript
/*!
|
|
* Native JavaScript for Bootstrap v3.0.10 (https://thednp.github.io/bootstrap.native/)
|
|
* Copyright 2015-2020 © dnp_theme
|
|
* Licensed under MIT (https://github.com/thednp/bootstrap.native/blob/master/LICENSE)
|
|
*/
|
|
|
|
window.BSN=(()=>{"use strict";const e="transitionend",t=document,s=t.body,i=e=>e.focus?e.focus():e.setActive();function n(t,s){var i=0,n=parseFloat(getComputedStyle(t).transitionDuration),o=n=>{!i&&s(n),i=1,t.removeEventListener(e,o)};isFinite(n)&&n?t.addEventListener(e,o):setTimeout(()=>{!i&&s(),i=1},17)}return{Dropdown:function(e){var s,n,o=this,a=[];function c(e,t){const s=t.parentNode;(t.href&&"#"===t.href.slice(-1)||s&&s.href&&"#"===s.href.slice(-1))&&e.preventDefault()}function r(){let s=e.open?"addEventListener":"removeEventListener";t[s]("click",l,!1),t[s]("keydown",h,!1),t[s]("keyup",u,!1),t[s]("focus",l,!1)}function l(t){let s=t.target,i=s&&(s.getAttribute("data-toggle")||s.parentNode&&s.parentNode.getAttribute("data-toggle"));("focus"!==t.type||s!==e&&s!==n&&!n.contains(s))&&(i&&(s===n||n.contains(s))||(o.hide(),c(t,s)))}function d(e){o.show(),c(e,e.target)}function h(e){("ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault()}function u(s){var c=t.activeElement,r=c===e,l=n.contains(c),d=c.parentNode===n||c.parentNode.parentNode===n,h=a.indexOf(c);d&&(h=r?0:"ArrowUp"===s.code?h>1?h-1:0:"ArrowDown"===s.code&&h<a.length-1?h+1:h,a[h]&&i(a[h])),(a.length&&d||!a.length&&(l||r)||!l)&&e.open&&"Escape"===s.code&&o.toggle()}o.show=(()=>{n=s.querySelector(".dropdown-menu"),a=[],Array.from(n.children).forEach(e=>{e.children.length&&"A"===e.children[0].tagName&&a.push(e.children[0]),"A"===e.tagName&&a.push(e)}),!("tabindex"in n)&&n.setAttribute("tabindex","0"),n.classList.add("show"),s.classList.add("show"),e.setAttribute("aria-expanded",!0),e.open=!0,e.removeEventListener("click",d,!1),setTimeout(()=>{i(n.getElementsByTagName("INPUT")[0]||e),r()},1)}),o.hide=(()=>{n.classList.remove("show"),s.classList.remove("show"),e.setAttribute("aria-expanded",!1),e.open=!1,r(),i(e),setTimeout(()=>e.Dropdown&&e.addEventListener("click",d,!1),1)}),o.toggle=(()=>s.classList.contains("show")&&e.open?o.hide():o.show()),s=e.parentNode,e.addEventListener("click",d,!1),e.open=!1,e.Dropdown=o},Modal:function(e){var o;function a(){var i,n,a=s.classList.contains("modal-open"),c=parseInt(getComputedStyle(s).paddingRight),r=t.documentElement.clientHeight!==t.documentElement.scrollHeight||s.clientHeight!==s.scrollHeight,l=e.clientHeight!==e.scrollHeight;(n=t.createElement("div")).className="modal-scrollbar-measure",s.appendChild(n),i=n.offsetWidth-n.clientWidth,s.removeChild(n),o=i,e.style.paddingRight=!l&&o?o+"px":"",s.style.paddingRight=l||r?c+(a?0:o)+"px":""}function c(t){window[t?"addEventListener":"removeEventListener"]("resize",()=>e.classList.contains("show")&&a(),{passive:!0})}function r(){e.style.display="block",a(),!t.getElementsByClassName("modal show")[0]&&s.classList.add("modal-open"),e.classList.add("show"),e.setAttribute("aria-hidden",!1),e.classList.contains("fade")?n(e,l):l()}function l(){i(e),e.isAnimating=!1,c(1)}function d(){e.style.display="",s.classList.remove("modal-open"),s.style.paddingRight="",e.style.paddingRight="",c(),e.isAnimating=!1}this.show=(()=>{e.classList.contains("show")&&e.isAnimating||(e.isAnimating=!0,t.getElementsByClassName("modal show")[0]?r():setTimeout(r,0))}),this.hide=(()=>{e.classList.contains("show")&&(e.isAnimating=!0,e.classList.remove("show"),e.setAttribute("aria-hidden",!0),e.classList.contains("fade")?n(e,d):d())}),e.isAnimating=!1,e.Modal=this},Tab:class{constructor(e){this.element=e,e.Tab=this,e.addEventListener("click",e=>{e.preventDefault(),this.show()})}show(){const e=this.element,s=e.closest("li");if(!s.classList.contains("active")){const i=e.closest("ul").querySelector(".active a");i.closest("li").classList.remove("active"),t.querySelector(i.getAttribute("href")).classList.remove("active"),s.classList.add("active"),t.querySelector(e.getAttribute("href")).classList.add("active")}}}}})();
|