diff options
author | Aarni Koskela <akx@iki.fi> | 2023-05-17 12:46:58 +0000 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2023-05-17 13:09:06 +0000 |
commit | 9c54b78d9dde5601e916f308d9a9d6953ec39430 (patch) | |
tree | 7eff4b1d65193de1ddc5503d46bba6508a1e903e /javascript/generationParams.js | |
parent | 4f11f285f912fd48bc85a650a0384b6044d68b86 (diff) | |
download | stable-diffusion-webui-gfx803-9c54b78d9dde5601e916f308d9a9d6953ec39430.tar.gz stable-diffusion-webui-gfx803-9c54b78d9dde5601e916f308d9a9d6953ec39430.tar.bz2 stable-diffusion-webui-gfx803-9c54b78d9dde5601e916f308d9a9d6953ec39430.zip |
Run `eslint --fix` (and normalize tabs to spaces)
Diffstat (limited to 'javascript/generationParams.js')
-rw-r--r-- | javascript/generationParams.js | 48 |
1 files changed, 25 insertions, 23 deletions
diff --git a/javascript/generationParams.js b/javascript/generationParams.js index ef64ee2e..f9e84e70 100644 --- a/javascript/generationParams.js +++ b/javascript/generationParams.js @@ -1,33 +1,35 @@ // 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'] }); - } +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.selected')?.innerText - if (mutationRecord.target.style.display === 'none' && (selectedTab === 'txt2img' || selectedTab === 'img2img')) - gradioApp().getElementById(selectedTab+"_generation_info_button")?.click() - }); + mutations.forEach(function(mutationRecord) { + let selectedTab = gradioApp().querySelector('#tabs div button.selected')?.innerText; + if (mutationRecord.target.style.display === 'none' && (selectedTab === 'txt2img' || selectedTab === 'img2img')) { + gradioApp().getElementById(selectedTab + "_generation_info_button")?.click(); + } + }); }); function attachGalleryListeners(tab_name) { - var 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; + var 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; } |