FIX optimizing save progress on save button
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2025-04-07 15:34:40 +02:00
parent 87c5990927
commit f3c6b39607
2 changed files with 21 additions and 3 deletions

View File

@ -89,17 +89,27 @@ add_action('edit_form_after_title', function () {
<!-- <button id="set-offline-status" class="button button-secondary">Mettre Hors Ligne</button>
<button id="set-online-status" class="button button-secondary">Mettre En Ligne</button> -->
<button id="save-post-custom" class="button button-primary">Sauvegarder</button>
<div id="save-post-custom">
<button class=" button button-primary">Sauvegarder</button>
<span class="spinner"></span>
</div>
</div>
<script>
jQuery(function($) {
$('#save-post-custom').on('click', function(e) {
e.preventDefault();
const $button = $(this);
const $button = $(this.querySelector('button'));
const $spinner = $(this.querySelector('.spinner'));
// Désactiver le bouton et changer le texte
$button.prop('disabled', true).text('Sauvegarde en cours...');
$spinner.show();
$spinner.addClass('is-active');
// Déclencher la sauvegarde
$('#publish').trigger('click');
@ -107,6 +117,8 @@ add_action('edit_form_after_title', function () {
// Réactiver le bouton et restaurer le texte après un délai
setTimeout(function() {
$button.prop('disabled', false).text('Sauvegarder');
$spinner.hide();
$spinner.removeClass('is-active');
}, 3000);
});
});

View File

@ -654,7 +654,13 @@ select[data-enpassusermodified='yes'] {
@apply text-white border-none rounded-xl px-4 !py-1 ml-auto;
}
#save-post-custom {
@apply ml-auto rounded-xl bg-amber-600 border-none text-white px-4 !py-1;
@apply ml-auto w-fit p-0 mr-0;
button {
@apply rounded-xl bg-amber-600 border-none text-white px-4 !py-1 mr-0;
}
.spinner:not(.is-active) {
@apply !hidden;
}
}
#set-offline-status {