From 0d64f6ad65f818f97d0ec4a9e6d23dc548960637 Mon Sep 17 00:00:00 2001 From: shuki Date: Wed, 4 Mar 2026 03:18:34 +0200 Subject: [PATCH] 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 --- whm/gniza-whm/remotes.cgi | 13 +++++-------- whm/gniza-whm/setup.cgi | 13 +++++-------- 2 files changed, 10 insertions(+), 16 deletions(-) diff --git a/whm/gniza-whm/remotes.cgi b/whm/gniza-whm/remotes.cgi index fed0b28..ca7145c 100644 --- a/whm/gniza-whm/remotes.cgi +++ b/whm/gniza-whm/remotes.cgi @@ -714,18 +714,15 @@ function gnizaTestConnection() { function gnizaToast(type, msg) { var prev = document.getElementById('gniza-alert'); if (prev) prev.remove(); - var s = document.getElementById('gniza-alert-style'); - if (!s) { - s = document.createElement('style'); - 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 container = document.querySelector('[data-theme]'); + if (!container) return; + container.style.position = 'relative'; var el = document.createElement('div'); el.id = 'gniza-alert'; 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; - document.body.appendChild(el); + container.appendChild(el); setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000); setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500); } diff --git a/whm/gniza-whm/setup.cgi b/whm/gniza-whm/setup.cgi index 5e12df7..33e3aa0 100644 --- a/whm/gniza-whm/setup.cgi +++ b/whm/gniza-whm/setup.cgi @@ -316,18 +316,15 @@ function gnizaTestConnection() { function gnizaToast(type, msg) { var prev = document.getElementById('gniza-alert'); if (prev) prev.remove(); - var s = document.getElementById('gniza-alert-style'); - if (!s) { - s = document.createElement('style'); - 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 container = document.querySelector('[data-theme]'); + if (!container) return; + container.style.position = 'relative'; var el = document.createElement('div'); el.id = 'gniza-alert'; 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; - document.body.appendChild(el); + container.appendChild(el); setTimeout(function() { el.style.opacity = '0'; }, type === 'error' ? 6000 : 3000); setTimeout(function() { el.remove(); }, type === 'error' ? 6500 : 3500); }