class AlertElement extends HTMLElement { constructor() { super(); this.close = this.close.bind(this); this.destroyCloseButton = this.destroyCloseButton.bind(this); this.createCloseButton = this.createCloseButton.bind(this); this.onMutation = this.onMutation.bind(this); this.observer = new MutationObserver(this.onMutation); this.observer.observe(this, { attributes: false, childList: true, subtree: true }); this.addEventListener('animationend', (event) => { if (event.animationName === 'ecoui-alert-fade-in' && event.target === this) { this.dispatchEvent(new CustomEvent('ecoui.alert.shown')); this.style.removeProperty('animationName'); } }); this.addEventListener('animationend', (event) => { if (event.animationName === 'ecoui-alert-fade-out' && event.target === this) { this.dispatchEvent(new CustomEvent('ecoui.alert.closed')); this.remove(); } }); } static get observedAttributes() { return ['type', 'role', 'dismiss', 'auto-dismiss', 'close-text']; } get type() { return this.getAttribute('type'); } set type(value) { this.setAttribute('type', value); } get role() { return this.getAttribute('role'); } set role(value) { this.setAttribute('role', value); } get closeText() { return this.getAttribute('close-text'); } set closeText(value) { this.setAttribute('close-text', value); } get dismiss() { return this.getAttribute('dismiss'); } set dismiss(value) { this.setAttribute('dismiss', value); } get autodismiss() { return this.getAttribute('auto-dismiss'); } set autodismiss(value) { this.setAttribute('auto-dismiss', value); } connectedCallback() { this.dispatchEvent(new CustomEvent('ecoui.alert.show')); this.style.animationName = 'ecoui-alert-fade-in'; if (!this.type || !['info', 'warning', 'danger', 'success'].includes(this.type)) { this.setAttribute('type', 'info'); } if (!this.role || !['alert', 'alertdialog'].includes(this.role)) { this.setAttribute('role', 'alert'); } if (this.firstElementChild && this.firstElementChild.tagName === 'BUTTON') { this.button = this.firstElementChild; if (this.button.classList.contains('ecoui-alert--close')) { this.button.classList.add('ecoui-alert--close'); } if (this.button.innerHTML === '') { this.button.innerHTML = ''; } if (!this.button.hasAttribute('aria-label')) { this.button.setAttribute('aria-label', this.closeText); } } if (this.hasAttribute('dismiss') && !this.button) { this.createCloseButton(); } if (this.hasAttribute('auto-dismiss')) { this.autoDismiss(); } } disconnectedCallback() { if (this.button) { this.button.removeEventListener('click', this.close); } this.observer.disconnect(); } attributeChangedCallback(attr, oldValue, newValue) { switch (attr) { case 'type': if (!newValue || (newValue && ['info', 'warning', 'danger', 'success'].indexOf(newValue) === -1)) { this.type = 'info'; } break; case 'role': if (!newValue || (newValue && ['alert', 'alertdialog'].indexOf(newValue) === -1)) { this.role = 'alert'; } break; case 'dismiss': if ((!newValue || newValue === '') && (!oldValue || oldValue === '')) { if (this.button && !this.hasAttribute('dismiss')) { this.destroyCloseButton(); } else if (!this.button && this.hasAttribute('dismiss')) { this.createCloseButton(); } } else if (this.button && newValue === 'false') { this.destroyCloseButton(); } else if (!this.button && newValue !== 'false') { this.createCloseButton(); } break; case 'close-text': if (!newValue || newValue !== oldValue) { if (this.button) { this.button.setAttribute('aria-label', newValue); } } break; case 'auto-dismiss': this.autoDismiss(); break; } } onMutation(mutationsList) { for (const mutation of mutationsList) { if (mutation.type === 'childList') { if (mutation.addedNodes.length) { if (this.button && this.firstElementChild !== this.button) { this.prepend(this.button); } } } } } close() { this.dispatchEvent(new CustomEvent('ecoui.alert.close')); this.style.animationName = 'ecoui-alert-fade-out'; } createCloseButton() { this.button = document.createElement('button'); this.button.setAttribute('type', 'button'); this.button.classList.add('ecoui-alert--close'); this.button.innerHTML = ''; this.button.setAttribute('aria-label', this.closeText); this.insertAdjacentElement('afterbegin', this.button); this.button.addEventListener('click', this.close); } destroyCloseButton() { if (this.button) { this.button.removeEventListener('click', this.close); this.button.parentNode.removeChild(this.button); this.button = null; } } autoDismiss() { const timer = parseInt(this.getAttribute('auto-dismiss'), 10); setTimeout(this.close, timer >= 10 ? timer : 3000); } } if (!customElements.get('ecoui-alert')) { customElements.define('ecoui-alert', AlertElement); } function tabSwiper(e){var a=function(){if(sonWidthSum(e+">li")+$(".caret",e).length>$(e).parent().width())if($(e).hasClass("swiper-wrapper"))$(e).hasClass("flex-start")||$(e).addClass("flex-start");else{$(e).addClass("swiper-wrapper flex-start").wrap('
').after('
').find(">li").addClass("swiper-slide");new Swiper(".swiper-navtab",{scrollbar:{el:".swiper-scrollbar",draggable:!0},slidesPerView:"auto"})}else $(e).hasClass("flex-start")&&$(e).removeClass("flex-start")};a(),$(window).resize(function(){a()}),$(e).removeClass("invisible-xs")}function sonWidthSum(e,a){var t=$(e),i=t.length,l=0;(a>i||!a)&&(a=i);for(var s=0;s