fix #21 support ImageBrowser with Pano buttons
parent
0b78612c2a
commit
414464c518
|
|
@ -7,7 +7,7 @@ let galImageDisp
|
|||
function panorama_here(phtml, mode, buttonId) {
|
||||
return async () => {
|
||||
try {
|
||||
const tabContext = get_uiCurrentTab().innerText
|
||||
let tabContext = get_uiCurrentTab().innerText
|
||||
let containerName
|
||||
switch (tabContext) {
|
||||
case "txt2img":
|
||||
|
|
@ -19,9 +19,32 @@ function panorama_here(phtml, mode, buttonId) {
|
|||
case "Extras":
|
||||
containerName = "#extras_gallery_container"
|
||||
break;
|
||||
default:
|
||||
case "Image Browser": {
|
||||
tabContext = "IB_" + gradioApp().querySelector("#image_browser_tabs_container button.bg-white").innerText
|
||||
switch (tabContext) {
|
||||
case "IB_txt2img": containerName = "#image_browser_tab_txt2img_image_browser_gallery"
|
||||
break;
|
||||
case "IB_img2img": containerName = "#image_browser_tab_img2img_image_browser_gallery"
|
||||
break;
|
||||
case "IB_txt2img-grids": containerName = "#image_browser_tab_txt2img-grids_image_browser_gallery"
|
||||
break;
|
||||
case "IB_img2img-grids": containerName = "#image_browser_tab_img2img-grids_image_browser_gallery"
|
||||
break;
|
||||
case "IB_Extras": containerName = "#image_browser_tab_extras_image_browser_gallery"
|
||||
break;
|
||||
case "IB_Favorites": containerName = "#image_browser_tab_favorites_image_browser_gallery"
|
||||
break;
|
||||
default: {
|
||||
console.warn("PanoramaViewer: Unsupported Image Browser gallery: " + tabContext)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
console.warn("PanoramaViewer: Unsupported gallery: " + tabContext)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
let galviewer = gradioApp().querySelector("#panogalviewer-iframe" + tabContext)
|
||||
|
|
@ -264,22 +287,22 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
}
|
||||
target.addEventListener("drop", onGalleryDrop)
|
||||
target.addEventListener("dragover", (event) => {
|
||||
event.preventDefault();
|
||||
event.preventDefault();
|
||||
});
|
||||
|
||||
// completely hide the transfer textbox and its container
|
||||
let alldrops = gradioApp().querySelectorAll("div[id^='gallery_input_ondrop']")
|
||||
alldrops.forEach((e) => {
|
||||
e.parentElement.style.display = "none"
|
||||
alldrops.forEach((e) => {
|
||||
e.parentElement.style.display = "none"
|
||||
})
|
||||
|
||||
/* no tab anymore, no functionality
|
||||
if (gradioApp().getElementById("panoviewer-iframe")) {
|
||||
openpanoramajs();
|
||||
} else {
|
||||
setTimeout(onload, 10);
|
||||
}
|
||||
*/
|
||||
/* no tab anymore, no functionality
|
||||
if (gradioApp().getElementById("panoviewer-iframe")) {
|
||||
openpanoramajs();
|
||||
} else {
|
||||
setTimeout(onload, 10);
|
||||
}
|
||||
*/
|
||||
}
|
||||
else {
|
||||
setTimeout(onload, 3);
|
||||
|
|
|
|||
|
|
@ -59,16 +59,20 @@ def after_component(component, **kwargs):
|
|||
#send2tab_button = gr.Button ("Pano \U0001F440", elem_id=f"sendto_panorama_button") # 👀
|
||||
#send2tab_button.click(None, [], None, _js="() => panorama_send_gallery('WebUI Resource')")
|
||||
#send2tab_button.__setattr__("class","gr-button")
|
||||
suffix = component.parent.elem_id
|
||||
if component.parent.elem_id :
|
||||
suffix = component.parent.elem_id
|
||||
else :
|
||||
suffix = "_dummy_suffix"
|
||||
|
||||
# if (suffix):
|
||||
view_gallery_button = gr.Button ("Pano \U0001F310", elem_id="sendto_panogallery_button_"+suffix) # 🌐
|
||||
view_cube_button = gr.Button ("Pano \U0001F9CA", elem_id="sendto_panogallery_cube_button_"+ suffix) # 🧊
|
||||
view_gallery_button.click (None, [],None, _js="panorama_here(\""+iframesrc+"\",\"\",\""+view_gallery_button.elem_id+"\")" )
|
||||
view_cube_button.click (None, [],None, _js="panorama_here(\""+iframesrc+"\",\"cubemap\",\""+view_cube_button.elem_id+"\")" )
|
||||
|
||||
gallery_input_ondrop = gr.Textbox(visible=False, elem_id="gallery_input_ondrop_"+ suffix)
|
||||
gallery_input_ondrop.style(container=False)
|
||||
|
||||
if (suffix):
|
||||
view_gallery_button = gr.Button ("Pano \U0001F310", elem_id="sendto_panogallery_button_"+suffix) # 🌐
|
||||
view_cube_button = gr.Button ("Pano \U0001F9CA", elem_id="sendto_panogallery_cube_button_"+ suffix) # 🧊
|
||||
view_gallery_button.click (None, [],None, _js="panorama_here(\""+iframesrc+"\",\"\",\""+view_gallery_button.elem_id+"\")" )
|
||||
view_cube_button.click (None, [],None, _js="panorama_here(\""+iframesrc+"\",\"cubemap\",\""+view_cube_button.elem_id+"\")" )
|
||||
|
||||
gallery_input_ondrop = gr.Textbox(visible=False, elem_id="gallery_input_ondrop_"+ suffix)
|
||||
gallery_input_ondrop.style(container=False)
|
||||
if (gallery_input_ondrop and txt2img_gallery_component):
|
||||
gallery_input_ondrop.change(fn=dropHandleGallery, inputs=[gallery_input_ondrop], outputs=[txt2img_gallery_component])
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue