(toolKey)
| 986 | } |
| 987 | |
| 988 | function openEmbeddedTool(toolKey) { |
| 989 | if (!toolOverlay) return; |
| 990 | const tool = EMBEDDED_TOOLS[toolKey]; |
| 991 | if (!tool) return; |
| 992 | const embeddedUrl = buildEmbeddedToolUrl(tool.href); |
| 993 | const frame = getToolFrameEl(toolKey); |
| 994 | if (!frame) return; |
| 995 | |
| 996 | // Update header UI |
| 997 | if (toolOverlayPill) toolOverlayPill.textContent = "Tools"; |
| 998 | if (toolOverlayOpenNewTab) toolOverlayOpenNewTab.href = embeddedUrl; |
| 999 | frame.title = tool.label; |
| 1000 | |
| 1001 | // Keep tool state by loading each tool once and then only toggling visibility |
| 1002 | if (!loadedToolFrames.has(toolKey)) { |
| 1003 | frame.setAttribute("src", embeddedUrl); |
| 1004 | loadedToolFrames.add(toolKey); |
| 1005 | } |
| 1006 | |
| 1007 | toolOverlay.classList.add("open"); |
| 1008 | toolOverlay.setAttribute("aria-hidden", "false"); |
| 1009 | document.documentElement.classList.add("tool-open"); |
| 1010 | setToolOverlayAction(toolKey); |
| 1011 | setActiveToolSwitchUI(toolKey); |
| 1012 | |
| 1013 | hideAllToolFrames(); |
| 1014 | frame.classList.remove("hidden"); |
| 1015 | |
| 1016 | // Ensure theme is synced even if the tool doesn't read query params |
| 1017 | syncEmbeddedToolTheme(getCurrentDisplayKitTheme()); |
| 1018 | } |
| 1019 | |
| 1020 | function closeEmbeddedTool() { |
| 1021 | if (!toolOverlay) return; |
no test coverage detected