6 this.type = elem.getAttribute('notification');
7 this.textElem = elem.querySelector('span');
8 this.autohide = this.elem.hasAttribute('data-autohide');
9 this.elem.style.display = 'grid';
11 window.$events.listen(this.type, text => {
14 elem.addEventListener('click', this.hide.bind(this));
16 if (elem.hasAttribute('data-show')) {
17 setTimeout(() => this.show(this.textElem.textContent), 100);
20 this.hideCleanup = this.hideCleanup.bind(this);
23 show(textToShow = '') {
24 this.elem.removeEventListener('transitionend', this.hideCleanup);
25 this.textElem.textContent = textToShow;
26 this.elem.style.display = 'grid';
28 this.elem.classList.add('showing');
31 if (this.autohide) setTimeout(this.hide.bind(this), 2000);
35 this.elem.classList.remove('showing');
36 this.elem.addEventListener('transitionend', this.hideCleanup);
40 this.elem.style.display = 'none';
41 this.elem.removeEventListener('transitionend', this.hideCleanup);
46 export default Notification;