diff options
author | Muhammad Rizqi Nur <rizqinur2010@gmail.com> | 2022-10-29 08:04:21 +0000 |
---|---|---|
committer | Muhammad Rizqi Nur <rizqinur2010@gmail.com> | 2022-10-29 08:04:21 +0000 |
commit | 05e2e40537a948d7563d873ffbc394c41a0cd0b1 (patch) | |
tree | 5f46c59cab2d36989eed21411dce5271ec540776 /javascript/imageviewer.js | |
parent | 16451ca573220e49f2eaaab97580b6b91287c8c4 (diff) | |
parent | 35c45df28b303a05d56a13cb56d4046f08cf8c25 (diff) | |
download | stable-diffusion-webui-gfx803-05e2e40537a948d7563d873ffbc394c41a0cd0b1.tar.gz stable-diffusion-webui-gfx803-05e2e40537a948d7563d873ffbc394c41a0cd0b1.tar.bz2 stable-diffusion-webui-gfx803-05e2e40537a948d7563d873ffbc394c41a0cd0b1.zip |
Merge branch 'master' into gradient-clipping
Diffstat (limited to 'javascript/imageviewer.js')
-rw-r--r-- | javascript/imageviewer.js | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/javascript/imageviewer.js b/javascript/imageviewer.js index 9e380c65..67916536 100644 --- a/javascript/imageviewer.js +++ b/javascript/imageviewer.js @@ -13,6 +13,15 @@ function showModal(event) { } lb.style.display = "block"; lb.focus() + + const tabTxt2Img = gradioApp().getElementById("tab_txt2img") + const tabImg2Img = gradioApp().getElementById("tab_img2img") + // show the save button in modal only on txt2img or img2img tabs + if (tabTxt2Img.style.display != "none" || tabImg2Img.style.display != "none") { + gradioApp().getElementById("modal_save").style.display = "inline" + } else { + gradioApp().getElementById("modal_save").style.display = "none" + } event.stopPropagation() } @@ -81,6 +90,25 @@ function modalImageSwitch(offset) { } } +function saveImage(){ + const tabTxt2Img = gradioApp().getElementById("tab_txt2img") + const tabImg2Img = gradioApp().getElementById("tab_img2img") + const saveTxt2Img = "save_txt2img" + const saveImg2Img = "save_img2img" + if (tabTxt2Img.style.display != "none") { + gradioApp().getElementById(saveTxt2Img).click() + } else if (tabImg2Img.style.display != "none") { + gradioApp().getElementById(saveImg2Img).click() + } else { + console.error("missing implementation for saving modal of this type") + } +} + +function modalSaveImage(event) { + saveImage() + event.stopPropagation() +} + function modalNextImage(event) { modalImageSwitch(1) event.stopPropagation() @@ -93,6 +121,9 @@ function modalPrevImage(event) { function modalKeyHandler(event) { switch (event.key) { + case "s": + saveImage() + break; case "ArrowLeft": modalPrevImage(event) break; @@ -198,6 +229,14 @@ document.addEventListener("DOMContentLoaded", function() { modalTileImage.title = "Preview tiling"; modalControls.appendChild(modalTileImage) + const modalSave = document.createElement("span") + modalSave.className = "modalSave cursor" + modalSave.id = "modal_save" + modalSave.innerHTML = "🖫" + modalSave.addEventListener("click", modalSaveImage, true) + modalSave.title = "Save Image(s)" + modalControls.appendChild(modalSave) + const modalClose = document.createElement('span') modalClose.className = 'modalClose cursor'; modalClose.innerHTML = '×' |