// Keeps at most one full-height side panel (base map, GPX, ...) open at a // time — they all dock to the same spot next to the sidebar, so two open // together would just stack on top of each other. const OPEN_EVENT = "side-panel-open"; export function notifySidePanelOpen(panel) { document.dispatchEvent(new CustomEvent(OPEN_EVENT, { detail: panel })); } export function onlyOneSidePanelOpen(panel, onClosedByOther) { document.addEventListener(OPEN_EVENT, (event) => { if (event.detail !== panel && !panel.hidden) { panel.hidden = true; onClosedByOther(); } }); } // Lets a control that writes into the GPX store (e.g. notes.js saving a // drawn point) tell GpxPanelControl its tree is stale, without either one // holding a reference to the other. const STORE_CHANGED_EVENT = "gpx-store-changed"; export function notifyGpxStoreChanged() { document.dispatchEvent(new CustomEvent(STORE_CHANGED_EVENT)); } export function onGpxStoreChanged(callback) { document.addEventListener(STORE_CHANGED_EVENT, callback); }