mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-17 10:15:27 -04:00
97a7f59fe7
* fix(notes): bring pane above active windows * fix(notes): align tool window z-order handoff --------- Co-authored-by: Matyas Fenyves <16389204+uhhgoat@users.noreply.github.com>
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
export const TOOL_WINDOW_SELECTOR = 'body > .modal, body > .research-overlay, body > .notes-pane-backdrop';
|
|
|
|
export function topToolWindowZ(options = {}) {
|
|
const {
|
|
exclude = null,
|
|
root = globalThis.document,
|
|
getStyle = globalThis.getComputedStyle,
|
|
floor = 250,
|
|
} = options;
|
|
let top = floor;
|
|
if (!root || typeof root.querySelectorAll !== 'function' || typeof getStyle !== 'function') return top;
|
|
root.querySelectorAll(TOOL_WINDOW_SELECTOR).forEach(el => {
|
|
if (!el || el === exclude) return;
|
|
if (el.classList?.contains('hidden') || el.classList?.contains('modal-minimized')) return;
|
|
const cs = getStyle(el);
|
|
if (cs.display === 'none' || cs.visibility === 'hidden') return;
|
|
const z = parseInt(cs.zIndex, 10);
|
|
if (Number.isFinite(z)) top = Math.max(top, z);
|
|
});
|
|
return top;
|
|
}
|
|
|
|
export function nextToolWindowZ(options = {}) {
|
|
const { current = null } = options;
|
|
const top = topToolWindowZ(options);
|
|
const currentZ = parseInt(current, 10);
|
|
if (Number.isFinite(currentZ) && currentZ > top) return currentZ;
|
|
return top + 1;
|
|
}
|