diff --git a/openlibrary/i18n/messages.pot b/openlibrary/i18n/messages.pot index 99b61dde84c..12a99a3b7c3 100644 --- a/openlibrary/i18n/messages.pot +++ b/openlibrary/i18n/messages.pot @@ -429,7 +429,8 @@ msgstr "" msgid "Library Explorer" msgstr "" -#: books/custom_carousel.html login.html search/work_search_facets.html +#: account/create.html books/custom_carousel.html login.html +#: search/work_search_facets.html msgid "Loading..." msgstr "" @@ -1033,6 +1034,10 @@ msgid "" "nonprofit Internet Archive" msgstr "" +#: account/create.html type/author/view.html +msgid "Success!" +msgstr "" + #: account/create.html msgid "Your URL" msgstr "" @@ -6479,10 +6484,6 @@ msgstr "" msgid "Refresh the page?" msgstr "" -#: type/author/view.html -msgid "Success!" -msgstr "" - #: type/author/view.html msgid "" "OK. The merge is in motion. It will take a few minutes to " diff --git a/openlibrary/plugins/openlibrary/js/signup.js b/openlibrary/plugins/openlibrary/js/signup.js index 782f801d3cb..e3d8f16a31f 100644 --- a/openlibrary/plugins/openlibrary/js/signup.js +++ b/openlibrary/plugins/openlibrary/js/signup.js @@ -3,6 +3,10 @@ import { debounce } from './nonjquery_utils.js'; export function initSignupForm() { const signupForm = document.querySelector('form[name=signup]'); const i18nStrings = JSON.parse(signupForm.dataset.i18n); + const emailLoadingIcon = $('.ol-signup-form__input--emailAddr .ol-signup-form__icon--loading'); + const usernameLoadingIcon = $('.ol-signup-form__input--username .ol-signup-form__icon--loading'); + const emailSuccessIcon = $('.ol-signup-form__input--emailAddr .ol-signup-form__icon--success'); + const usernameSuccessIcon = $('.ol-signup-form__input--username .ol-signup-form__icon--success'); // Keep the same with openlibrary/plugins/upstream/forms.py const VALID_EMAIL_RE = /^.*@.*\..*$/; @@ -60,6 +64,8 @@ export function initSignupForm() { function validateUsername() { const value_username = $('#username').val(); + usernameSuccessIcon.hide(); + if (value_username === '') { clearError('#username', '#usernameMessage'); return; @@ -75,15 +81,20 @@ export function initSignupForm() { return; } - clearError('#username', '#usernameMessage'); + usernameLoadingIcon.show(); $.ajax({ url: '/account/validate', data: { username: value_username }, type: 'GET', success: function(errors) { + usernameLoadingIcon.hide(); + if (errors.username) { renderError('#username', '#usernameMessage', errors.username); + } else { + clearError('#username', '#usernameMessage'); + usernameSuccessIcon.show(); } } }); @@ -92,6 +103,8 @@ export function initSignupForm() { function validateEmail() { const value_email = $('#emailAddr').val(); + emailSuccessIcon.hide(); + if (value_email === '') { clearError('#emailAddr', '#emailAddrMessage'); return; @@ -102,15 +115,20 @@ export function initSignupForm() { return; } - clearError('#emailAddr', '#emailAddrMessage'); + emailLoadingIcon.show(); $.ajax({ url: '/account/validate', data: { email: value_email }, type: 'GET', success: function(errors) { + emailLoadingIcon.hide(); + if (errors.email) { renderError('#emailAddr', '#emailAddrMessage', errors.email); + } else { + clearError('#emailAddr', '#emailAddrMessage'); + emailSuccessIcon.show(); } } }); diff --git a/openlibrary/templates/account/create.html b/openlibrary/templates/account/create.html index 29828a0f954..2db12b20538 100644 --- a/openlibrary/templates/account/create.html +++ b/openlibrary/templates/account/create.html @@ -29,7 +29,7 @@

$_("Sign Up")

$# :param openlibrary.utils.form.Input input: $# :param str suffix: HTML to put at bottom of input -