$(document).ready(function () { $('.collection.collapsible').collapsible({ accordion: false }); /*Slider tag article*/ if ($('#slider_articles_tag').length) { var slider_article_2 = $("#slider_articles_tag").lightSlider({ item: 4, controls: false, pager: false, responsive: [ { breakpoint: 1000, settings: { item: 2 } }, { breakpoint: 600, settings: { item: 1 } } ] }); $('#slider_articles_tag + #bouton_prev_articles').on('click', function () { slider_article_2.goToPrevSlide(); }); $('#slider_articles_tag + #bouton_next_articles').on('click', function () { slider_article_2.goToNextSlide(); }); } if ($('.liste-dossiers-documents').length > 0) { $('.liste-dossiers-documents .collection-item:first-child .collection-item-lien, .liste-dossiers-documents .collection-item:first-child .collapsible-body:nth-child(2)').trigger('click'); } }); function affiche_password(that) { var input = $(that).next('input'); if ($(input).prop('type') == "password") { $(input).prop('type', 'text'); } else { $(input).prop('type', 'password'); } } function show_documents_cat(id_cat) { var html = $('.documents[data-cat=' + id_cat + ']').html(); $('.liste-documents').fadeOut(function () { $('.liste-documents').html(html).fadeIn() }); $('.collapsible-body').removeClass('active'); $('.collapsible-body[data-idu="' + id_cat + '"]').addClass('active'); } function show_informations_cat(id_cat) { var html = $('.informations[data-cat=' + id_cat + ']').html(); $('.liste-informations').fadeOut(function () { $('.liste-informations').html(html).fadeIn() }); $('.collection-item-lien').removeClass('active'); $('.collection-item-lien[data-idu="' + id_cat + '"]').addClass('active'); } function menu_suivant(that) { $(that).next('ul').addClass('active'); $(that).parent('li').parent('ul').addClass('overflow_false'); } function ferme_menu_actif(that) { $(that).parent('ul').removeClass('active'); $(that).parent('ul').parent('li').parent('ul').removeClass('overflow_false'); } // QUESTIONNAIRE var idReponse; function beforeEtapeQuestionnaire(categorie) { $.ajax({ beforeSend: function () { $('
').appendTo($('#questionnaire')); }, type: "POST", url: "../ajax-call", data: { fct: 'beforeEtapeQuestionnaire', categorie: categorie }, success: function (data) { data = JSON.parse(data); var id_question = data['id_question']; var id_precedent_question = data['id_precent_question']; var categorie = data['categorie']; var id_reponse = data['id_reponse']; nextEtapeQuestionnaire(id_question, id_precedent_question, categorie, 1, id_reponse); } }); } function getEtapeFinale() { // Je vais récupérer les données stockées dans la session $.ajax({ beforeSend: function () { $('.infos_question').html('').addClass('no_style'); $('').appendTo($('.infos_question')); }, type: "POST", url: "../ajax-call", data: { fct: 'getSessionQuestionnaire', }, success: function (data) { $('.infos_question').remove(); $('#questionnaire').html(data); /*On réinit les selects car ça ne fonctionne pas s'il y a un form*/ $('select').formSelect(); } }); } function nextEtapeQuestionnaire(id_current_question, id_precedent_question, categorie, before = 0, id_before_reponse = 0) { /*On peut cliquer seulement si un radio et check + étape suivante ou étape précédente*/ if (($('.input_reponse').is(':checked') && before === 0) || before === 1) { var firstQuestion = $('#nextEtapeBtn').attr('firstQuestion'); $('#nextEtapeBtn').attr('firstQuestion', 0); $.ajax({ beforeSend: function () { $('').appendTo($('#questionnaire')); }, type: "POST", url: "../ajax-call", data: { fct: 'nextquestionnaire', id_current_question: id_current_question, categorie: categorie, id_precedent_question: id_precedent_question, idReponse: idReponse, firstQuestion: firstQuestion, beforeQuestion: before }, success: function (data) { data = JSON.parse(data); $('.loader_questionnaire').remove(); /*On vide les anciennes réponses*/ $('.infos_reponses').html(''); if (before === 0) { // Je vérifie si il s'agit d'une question finale if (isFinal === '1') { getEtapeFinale(); return; } } /*On remplace les infos questions*/ $('.infos_question').html( '