5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-15 04:11:41 +00:00

mostrar un mensaje mientras se envía el form

This commit is contained in:
f 2018-12-14 10:38:50 -03:00
parent af512e788d
commit 8c2928e833
No known key found for this signature in database
GPG key ID: F3FDAB97B5F9F7E7
4 changed files with 8 additions and 0 deletions

View file

@ -9,13 +9,17 @@ $(document).on('turbolinks:load', function() {
$('.submit-post').click(function(e) {
var form = $(this).parents('form.form');
var invalid_help = $('.invalid_help');
var sending_help = $('.sending_help');
invalid_help.addClass('d-none');
sending_help.addClass('d-none');
if (form[0].checkValidity() === false) {
e.preventDefault();
e.stopPropagation();
invalid_help.removeClass('d-none');
} else {
sending_help.removeClass('d-none');
}
form.addClass('was-validated');

View file

@ -24,6 +24,7 @@
.form-group
= submit_tag t('posts.save'), class: 'btn btn-success submit-post'
.invalid_help.alert.alert-danger.d-none= @site.config.dig('invalid_help') || t('posts.invalid_help')
.sending_help.alert.alert-success.d-none= @site.config.dig('sending_help') || t('posts.sending_help')
- if current_user.is_a? Usuaria
.form-group
= label_tag 'post_author', t('posts.author')
@ -127,5 +128,6 @@
.form-group
= submit_tag t('posts.save'), class: 'btn btn-success submit-post'
.invalid_help.alert.alert-danger.d-none= @site.config.dig('invalid_help') || t('posts.invalid_help')
.sending_help.alert.alert-success.d-none= @site.config.dig('sending_help') || t('posts.sending_help')
- if post = @post.template.get_front_matter('post')
= render 'layouts/help', help: CommonMarker.render_doc(post).to_html

View file

@ -242,3 +242,4 @@ en:
multiple: 'You can select several images'
url: 'The address must start with http:// or https://'
invalid_help: It looks like the form is incomplete. Check the red-colored fields to complete it.
sending_help: Saving, please wait...

View file

@ -249,3 +249,4 @@ es:
multiple: 'Puedes seleccionar varias imágenes'
url: 'La dirección debe comenzar con http:// o https://'
invalid_help: Parece que el formulario no está completo. Verifica los campos marcados en rojo para completarlo.
sending_help: Guardando, por favor espera...