X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/7f902e41c7a6a18a754bb889c2655aa4fba736ec..refs/pull/1117/head:/resources/assets/js/components/notification.js diff --git a/resources/assets/js/components/notification.js b/resources/assets/js/components/notification.js index 1a9819702..f7edb08aa 100644 --- a/resources/assets/js/components/notification.js +++ b/resources/assets/js/components/notification.js @@ -6,11 +6,16 @@ class Notification { this.type = elem.getAttribute('notification'); this.textElem = elem.querySelector('span'); this.autohide = this.elem.hasAttribute('data-autohide'); - window.Events.listen(this.type, text => { + this.elem.style.display = 'grid'; + + window.$events.listen(this.type, text => { this.show(text); }); elem.addEventListener('click', this.hide.bind(this)); - if (elem.hasAttribute('data-show')) this.show(this.textElem.textContent); + + if (elem.hasAttribute('data-show')) { + setTimeout(() => this.show(this.textElem.textContent), 100); + } this.hideCleanup = this.hideCleanup.bind(this); } @@ -18,7 +23,7 @@ class Notification { show(textToShow = '') { this.elem.removeEventListener('transitionend', this.hideCleanup); this.textElem.textContent = textToShow; - this.elem.style.display = 'block'; + this.elem.style.display = 'grid'; setTimeout(() => { this.elem.classList.add('showing'); }, 1); @@ -38,4 +43,4 @@ class Notification { } -module.exports = Notification; \ No newline at end of file +export default Notification; \ No newline at end of file