mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 13:47:58 +01:00
Disable image scraper fetch when there is no text (#92)
*Modified fetch to be disabled on pageload. Javascript enables it after the user has entered some text. Re-disables it if the text goes to zero, or the image upload button has been used.
This commit is contained in:
parent
2fc271d7aa
commit
ba76ede87d
5 changed files with 17 additions and 4 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -38,3 +38,6 @@ npm-debug.log
|
|||
|
||||
# Mnesia
|
||||
/Mnesia*
|
||||
|
||||
# Intellij IDEA
|
||||
.idea
|
||||
|
|
|
@ -67,6 +67,7 @@ function setupImageUpload() {
|
|||
// Clear any currently cached data, because the file field
|
||||
// has higher priority than the scraper:
|
||||
remoteUrl.value = '';
|
||||
disableFetch();
|
||||
hideError();
|
||||
});
|
||||
|
||||
|
@ -101,6 +102,15 @@ function setupImageUpload() {
|
|||
enableFetch();
|
||||
}).catch(showError);
|
||||
});
|
||||
|
||||
// Enable/disable the fetch button based on content in the image scraper. Fetching with no URL makes no sense.
|
||||
remoteUrl.addEventListener('input', () => {
|
||||
if(remoteUrl.value.length > 0) {
|
||||
enableFetch();
|
||||
} else {
|
||||
disableFetch();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export { setupImageUpload };
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
.field.field--inline
|
||||
= url_input f, :scraper_url, class: "input input--wide js-scraper", placeholder: "Link a deviantART page, a Tumblr post, or the image directly"
|
||||
button.button.button--separate-left#js-scraper-preview type="button" title="Fetch the image at the specified URL" data-disable-with="Fetch"
|
||||
button.button.button--separate-left#js-scraper-preview(type="button" title="Fetch the image at the specified URL" data-disable-with="Fetch" disabled)
|
||||
' Fetch
|
||||
|
||||
.field-error-js.hidden.js-scraper
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
.field.field--inline
|
||||
= url_input f, :scraper_url, class: "input input--wide js-scraper", placeholder: "Link a deviantART page, a Tumblr post, or the image directly"
|
||||
button.button.button--separate-left#js-scraper-preview type="button" title="Fetch the image at the specified URL" data-disable-with="Fetch"
|
||||
button.button.button--separate-left#js-scraper-preview(type="button" title="Fetch the image at the specified URL" data-disable-with="Fetch" disabled)
|
||||
' Fetch
|
||||
|
||||
.field-error-js.hidden.js-scraper
|
||||
|
|
|
@ -16,7 +16,7 @@ h1 Reverse Search
|
|||
|
||||
.field.field--inline
|
||||
= url_input f, :url, name: "url", class: "input input--wide js-scraper", placeholder: "Link a deviantART page, a Tumblr post, or the image directly"
|
||||
button.button.button--separate-left#js-scraper-preview type="button" title="Fetch the image at the specified URL" data-disable-with="Fetch"
|
||||
button.button.button--separate-left#js-scraper-preview(type="button" title="Fetch the image at the specified URL" data-disable-with="Fetch" disabled)
|
||||
' Fetch
|
||||
|
||||
.field-error-js.hidden.js-scraper
|
||||
|
|
Loading…
Reference in a new issue