Skip to content

Commit

Permalink
Merge pull request #16065 from AUTOMATIC1111/ToggleLivePriview-in-ima…
Browse files Browse the repository at this point in the history
…ge-viewer

ToggleLivePriview button in image viewer
  • Loading branch information
AUTOMATIC1111 committed Jul 6, 2024
2 parents 4cc3add + 775fa76 commit 68df281
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions javascript/imageviewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function closeModal() {
function showModal(event) {
const source = event.target || event.srcElement;
const modalImage = gradioApp().getElementById("modalImage");
const modalToggleLivePreviewBtn = gradioApp().getElementById("modal_toggle_live_preview");
modalToggleLivePreviewBtn.innerHTML = opts.js_live_preview_in_modal_lightbox ? "🗇" : "🗆";
const lb = gradioApp().getElementById("lightboxModal");
modalImage.src = source.src;
if (modalImage.style.display === 'none') {
Expand Down Expand Up @@ -152,6 +154,13 @@ function modalZoomToggle(event) {
event.stopPropagation();
}

function modalLivePreviewToggle(event) {
const modalToggleLivePreview = gradioApp().getElementById("modal_toggle_live_preview");
opts.js_live_preview_in_modal_lightbox = !opts.js_live_preview_in_modal_lightbox;
modalToggleLivePreview.innerHTML = opts.js_live_preview_in_modal_lightbox ? "🗇" : "🗆";
event.stopPropagation();
}

function modalTileImageToggle(event) {
const modalImage = gradioApp().getElementById("modalImage");
const modal = gradioApp().getElementById("lightboxModal");
Expand Down Expand Up @@ -209,6 +218,14 @@ document.addEventListener("DOMContentLoaded", function() {
modalSave.title = "Save Image(s)";
modalControls.appendChild(modalSave);

const modalToggleLivePreview = document.createElement('span');
modalToggleLivePreview.className = 'modalToggleLivePreview cursor';
modalToggleLivePreview.id = "modal_toggle_live_preview";
modalToggleLivePreview.innerHTML = "🗆";
modalToggleLivePreview.onclick = modalLivePreviewToggle;
modalToggleLivePreview.title = "Toggle live preview";
modalControls.appendChild(modalToggleLivePreview);

const modalClose = document.createElement('span');
modalClose.className = 'modalClose cursor';
modalClose.innerHTML = '×';
Expand Down

0 comments on commit 68df281

Please sign in to comment.