mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2025-08-05 03:32:37 +00:00
inspiration pull request
This commit is contained in:
@@ -116,7 +116,6 @@ function showGalleryImage() {
|
||||
e.dataset.modded = true;
|
||||
if(e && e.parentElement.tagName == 'DIV'){
|
||||
e.style.cursor='pointer'
|
||||
e.style.userSelect='none'
|
||||
e.addEventListener('click', function (evt) {
|
||||
if(!opts.js_modal_lightbox) return;
|
||||
modalZoomSet(gradioApp().getElementById('modalImage'), opts.js_modal_lightbox_initially_zoomed)
|
||||
|
42
javascript/inspiration.js
Normal file
42
javascript/inspiration.js
Normal file
@@ -0,0 +1,42 @@
|
||||
function public_image_index_in_gallery(item, gallery){
|
||||
var index;
|
||||
var i = 0;
|
||||
gallery.querySelectorAll("img").forEach(function(e){
|
||||
if (e == item)
|
||||
index = i;
|
||||
i += 1;
|
||||
});
|
||||
return index;
|
||||
}
|
||||
|
||||
function inspiration_selected(name, types, name_list){
|
||||
var btn = gradioApp().getElementById("inspiration_select_button")
|
||||
return [gradioApp().getElementById("inspiration_select_button").getAttribute("img-index"), types];
|
||||
}
|
||||
var inspiration_image_click = function(){
|
||||
var index = public_image_index_in_gallery(this, gradioApp().getElementById("inspiration_gallery"));
|
||||
var btn = gradioApp().getElementById("inspiration_select_button")
|
||||
btn.setAttribute("img-index", index)
|
||||
setTimeout(function(btn){btn.click();}, 10, btn)
|
||||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
var mutationObserver = new MutationObserver(function(m){
|
||||
var gallery = gradioApp().getElementById("inspiration_gallery")
|
||||
if (gallery) {
|
||||
var node = gallery.querySelector(".absolute.backdrop-blur.h-full")
|
||||
if (node) {
|
||||
node.style.display = "None"; //parentNode.removeChild(node)
|
||||
}
|
||||
|
||||
gallery.querySelectorAll('img').forEach(function(e){
|
||||
e.onclick = inspiration_image_click
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
mutationObserver.observe( gradioApp(), { childList:true, subtree:true });
|
||||
|
||||
});
|
Reference in New Issue
Block a user