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

17 lines
482 B
JavaScript
Raw Normal View History

2018-09-06 19:23:27 +02:00
import Rails from 'rails-ujs';
import { show, hide } from '../shared/utils';
const { delegate } = Rails;
function showSpinner() {
[...document.querySelectorAll('.spinner')].forEach(show);
}
function hideSpinner() {
[...document.querySelectorAll('.spinner')].forEach(hide);
}
delegate(document, '[data-spinner]', 'ajax:complete', hideSpinner);
delegate(document, '[data-spinner]', 'ajax:stopped', hideSpinner);
delegate(document, '[data-spinner]', 'ajax:send', showSpinner);