mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-05-30 12:38:12 +08:00
Converted image manager into vue component
This commit is contained in:
@ -21,6 +21,8 @@ for (let i = 0, len = componentNames.length; i < len; i++) {
|
||||
if (typeof window.components[name] === "undefined") window.components[name] = [];
|
||||
for (let j = 0, jLen = elems.length; j < jLen; j++) {
|
||||
let instance = new component(elems[j]);
|
||||
if (typeof elems[j].components === 'undefined') elems[j].components = {};
|
||||
elems[j].components[name] = instance;
|
||||
window.components[name].push(instance);
|
||||
}
|
||||
}
|
@ -7,14 +7,16 @@ class Notification {
|
||||
this.textElem = elem.querySelector('span');
|
||||
this.autohide = this.elem.hasAttribute('data-autohide');
|
||||
window.Events.listen(this.type, text => {
|
||||
console.log('show', text);
|
||||
this.show(text);
|
||||
});
|
||||
elem.addEventListener('click', this.hide.bind(this));
|
||||
if (elem.hasAttribute('data-show')) this.show(this.textElem.textContent);
|
||||
|
||||
this.hideCleanup = this.hideCleanup.bind(this);
|
||||
}
|
||||
|
||||
show(textToShow = '') {
|
||||
this.elem.removeEventListener('transitionend', this.hideCleanup);
|
||||
this.textElem.textContent = textToShow;
|
||||
this.elem.style.display = 'block';
|
||||
setTimeout(() => {
|
||||
@ -26,13 +28,12 @@ class Notification {
|
||||
|
||||
hide() {
|
||||
this.elem.classList.remove('showing');
|
||||
this.elem.addEventListener('transitionend', this.hideCleanup);
|
||||
}
|
||||
|
||||
function transitionEnd() {
|
||||
this.elem.style.display = 'none';
|
||||
this.elem.removeEventListener('transitionend', transitionEnd);
|
||||
}
|
||||
|
||||
this.elem.addEventListener('transitionend', transitionEnd.bind(this));
|
||||
hideCleanup() {
|
||||
this.elem.style.display = 'none';
|
||||
this.elem.removeEventListener('transitionend', this.hideCleanup);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user