Fix toast: single instance, bottom-right, proper styling
Remove previous toast before showing new one to prevent stacking. Position bottom-right with padding, rounded corners, and proper font size for a clean toast appearance. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -712,18 +712,14 @@ function gnizaTestConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gnizaToast(type, msg) {
|
function gnizaToast(type, msg) {
|
||||||
var toast = document.getElementById('gniza-toast');
|
var prev = document.getElementById('gniza-toast');
|
||||||
if (!toast) {
|
if (prev) prev.remove();
|
||||||
toast = document.createElement('div');
|
|
||||||
toast.id = 'gniza-toast';
|
|
||||||
toast.style.cssText = 'position:fixed;top:12px;right:12px;z-index:9999;display:flex;flex-direction:column;gap:8px;max-width:400px';
|
|
||||||
document.body.appendChild(toast);
|
|
||||||
}
|
|
||||||
var el = document.createElement('div');
|
var el = document.createElement('div');
|
||||||
|
el.id = 'gniza-toast';
|
||||||
el.className = 'alert alert-' + type;
|
el.className = 'alert alert-' + type;
|
||||||
el.style.cssText = 'transition:opacity .3s;box-shadow:0 4px 12px rgba(0,0,0,.15)';
|
el.style.cssText = 'position:fixed;bottom:24px;right:24px;z-index:9999;max-width:400px;padding:12px 20px;border-radius:8px;font-size:14px;box-shadow:0 4px 12px rgba(0,0,0,.15);transition:opacity .3s';
|
||||||
el.textContent = msg;
|
el.textContent = msg;
|
||||||
toast.appendChild(el);
|
document.body.appendChild(el);
|
||||||
setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000);
|
setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000);
|
||||||
setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500);
|
setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -314,18 +314,14 @@ function gnizaTestConnection() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function gnizaToast(type, msg) {
|
function gnizaToast(type, msg) {
|
||||||
var toast = document.getElementById('gniza-toast');
|
var prev = document.getElementById('gniza-toast');
|
||||||
if (!toast) {
|
if (prev) prev.remove();
|
||||||
toast = document.createElement('div');
|
|
||||||
toast.id = 'gniza-toast';
|
|
||||||
toast.style.cssText = 'position:fixed;top:12px;right:12px;z-index:9999;display:flex;flex-direction:column;gap:8px;max-width:400px';
|
|
||||||
document.body.appendChild(toast);
|
|
||||||
}
|
|
||||||
var el = document.createElement('div');
|
var el = document.createElement('div');
|
||||||
|
el.id = 'gniza-toast';
|
||||||
el.className = 'alert alert-' + type;
|
el.className = 'alert alert-' + type;
|
||||||
el.style.cssText = 'transition:opacity .3s;box-shadow:0 4px 12px rgba(0,0,0,.15)';
|
el.style.cssText = 'position:fixed;bottom:24px;right:24px;z-index:9999;max-width:400px;padding:12px 20px;border-radius:8px;font-size:14px;box-shadow:0 4px 12px rgba(0,0,0,.15);transition:opacity .3s';
|
||||||
el.textContent = msg;
|
el.textContent = msg;
|
||||||
toast.appendChild(el);
|
document.body.appendChild(el);
|
||||||
setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000);
|
setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000);
|
||||||
setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500);
|
setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user