6 this.type = elem.getAttribute('notification');
7 this.textElem = elem.querySelector('span');
8 this.autohide = this.elem.hasAttribute('data-autohide');
9 window.$events.listen(this.type, text => {
12 elem.addEventListener('click', this.hide.bind(this));
13 if (elem.hasAttribute('data-show')) this.show(this.textElem.textContent);
15 this.hideCleanup = this.hideCleanup.bind(this);
18 show(textToShow = '') {
19 this.elem.removeEventListener('transitionend', this.hideCleanup);
20 this.textElem.textContent = textToShow;
21 this.elem.style.display = 'block';
23 this.elem.classList.add('showing');
26 if (this.autohide) setTimeout(this.hide.bind(this), 2000);
30 this.elem.classList.remove('showing');
31 this.elem.addEventListener('transitionend', this.hideCleanup);
35 this.elem.style.display = 'none';
36 this.elem.removeEventListener('transitionend', this.hideCleanup);
41 module.exports = Notification;