Add toasts

This commit is contained in:
kichikuou
2017-03-28 21:26:43 +09:00
parent ab6112b0bf
commit f76bf0a19a
4 changed files with 37 additions and 2 deletions
+16
View File
@@ -97,6 +97,22 @@ namespace xsystem35 {
this.zoom.handleZoom();
}
addToast(msg: string, type?: 'success' | 'danger') {
let container = $('.toast-container');
let div = document.createElement('div');
div.classList.add('toast');
if (type)
div.classList.add('toast-' + type);
div.innerText = msg;
let btn = document.createElement('button');
btn.setAttribute('class', 'btn btn-clear float-right');
function dismiss() { container.removeChild(div); }
btn.addEventListener('click', dismiss);
setTimeout(dismiss, 5000);
div.insertBefore(btn, div.firstChild);
container.insertBefore(div, container.firstChild);
}
private fsyncTimer: number;
syncfs(timeout = 100) {
window.clearTimeout(this.fsyncTimer);