snappymail/vendors/bootstrap/js/bootstrap.native.min.js

8 lines
3 KiB
JavaScript
Raw Normal View History

/*!
* 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)
*/
2020-09-02 03:50:17 +08:00
window.BSN=(()=>{"use strict";const e=document,t=e.body,s=e=>e.focus?e.focus():e.setActive();return{Dropdown:function(t){let o,n=[];const a=this,i=t.parentNode,r=e=>{const t=e.target,s=t.href||t.parentNode&&t.parentNode.href;s&&"#"===s.slice(-1)&&e.preventDefault()},d=()=>{let s=t.open?"addEventListener":"removeEventListener";e[s]("click",c,!1),e[s]("keydown",h,!1),e[s]("keyup",u,!1),e[s]("focus",c,!1)},c=e=>{let s=e.target,n=o.contains(s),i=s&&(s.getAttribute("data-toggle")||s.parentNode&&s.parentNode.getAttribute("data-toggle"));"focus"===e.type&&(s===t||n)||i&&n||(a.hide(),r(e))},l=e=>{a.show(),r(e)},h=e=>("ArrowUp"===e.code||"ArrowDown"===e.code)&&e.preventDefault(),u=i=>{let r=e.activeElement,d=r===t,c=o.contains(r),l=r.parentNode===o||r.parentNode.parentNode===o,h=n.indexOf(r);l&&(h=d?0:"ArrowUp"===i.code?h>1?h-1:0:"ArrowDown"===i.code&&h<n.length-1?h+1:h,n[h]&&s(n[h])),(n.length&&l||!n.length&&(c||d)||!c)&&t.open&&"Escape"===i.code&&a.toggle()};a.show=(()=>{o=i.querySelector(".dropdown-menu"),n=[],Array.from(o.children).forEach(e=>{e.children.length&&"A"===e.children[0].tagName&&n.push(e.children[0]),"A"===e.tagName&&n.push(e)}),!("tabindex"in o)&&o.setAttribute("tabindex","0"),o.classList.add("show"),i.classList.add("show"),t.setAttribute("aria-expanded",!0),t.open=!0,t.removeEventListener("click",l,!1),setTimeout(()=>{s(o.getElementsByTagName("INPUT")[0]||t),d()},1)}),a.hide=(()=>{o.classList.remove("show"),i.classList.remove("show"),t.setAttribute("aria-expanded",!1),t.open=!1,d(),s(t),setTimeout(()=>t.Dropdown&&t.addEventListener("click",l,!1),1)}),a.toggle=(()=>i.classList.contains("show")&&t.open?a.hide():a.show()),t.addEventListener("click",l,!1),t.open=!1,t.Dropdown=a},Modal:function(o){let n=!1;const a=o.classList,i=(e,t)=>{let s=parseFloat(getComputedStyle(e).transitionDuration),o=s=>{t&&t(s),t=0,e.removeEventListener("transitionend",o)};isFinite(s)&&s?e.addEventListener("transitionend",o):setTimeout(()=>{t&&t(),t=0},17)},r=()=>{!e.getElementsByClassName("modal show")[0]&&t.classList.add("modal-open"),a.add("show"),o.setAttribute("aria-hidden",!1),a.contains("fade")?i(o,d):d()},d=()=>{s(o),n=!1},c=()=>{t.classList.remove("modal-open"),n=!1};this.show=(()=>{a.contains("show")&&n||(n=!0,e.getElementsByClassName("modal show")[0]?r():setTimeout(r,0))}),this.hide=(()=>{a.contains("show")&&(n=!0,a.remove("show"),o.setAttribute("aria-hidden",!0),a.contains("fade")?i(o,c):c())}),o.Modal=this},Tab:class{constructor(e){this.element=e,e.Tab=this,e.addEventListener("click",e=>{e.preventDefault(),this.show()})}show(){const t=this.element,s=t.closest("li");if(!s.classList.contains("active")){const o=t.closest("ul").querySelector(".active a");o.closest("li").classList.remove("active"),e.querySelector(o.getAttribute("href")).classList.remove("active"),s.classList.add("active"),e.querySelector(t.getAttribute("href")).classList.add("active")}}}}})();