aboutsummaryrefslogtreecommitdiffstats
path: root/javascript/ui.js
diff options
context:
space:
mode:
authorParityError <36368048+ParityError@users.noreply.github.com>2023-03-29 01:29:59 +0000
committerGitHub <noreply@github.com>2023-03-29 01:29:59 +0000
commitf69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285 (patch)
tree01852aeac922029273e08a90c683d63c6fc169cd /javascript/ui.js
parentfb68d93b6a579a424919b22682cf067ce9a8e13f (diff)
parent3856ada5cc9ac4124e20ff311ce7aa77330845d9 (diff)
downloadstable-diffusion-webui-gfx803-f69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285.tar.gz
stable-diffusion-webui-gfx803-f69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285.tar.bz2
stable-diffusion-webui-gfx803-f69acfe9a4c09a5c2299e0cc2d5bdcd7a6e62285.zip
Merge branch 'AUTOMATIC1111:master' into master
Diffstat (limited to 'javascript/ui.js')
-rw-r--r--javascript/ui.js39
1 files changed, 32 insertions, 7 deletions
diff --git a/javascript/ui.js b/javascript/ui.js
index b7a8268a..4a440193 100644
--- a/javascript/ui.js
+++ b/javascript/ui.js
@@ -7,9 +7,31 @@ function set_theme(theme){
}
}
+function all_gallery_buttons() {
+ var allGalleryButtons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery].gradio-gallery .thumbnails > .thumbnail-item.thumbnail-small');
+ var visibleGalleryButtons = [];
+ allGalleryButtons.forEach(function(elem) {
+ if (elem.parentElement.offsetParent) {
+ visibleGalleryButtons.push(elem);
+ }
+ })
+ return visibleGalleryButtons;
+}
+
+function selected_gallery_button() {
+ var allCurrentButtons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery].gradio-gallery .thumbnail-item.thumbnail-small.selected');
+ var visibleCurrentButton = null;
+ allCurrentButtons.forEach(function(elem) {
+ if (elem.parentElement.offsetParent) {
+ visibleCurrentButton = elem;
+ }
+ })
+ return visibleCurrentButton;
+}
+
function selected_gallery_index(){
- var buttons = gradioApp().querySelectorAll('[style="display: block;"].tabitem div[id$=_gallery] .gallery-item')
- var button = gradioApp().querySelector('[style="display: block;"].tabitem div[id$=_gallery] .gallery-item.\\!ring-2')
+ var buttons = all_gallery_buttons();
+ var button = selected_gallery_button();
var result = -1
buttons.forEach(function(v, i){ if(v==button) { result = i } })
@@ -18,14 +40,18 @@ function selected_gallery_index(){
}
function extract_image_from_gallery(gallery){
- if(gallery.length == 1){
- return [gallery[0]]
+ if (gallery.length == 0){
+ return [null];
+ }
+ if (gallery.length == 1){
+ return [gallery[0]];
}
index = selected_gallery_index()
if (index < 0 || index >= gallery.length){
- return [null]
+ // Use the first image in the gallery as the default
+ index = 0;
}
return [gallery[index]];
@@ -86,7 +112,7 @@ function get_tab_index(tabId){
var res = 0
gradioApp().getElementById(tabId).querySelector('div').querySelectorAll('button').forEach(function(button, i){
- if(button.className.indexOf('bg-white') != -1)
+ if(button.className.indexOf('selected') != -1)
res = i
})
@@ -255,7 +281,6 @@ onUiUpdate(function(){
}
prompt.parentElement.insertBefore(counter, prompt)
- counter.classList.add("token-counter")
prompt.parentElement.style.position = "relative"
promptTokecountUpdateFuncs[id] = function(){ update_token_counter(id_button); }