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 => {
10 console.log('show', text);
13 elem.addEventListener('click', this.hide.bind(this));
14 if (elem.hasAttribute('data-show')) this.show(this.textElem.textContent);
17 show(textToShow = '') {
18 this.textElem.textContent = textToShow;
19 this.elem.style.display = 'block';
21 this.elem.classList.add('showing');
24 if (this.autohide) setTimeout(this.hide.bind(this), 2000);
28 this.elem.classList.remove('showing');
30 function transitionEnd() {
31 this.elem.style.display = 'none';
32 this.elem.removeEventListener('transitionend', transitionEnd);
35 this.elem.addEventListener('transitionend', transitionEnd.bind(this));
40 module.exports = Notification;