@@ -6,6 +6,8 @@ function closeModal() {
6
6
function showModal ( event ) {
7
7
const source = event . target || event . srcElement ;
8
8
const modalImage = gradioApp ( ) . getElementById ( "modalImage" ) ;
9
+ const modalToggleLivePreviewBtn = gradioApp ( ) . getElementById ( "modal_toggle_live_preview" ) ;
10
+ modalToggleLivePreviewBtn . innerHTML = opts . js_live_preview_in_modal_lightbox ? "🗇" : "🗆" ;
9
11
const lb = gradioApp ( ) . getElementById ( "lightboxModal" ) ;
10
12
modalImage . src = source . src ;
11
13
if ( modalImage . style . display === 'none' ) {
@@ -152,6 +154,13 @@ function modalZoomToggle(event) {
152
154
event . stopPropagation ( ) ;
153
155
}
154
156
157
+ function modalLivePreviewToggle ( event ) {
158
+ const modalToggleLivePreview = gradioApp ( ) . getElementById ( "modal_toggle_live_preview" ) ;
159
+ opts . js_live_preview_in_modal_lightbox = ! opts . js_live_preview_in_modal_lightbox ;
160
+ modalToggleLivePreview . innerHTML = opts . js_live_preview_in_modal_lightbox ? "🗇" : "🗆" ;
161
+ event . stopPropagation ( ) ;
162
+ }
163
+
155
164
function modalTileImageToggle ( event ) {
156
165
const modalImage = gradioApp ( ) . getElementById ( "modalImage" ) ;
157
166
const modal = gradioApp ( ) . getElementById ( "lightboxModal" ) ;
@@ -209,6 +218,14 @@ document.addEventListener("DOMContentLoaded", function() {
209
218
modalSave . title = "Save Image(s)" ;
210
219
modalControls . appendChild ( modalSave ) ;
211
220
221
+ const modalToggleLivePreview = document . createElement ( 'span' ) ;
222
+ modalToggleLivePreview . className = 'modalToggleLivePreview cursor' ;
223
+ modalToggleLivePreview . id = "modal_toggle_live_preview" ;
224
+ modalToggleLivePreview . innerHTML = "🗆" ;
225
+ modalToggleLivePreview . onclick = modalLivePreviewToggle ;
226
+ modalToggleLivePreview . title = "Toggle live preview" ;
227
+ modalControls . appendChild ( modalToggleLivePreview ) ;
228
+
212
229
const modalClose = document . createElement ( 'span' ) ;
213
230
modalClose . className = 'modalClose cursor' ;
214
231
modalClose . innerHTML = '×' ;
0 commit comments