From 931e5aebb301714e8c0263555c99d7b7d9892fd0 Mon Sep 17 00:00:00 2001 From: DepFA <35278260+dfaker@users.noreply.github.com> Date: Mon, 19 Sep 2022 13:18:07 +0100 Subject: [PATCH] initialize modal state from options --- javascript/imageviewer.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/javascript/imageviewer.js b/javascript/imageviewer.js index c04cde347..564f8eb0c 100644 --- a/javascript/imageviewer.js +++ b/javascript/imageviewer.js @@ -82,7 +82,6 @@ function showGalleryImage(){ function modalZoomToggle(event){ modalImage = gradioApp().getElementById("modalImage"); - console.log(modalImage) if( !modalImage.classList.contains('modalImageFullscreen') ){ modalImage.classList.add('modalImageFullscreen'); }else{ @@ -102,6 +101,25 @@ onUiUpdate(function(){ if(fullImg_preview != null){ fullImg_preview.forEach(galleryImageHandler); } + + if(Object.keys(opts).length != 0) return; + + json_elem = gradioApp().getElementById('settings_json') + if(json_elem == null) return; + + textarea = json_elem.querySelector('textarea') + jsdata = textarea.value + opts = JSON.parse(jsdata) + + if(!window.lightbox_settings_applied){ + window.lightbox_settings_applied = true; + if(opts.js_modal_lightbox_initialy_zoomed){ + var imageModal = gradioApp().getElementById('modalImage'); + if(imageModal){ + imageModal.className = 'modalImageFullscreen'; + } + } + } }) document.addEventListener("DOMContentLoaded", function() {