diff --git a/server/src/wled_controller/static/app.js b/server/src/wled_controller/static/app.js index 47253da..94922ed 100644 --- a/server/src/wled_controller/static/app.js +++ b/server/src/wled_controller/static/app.js @@ -56,11 +56,125 @@ function closeLightbox(event) { } document.addEventListener('keydown', (e) => { - if (e.key === 'Escape' && document.getElementById('image-lightbox').classList.contains('active')) { - closeLightbox(); + if (e.key === 'Escape') { + if (document.getElementById('display-picker-lightbox').classList.contains('active')) { + closeDisplayPicker(); + } else if (document.getElementById('image-lightbox').classList.contains('active')) { + closeLightbox(); + } } }); +// Display picker lightbox +let _displayPickerCallback = null; + +function openDisplayPicker(callback) { + _displayPickerCallback = callback; + const lightbox = document.getElementById('display-picker-lightbox'); + const canvas = document.getElementById('display-picker-canvas'); + + lightbox.classList.add('active'); + + // Defer render to next frame so the lightbox has been laid out and canvas has dimensions + requestAnimationFrame(() => { + if (_cachedDisplays && _cachedDisplays.length > 0) { + renderDisplayPickerLayout(_cachedDisplays); + } else { + canvas.innerHTML = '
'; + loadDisplays().then(() => { + if (_cachedDisplays && _cachedDisplays.length > 0) { + renderDisplayPickerLayout(_cachedDisplays); + } else { + canvas.innerHTML = `@@ -451,10 +443,11 @@