demarches-normaliennes/app/javascript/new_design/spinner.js

14 lines
393 B
JavaScript
Raw Normal View History

2018-10-09 11:35:22 +02:00
import { show, hide, delegate } from '@utils';
2018-09-06 19:23:27 +02:00
function showSpinner() {
[...document.querySelectorAll('.spinner')].forEach(show);
}
function hideSpinner() {
[...document.querySelectorAll('.spinner')].forEach(hide);
}
2018-10-09 11:35:22 +02:00
delegate('ajax:complete', '[data-spinner]', hideSpinner);
delegate('ajax:stopped', '[data-spinner]', hideSpinner);
delegate('ajax:send', '[data-spinner]', showSpinner);