Upload 59 files
Browse files- static/js/app.js +13 -64
static/js/app.js
CHANGED
|
@@ -25,88 +25,37 @@
|
|
| 25 |
})();
|
| 26 |
|
| 27 |
// =============================================================================
|
| 28 |
-
// Toast Notification System
|
| 29 |
// =============================================================================
|
|
|
|
| 30 |
const ToastManager = {
|
| 31 |
-
|
| 32 |
-
|
|
|
|
| 33 |
init() {
|
| 34 |
-
this.
|
| 35 |
-
if (!this.container) {
|
| 36 |
-
this.container = document.createElement('div');
|
| 37 |
-
this.container.id = 'toast-container';
|
| 38 |
-
this.container.className = 'toast-container';
|
| 39 |
-
document.body.appendChild(this.container);
|
| 40 |
-
}
|
| 41 |
},
|
| 42 |
-
|
| 43 |
show(message, type = 'info', duration = 5000) {
|
| 44 |
-
if (
|
| 45 |
-
|
| 46 |
-
const toast = document.createElement('div');
|
| 47 |
-
toast.className = `toast ${type}`;
|
| 48 |
-
|
| 49 |
-
const icons = {
|
| 50 |
-
success: 'fa-check-circle',
|
| 51 |
-
error: 'fa-times-circle',
|
| 52 |
-
warning: 'fa-exclamation-triangle',
|
| 53 |
-
info: 'fa-info-circle'
|
| 54 |
-
};
|
| 55 |
-
|
| 56 |
-
const titles = {
|
| 57 |
-
success: 'Success',
|
| 58 |
-
error: 'Error',
|
| 59 |
-
warning: 'Warning',
|
| 60 |
-
info: 'Info'
|
| 61 |
-
};
|
| 62 |
-
|
| 63 |
-
toast.innerHTML = `
|
| 64 |
-
<div class="toast-icon">
|
| 65 |
-
<i class="fas ${icons[type] || icons.info}"></i>
|
| 66 |
-
</div>
|
| 67 |
-
<div class="toast-content">
|
| 68 |
-
<div class="toast-title">${titles[type] || titles.info}</div>
|
| 69 |
-
<div class="toast-message">${message}</div>
|
| 70 |
-
</div>
|
| 71 |
-
<button class="toast-close" onclick="ToastManager.remove(this.parentElement)">
|
| 72 |
-
<i class="fas fa-times"></i>
|
| 73 |
-
</button>
|
| 74 |
-
<div class="toast-progress"></div>
|
| 75 |
-
`;
|
| 76 |
-
|
| 77 |
-
this.container.appendChild(toast);
|
| 78 |
-
|
| 79 |
-
// Auto remove after duration
|
| 80 |
-
if (duration > 0) {
|
| 81 |
-
setTimeout(() => this.remove(toast), duration);
|
| 82 |
-
}
|
| 83 |
-
|
| 84 |
-
return toast;
|
| 85 |
},
|
| 86 |
-
|
| 87 |
remove(toast) {
|
| 88 |
-
if (
|
| 89 |
-
toast.classList.add('removing');
|
| 90 |
-
setTimeout(() => {
|
| 91 |
-
if (toast.parentElement) {
|
| 92 |
-
toast.parentElement.removeChild(toast);
|
| 93 |
-
}
|
| 94 |
-
}, 300);
|
| 95 |
},
|
| 96 |
-
|
| 97 |
success(message, duration) {
|
|
|
|
| 98 |
return this.show(message, 'success', duration);
|
| 99 |
},
|
| 100 |
-
|
| 101 |
error(message, duration) {
|
|
|
|
| 102 |
return this.show(message, 'error', duration);
|
| 103 |
},
|
| 104 |
-
|
| 105 |
warning(message, duration) {
|
|
|
|
| 106 |
return this.show(message, 'warning', duration);
|
| 107 |
},
|
| 108 |
-
|
| 109 |
info(message, duration) {
|
|
|
|
| 110 |
return this.show(message, 'info', duration);
|
| 111 |
}
|
| 112 |
};
|
|
|
|
| 25 |
})();
|
| 26 |
|
| 27 |
// =============================================================================
|
| 28 |
+
// Toast Notification System (use the one from toast.js)
|
| 29 |
// =============================================================================
|
| 30 |
+
// Create a proxy that will use window.toastManager when it's available
|
| 31 |
const ToastManager = {
|
| 32 |
+
get _manager() {
|
| 33 |
+
return window.toastManager || window.toast;
|
| 34 |
+
},
|
| 35 |
init() {
|
| 36 |
+
if (this._manager && this._manager.init) this._manager.init();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
},
|
|
|
|
| 38 |
show(message, type = 'info', duration = 5000) {
|
| 39 |
+
if (this._manager) return this._manager.show(message, type, duration);
|
| 40 |
+
console.log(`Toast: ${type} - ${message}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
},
|
|
|
|
| 42 |
remove(toast) {
|
| 43 |
+
if (toast && toast.remove) toast.remove();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 44 |
},
|
|
|
|
| 45 |
success(message, duration) {
|
| 46 |
+
if (this._manager && this._manager.success) return this._manager.success(message, duration);
|
| 47 |
return this.show(message, 'success', duration);
|
| 48 |
},
|
|
|
|
| 49 |
error(message, duration) {
|
| 50 |
+
if (this._manager && this._manager.error) return this._manager.error(message, duration);
|
| 51 |
return this.show(message, 'error', duration);
|
| 52 |
},
|
|
|
|
| 53 |
warning(message, duration) {
|
| 54 |
+
if (this._manager && this._manager.warning) return this._manager.warning(message, duration);
|
| 55 |
return this.show(message, 'warning', duration);
|
| 56 |
},
|
|
|
|
| 57 |
info(message, duration) {
|
| 58 |
+
if (this._manager && this._manager.info) return this._manager.info(message, duration);
|
| 59 |
return this.show(message, 'info', duration);
|
| 60 |
}
|
| 61 |
};
|