Skip to content

Commit 403c5db

Browse files
committed
hide save btn for other tabs than txt2img and img2img
1 parent bf25b51 commit 403c5db

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

javascript/imageviewer.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ function showModal(event) {
1313
}
1414
lb.style.display = "block";
1515
lb.focus()
16+
17+
const tabTxt2Img = gradioApp().getElementById("tab_txt2img")
18+
const tabImg2Img = gradioApp().getElementById("tab_img2img")
19+
// show the save button in modal only on txt2img or img2img tabs
20+
if (tabTxt2Img.style.display != "none" || tabImg2Img.style.display != "none") {
21+
gradioApp().getElementById("modal_save").style.display = "inline"
22+
} else {
23+
gradioApp().getElementById("modal_save").style.display = "none"
24+
}
1625
event.stopPropagation()
1726
}
1827

@@ -86,9 +95,9 @@ function saveImage(){
8695
const tabImg2Img = gradioApp().getElementById("tab_img2img")
8796
const saveTxt2Img = "save_txt2img"
8897
const saveImg2Img = "save_img2img"
89-
if (tabTxt2Img.style["display"] != "none") {
98+
if (tabTxt2Img.style.display != "none") {
9099
gradioApp().getElementById(saveTxt2Img).click()
91-
} else if (tabImg2Img.style["display"] != "none") {
100+
} else if (tabImg2Img.style.display != "none") {
92101
gradioApp().getElementById(saveImg2Img).click()
93102
} else {
94103
console.error("missing implementation for saving modal of this type")
@@ -222,6 +231,7 @@ document.addEventListener("DOMContentLoaded", function() {
222231

223232
const modalSave = document.createElement("span")
224233
modalSave.className = "modalSave cursor"
234+
modalSave.id = "modal_save"
225235
modalSave.innerHTML = "🖫"
226236
modalSave.addEventListener("click", modalSaveImage, true)
227237
modalSave.title = "Save Image(s)"

0 commit comments

Comments
 (0)