Place alert inside gniza container with absolute positioning

Append alert to the data-theme container instead of document.body
so it stays within the gniza content frame. Use position:absolute
relative to the container.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-04 03:18:34 +02:00
parent f85cbb49c9
commit 0d64f6ad65
2 changed files with 10 additions and 16 deletions

View File

@@ -714,18 +714,15 @@ function gnizaTestConnection() {
function gnizaToast(type, msg) { function gnizaToast(type, msg) {
var prev = document.getElementById('gniza-alert'); var prev = document.getElementById('gniza-alert');
if (prev) prev.remove(); if (prev) prev.remove();
var s = document.getElementById('gniza-alert-style'); var container = document.querySelector('[data-theme]');
if (!s) { if (!container) return;
s = document.createElement('style'); container.style.position = 'relative';
s.id = 'gniza-alert-style';
s.textContent = '#gniza-alert{position:fixed!important;top:24px!important;right:24px!important;z-index:9999!important;max-width:480px!important;padding:12px 20px!important;border-radius:8px!important;font-size:14px!important;box-shadow:0 4px 12px rgba(0,0,0,.15)!important;transition:opacity .3s!important;display:block!important;}';
document.head.appendChild(s);
}
var el = document.createElement('div'); var el = document.createElement('div');
el.id = 'gniza-alert'; el.id = 'gniza-alert';
el.className = 'alert alert-' + type; el.className = 'alert alert-' + type;
el.style.cssText = 'position:absolute;top:0;right:0;z-index:9999;max-width:480px;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;
document.body.appendChild(el); container.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);
} }

View File

@@ -316,18 +316,15 @@ function gnizaTestConnection() {
function gnizaToast(type, msg) { function gnizaToast(type, msg) {
var prev = document.getElementById('gniza-alert'); var prev = document.getElementById('gniza-alert');
if (prev) prev.remove(); if (prev) prev.remove();
var s = document.getElementById('gniza-alert-style'); var container = document.querySelector('[data-theme]');
if (!s) { if (!container) return;
s = document.createElement('style'); container.style.position = 'relative';
s.id = 'gniza-alert-style';
s.textContent = '#gniza-alert{position:fixed!important;top:24px!important;right:24px!important;z-index:9999!important;max-width:480px!important;padding:12px 20px!important;border-radius:8px!important;font-size:14px!important;box-shadow:0 4px 12px rgba(0,0,0,.15)!important;transition:opacity .3s!important;display:block!important;}';
document.head.appendChild(s);
}
var el = document.createElement('div'); var el = document.createElement('div');
el.id = 'gniza-alert'; el.id = 'gniza-alert';
el.className = 'alert alert-' + type; el.className = 'alert alert-' + type;
el.style.cssText = 'position:absolute;top:0;right:0;z-index:9999;max-width:480px;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;
document.body.appendChild(el); container.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);
} }