demarches-normaliennes/app/javascript/new_design/spinner.js
2018-10-10 14:55:28 +02:00

13 lines
393 B
JavaScript

import { show, hide, delegate } from '@utils';
function showSpinner() {
[...document.querySelectorAll('.spinner')].forEach(show);
}
function hideSpinner() {
[...document.querySelectorAll('.spinner')].forEach(hide);
}
delegate('ajax:complete', '[data-spinner]', hideSpinner);
delegate('ajax:stopped', '[data-spinner]', hideSpinner);
delegate('ajax:send', '[data-spinner]', showSpinner);