LinkUp initial import

This commit is contained in:
2026-10-29 16:27:16 +08:00
commit 155058f0f3
50 changed files with 10624 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
(() => {
let dismissTimer = 0;
let liftFrame = 0;
function liftAboveDialogs(element) {
if (!element?.showPopover) return;
try {
if (element.matches(':popover-open')) element.hidePopover();
element.showPopover();
} catch {
// Older browsers fall back to the fixed-position z-index styling.
}
}
function show(message) {
const element = document.getElementById('toast');
if (!element) return;
const label = element.querySelector('span');
if (label) label.textContent = String(message ?? '');
window.clearTimeout(dismissTimer);
window.cancelAnimationFrame(liftFrame);
liftAboveDialogs(element);
element.classList.add('show');
// Some flows open a dialog immediately after calling toast(). Reinsert the
// popover on the next frame so it is the top-most item in the top layer.
liftFrame = window.requestAnimationFrame(() => liftAboveDialogs(element));
dismissTimer = window.setTimeout(() => {
element.classList.remove('show');
window.setTimeout(() => {
try {
if (element.matches(':popover-open')) element.hidePopover();
} catch {}
}, 180);
}, 2600);
}
window.LinkUpToast = Object.freeze({ show });
})();