diff options
author | Keavon Chambers <keavon@keavon.com> | 2022-11-19 18:34:31 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-19 18:34:31 +0000 |
commit | 2f90496b19cd9c512633742db97b072a7075f017 (patch) | |
tree | 60d2dddd69172d9b5cf58c8da2bd64c61132f4fa /javascript | |
parent | a258fd60dbe2d68325339405a2aa72816d06d2fd (diff) | |
parent | 47a44c7e421b98ca07e92dbf88769b04c9e28f86 (diff) | |
download | stable-diffusion-webui-gfx803-2f90496b19cd9c512633742db97b072a7075f017.tar.gz stable-diffusion-webui-gfx803-2f90496b19cd9c512633742db97b072a7075f017.tar.bz2 stable-diffusion-webui-gfx803-2f90496b19cd9c512633742db97b072a7075f017.zip |
Merge branch 'master' into cors-regex
Diffstat (limited to 'javascript')
-rw-r--r-- | javascript/generationParams.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/javascript/generationParams.js b/javascript/generationParams.js new file mode 100644 index 00000000..95f05093 --- /dev/null +++ b/javascript/generationParams.js @@ -0,0 +1,33 @@ +// attaches listeners to the txt2img and img2img galleries to update displayed generation param text when the image changes + +let txt2img_gallery, img2img_gallery, modal = undefined; +onUiUpdate(function(){ + if (!txt2img_gallery) { + txt2img_gallery = attachGalleryListeners("txt2img") + } + if (!img2img_gallery) { + img2img_gallery = attachGalleryListeners("img2img") + } + if (!modal) { + modal = gradioApp().getElementById('lightboxModal') + modalObserver.observe(modal, { attributes : true, attributeFilter : ['style'] }); + } +}); + +let modalObserver = new MutationObserver(function(mutations) { + mutations.forEach(function(mutationRecord) { + let selectedTab = gradioApp().querySelector('#tabs div button.bg-white')?.innerText + if (mutationRecord.target.style.display === 'none' && selectedTab === 'txt2img' || selectedTab === 'img2img') + gradioApp().getElementById(selectedTab+"_generation_info_button").click() + }); +}); + +function attachGalleryListeners(tab_name) { + gallery = gradioApp().querySelector('#'+tab_name+'_gallery') + gallery?.addEventListener('click', () => gradioApp().getElementById(tab_name+"_generation_info_button").click()); + gallery?.addEventListener('keydown', (e) => { + if (e.keyCode == 37 || e.keyCode == 39) // left or right arrow + gradioApp().getElementById(tab_name+"_generation_info_button").click() + }); + return gallery; +} |