diff options
author | AUTOMATIC <16777216c@gmail.com> | 2022-09-18 05:41:08 +0000 |
---|---|---|
committer | AUTOMATIC <16777216c@gmail.com> | 2022-09-18 05:41:08 +0000 |
commit | 74c538e84f57bd7b5f54a1571fdb9a64621172b0 (patch) | |
tree | a959dc76f83140e222b6b5588bb921dd145dade0 /script.js | |
parent | 27b9b233f27b6ed3737b793edc8245830ca0b592 (diff) | |
download | stable-diffusion-webui-gfx803-74c538e84f57bd7b5f54a1571fdb9a64621172b0.tar.gz stable-diffusion-webui-gfx803-74c538e84f57bd7b5f54a1571fdb9a64621172b0.tar.bz2 stable-diffusion-webui-gfx803-74c538e84f57bd7b5f54a1571fdb9a64621172b0.zip |
script.js split work - dragdrop.js
Diffstat (limited to 'script.js')
-rw-r--r-- | script.js | 57 |
1 files changed, 0 insertions, 57 deletions
@@ -202,63 +202,6 @@ function submit(){ return res } -function isValidImageList( files ) { - return files && files?.length === 1 && ['image/png', 'image/gif', 'image/jpeg'].includes(files[0].type); -} - -function dropReplaceImage( imgWrap, files ) { - if ( ! isValidImageList( files ) ) { - return; - } - - imgWrap.querySelector('.modify-upload button + button')?.click(); - window.requestAnimationFrame( () => { - const fileInput = imgWrap.querySelector('input[type="file"]'); - if ( fileInput ) { - fileInput.files = files; - fileInput.dispatchEvent(new Event('change')); - } - }); -} - -window.document.addEventListener('dragover', e => { - const target = e.composedPath()[0]; - const imgWrap = target.closest('[data-testid="image"]'); - if ( !imgWrap ) { - return; - } - e.stopPropagation(); - e.preventDefault(); - e.dataTransfer.dropEffect = 'copy'; -}); - -window.document.addEventListener('drop', e => { - const target = e.composedPath()[0]; - const imgWrap = target.closest('[data-testid="image"]'); - if ( !imgWrap ) { - return; - } - e.stopPropagation(); - e.preventDefault(); - const files = e.dataTransfer.files; - dropReplaceImage( imgWrap, files ); -}); - -window.addEventListener('paste', e => { - const files = e.clipboardData.files; - if ( ! isValidImageList( files ) ) { - return; - } - [...gradioApp().querySelectorAll('input[type=file][accept="image/x-png,image/gif,image/jpeg"]')] - .filter(input => !input.matches('.\\!hidden input[type=file]')) - .forEach(input => { - input.files = files; - input.dispatchEvent(new Event('change')) - }); - [...gradioApp().querySelectorAll('[data-testid="image"]')] - .forEach(imgWrap => dropReplaceImage( imgWrap, files )); -}); - function ask_for_style_name(_, prompt_text, negative_prompt_text) { name_ = prompt('Style name:') return name_ === null ? [null, null, null]: [name_, prompt_text, negative_prompt_text] |