demarches-normaliennes/app/javascript/new_design/procedure-form.js

22 lines
964 B
JavaScript
Raw Normal View History

import { delegate } from '@utils';
2019-09-24 16:38:58 +02:00
function syncInputToElement(fromSelector, toSelector) {
const fromElement = document.querySelector(fromSelector);
const toElement = document.querySelector(toSelector);
if (toElement && fromElement) {
toElement.innerText = fromElement.value;
}
}
function syncFormToPreview() {
syncInputToElement('#procedure_libelle', '.procedure-title');
2019-09-24 16:38:58 +02:00
syncInputToElement('#procedure_description', '.procedure-description-body');
syncInputToElement('#procedure_description_what', '.js_description_what p');
syncInputToElement('#procedure_description_for_who', '.js_description_for_who p');
2019-09-24 16:38:58 +02:00
}
delegate('input', '.procedure-form #procedure_libelle', syncFormToPreview);
delegate('input', '.procedure-form #procedure_description', syncFormToPreview);
delegate('input', '.procedure-form #procedure_description_what', syncFormToPreview);
delegate('input', '.procedure-form #procedure_description_for_who', syncFormToPreview);