2018-10-02 16:59:30 +02:00
|
|
|
/* eslint no-unused-vars:0 */
|
|
|
|
/* globals $ */
|
|
|
|
|
2018-10-02 13:51:56 +02:00
|
|
|
$(document).on('turbolinks:load', handle_siret_form_errors);
|
2016-06-20 13:57:57 +02:00
|
|
|
|
2016-11-24 19:33:34 +01:00
|
|
|
function error_form_siret(invalid_siret) {
|
2018-10-02 16:59:30 +02:00
|
|
|
setTimeout(function() {
|
|
|
|
$("input[type='submit']").val('Erreur SIRET');
|
2017-04-04 16:15:33 +02:00
|
|
|
}, 10);
|
2016-09-16 17:08:50 +02:00
|
|
|
|
2018-10-02 16:59:30 +02:00
|
|
|
$("input[type='submit']")
|
|
|
|
.removeClass('btn-success')
|
|
|
|
.addClass('btn-danger');
|
2016-06-20 13:57:57 +02:00
|
|
|
|
2018-10-02 16:59:30 +02:00
|
|
|
$('#dossier-siret')
|
|
|
|
.addClass('input-error')
|
|
|
|
.val(invalid_siret)
|
|
|
|
.on('input', reset_form_siret);
|
2016-06-20 13:57:57 +02:00
|
|
|
}
|
|
|
|
|
2016-11-24 19:33:34 +01:00
|
|
|
function reset_form_siret() {
|
2018-10-02 16:59:30 +02:00
|
|
|
$("input[type='submit']")
|
|
|
|
.removeClass('btn-danger')
|
|
|
|
.addClass('btn-success')
|
|
|
|
.val('Valider');
|
|
|
|
$('#dossier-siret').removeClass('input-error');
|
2016-07-18 09:37:22 +02:00
|
|
|
}
|
|
|
|
|
2016-11-24 19:33:34 +01:00
|
|
|
function toggle_etape_1() {
|
2017-04-12 11:12:05 +02:00
|
|
|
$('.row.etape.etape_1 .etapes-menu #logos').toggle(100);
|
2018-10-02 16:59:30 +02:00
|
|
|
$('.row.etape.etape_1 .etapes-informations #description_procedure').toggle(
|
|
|
|
100
|
|
|
|
);
|
2016-11-23 16:17:29 +01:00
|
|
|
}
|
2018-03-27 11:26:42 +02:00
|
|
|
|
|
|
|
function handle_siret_form_errors() {
|
2018-10-02 16:59:30 +02:00
|
|
|
$('.form-inline[data-remote]').on('ajax:error', function(event) {
|
2018-03-27 11:26:42 +02:00
|
|
|
var input = $('#dossier-siret', event.target);
|
|
|
|
if (input.length) {
|
|
|
|
var invalid_siret = input.val();
|
|
|
|
error_form_siret(invalid_siret);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|