/* #PRODUIRE{fond=_js/cibloc.js} md5:5f5a01b66417293b1fbfe784db7aa1b7 */ var cibloc_accordeon_id = 0; var cibloc_question_id = 0; var cibloc_ancre = window.location.hash; var cibloc_ancre_existe = false; function cibloc_accordeon_replier_tout(id_question_click) { var bloc_id = ''; var tableau = ''; var tableau_click = id_question_click.split('-'); var id_bloc_click = ''; if (typeof tableau_click[0] !== 'undefined' && typeof tableau_click[1] !== 'undefined') { id_bloc_click = tableau_click[0] + '-' + tableau_click[1]; } var lesLiens = $('.cibloc_accordeon a.accordeon_lien'); for (var i=0; i'); var reponse = $this.next(); // Cas de l'affichage de la liste des blocs : ne pas activer le clic if ($this.parents().hasClass("cibloc_sans_vignette")){ // ajouter un lien $this.wrapInner(''); $this.wrapInner(''); // Cas classique } else { // ajouter un lien $this.wrapInner(''); $this.wrapInner(''); var lien = $this.children('a'); // affecter au lien l'evenement click lien.on('click', function(event) { if ($(this).attr('aria-expanded') === 'false'){ cibloc_accordeon_replier_tout($(this).attr('aria-controls')); $(this).attr('aria-expanded', 'true'); $(this).addClass('expanded'); reponse.attr('aria-hidden', 'false'); reponse.css('display', 'block'); event.preventDefault(); event.stopPropagation(); } else { $(this).attr('aria-expanded', 'false'); $(this).removeClass('expanded'); reponse.attr('aria-hidden', 'true'); reponse.css('display', 'none'); event.preventDefault(); event.stopPropagation(); } }); } }); }); // variante avec un comportement plus classique // chaque question doit etre un intertitre dans le bloc accordeon2 // (et elle deplie une question si l'URL contient l'ancre de cette question) $('.cibloc_accordeon2').each(function() { cibloc_accordeon_id++; cibloc_question_id = 0; $(this).find(intertitre).each(function() { var $this = $(this); // index de l'element dans la collection cibloc_question_id++; var id = 'accordeon-' + cibloc_accordeon_id + '-' +cibloc_question_id; // masquer au demarrage ... var style = ' style="display:none;"'; var ariahidden = ' aria-hidden="true"'; var ariaexpanded = ' aria-expanded="false"'; var lienclass = ' class="accordeon_lien"'; // ... sauf si l'URL contient l'ancre de la question if (cibloc_ancre && cibloc_ancre=='#'+id){ style = ''; ariahidden = ' aria-hidden="false"'; ariaexpanded = ' aria-expanded="true"'; lienclass = ' class="accordeon_lien expanded"'; cibloc_ancre_existe = true; } // enlever un eventuel lien de retour au sommaire $this.children( "a.sommaire-back" ).css( "display", "none" ); // entourer la reponse avec un div $this.nextUntil(intertitre).wrapAll('
'); var reponse = $this.next(); // Cas de l'affichage de la liste des blocs : ne pas activer le clic if ($this.parents().hasClass("cibloc_sans_vignette")){ // ajouter un lien $this.wrapInner(''); $this.wrapInner(''); // Cas classique } else { // ajouter un lien $this.wrapInner(''); $this.wrapInner(''); var lien = $this.children('a'); // affecter au lien l'evenement click lien.on('click', function(event) { if ($(this).attr('aria-expanded') === 'false'){ $(this).attr('aria-expanded', 'true'); $(this).addClass('expanded'); reponse.attr('aria-hidden', 'false'); reponse.css('display', 'block'); event.preventDefault(); event.stopPropagation(); } else { $(this).attr('aria-expanded', 'false'); $(this).removeClass('expanded'); reponse.attr('aria-hidden', 'true'); reponse.css('display', 'none'); event.preventDefault(); event.stopPropagation(); } }); } }); }); // variante qui ne se replie pas // chaque question doit etre un intertitre dans le bloc accordeon3 $('.cibloc_accordeon3').each(function() { cibloc_accordeon_id++; cibloc_question_id = 0; var lienclass = ' class="accordeon_lien expanded"'; $(this).find(intertitre).each(function() { var $this = $(this); // index de l'element dans la collection cibloc_question_id++; var id = 'accordeon-' + cibloc_accordeon_id + '-' +cibloc_question_id; // enlever un eventuel lien de retour au sommaire $this.children( "a.sommaire-back" ).css( "display", "none" ); // entourer la reponse avec un div $this.nextUntil(intertitre).wrapAll('