1 2var breakpoints = { 3 xxl: 1400, 4 xl: 1200, 5 lg: 992, 6 md: 768, 7 sm: 576 8} 9var langPage = $('html').attr('lang'); 10 11if (langPage == "fr" && $.ui?.autocomplete) { 12 $.extend($.ui.autocomplete.prototype.options.messages, { 13 noResults: "Aucun résultat trouvé.", 14 results: function(count) { 15 return count + (count > 1 ? " résultats disponibles." : " résultat disponible.") + ", utilisez les flèches directionnelles haut et bas pour vous déplacer dans la liste."; 16 } 17 }); 18} 19 20if ($.ui?.autocomplete) { 21 $.widget( "ui.autocomplete", $.ui.autocomplete, { 22 _renderItem: function( ul, item ) { 23 return this._getListItemElement(item) 24 .appendTo(ul); 25 }, 26 27 _resizeMenu: function() { 28 if (this.element.closest("qc-search-bar").length > 0) return; 29 this.menu.element.outerWidth( 400 ); 30 }, 31 _getListItemElement(item, formatted = null) { // partagé avec suggest_controller.js 32 return $("<li>") 33 .attr("data-value", item.value) 34 .append( 35 $( "<div>" ) 36 .html(`<span class="ui-menu-item-icon"><qc-icon type='search-thin' size='md' aria-hidden='true' ></qc-icon></span>` 37 + `<span class="ui-autocomplet-li-text">` + (formatted ?? item.label) + `</span>`)) 38 ; 39 40 } 41 } ); 42} 43 44 45$(document).ready(function() { 46 47 // suppression des infos de débogage Fluid activé via l'admin panel 48 document.querySelectorAll(".t3js-debug-template span:first-child").forEach(e => e.remove()) 49 document.querySelectorAll(".t3js-debug-template").forEach(e => e.removeAttribute("style")) 50 51 // Variables 52 53 var rechOuvreFr = "Bouton pour ouvrir la recherche."; 54 var rechOuvreEn = "Button to open search."; 55 var rechFermeFr = "Bouton pour fermer la recherche."; 56 var rechFermeEn = "Button to close search."; 57 58 // Supprimer le visuel sans Javascript 59 $(".nojs").removeClass("nojs"); 60 // Navigation pour les thèmes : version mobile 61 /* $('.navbar-toggler').click(function () { 62 $(this).toggleClass('open'); 63 });*/ 64 // Accordéon : ajouter les textes cachés 65 $('div[id^="collapse-"]').on('hidden.bs.collapse', function () { 66 var message = "Afficher le contenu"; 67 if (langPage == "en") { 68 message = "Show content"; 69 }; 70 $(this).prev().find("h4").find("a").find("span").html(message); 71 }); 72 73 $('div[id^="collapse-"]').on('shown.bs.collapse', function () { 74 var message = "Cacher le contenu"; 75 if (langPage == "en") { 76 message = "Hide content"; 77 }; 78 $(this).prev().find("h4").find("a").find("span").html(message); 79 }); 80 81 if ($('div[id^="collapse-"]')) { 82 var message = "Afficher le contenu"; 83 if (langPage == "en") { 84 message = "Show content"; 85 }; 86 $('div[id^="collapse-"]').prev().find("h4").find("a").append("<span class='visuallyHidden'>" + message + "</span>"); 87 } 88 89 90 91 // Retour à la page â pages campagne : flèche « arrow_back » Material teintée 92 // avec la couleur de la campagne, injectée dans son conteneur dédié. 93 // (l'ancien fleche-retour.svg a été migré vers <qc-icon>, cf. 3b0e7f31be ; 94 // l'ancien fetch/recolor du SVG plantait ici car il n'y a plus d'<img>.) 95 var svgContainer = document.getElementById("fleche-retour-page-campagne"); 96 if(svgContainer !== undefined && svgContainer !== null ){ 97 const selectedSvgColor = $('#selectedSvgColor').data('svg-color') 98 var backIcon = document.createElement('qc-icon'); 99 backIcon.setAttribute('icon', 'arrow_back'); 100 backIcon.setAttribute('size', 'sm'); 101 backIcon.setAttribute('aria-hidden', 'true'); 102 if (selectedSvgColor) { 103 backIcon.style.color = selectedSvgColor; 104 backIcon.style.setProperty('--img-color', selectedSvgColor); 105 } 106 svgContainer.appendChild(backIcon); 107 svgContainer.style.marginRight = "0.25rem"; 108 } 109 110 // Détection des onglets avec le slider(facultatif) 111 if($('.tab-v1 ul').length){ 112 $slick_slider = $('.tab-v1 ul').children("li.nav-item").parent(); 113 // Configurations du slider 114 settings = { 115 mobilefirst: true, 116 infinite: false, 117 prevArrow: "<button class=\"slick-prev slick-arrow\"><qc-icon icon='chevron_left' use-material aria-hidden='true'></qc-icon><span class='visuallyHidden'>Onglet précédent</span></button>", 118 nextArrow: "<button class=\"slick-next slick-arrow\"><qc-icon icon='chevron_right' use-material aria-hidden='true'></qc-icon><span class='visuallyHidden'>
118Prochain onglet</span></button>", 119 slidesToShow: 1, 120 slidesToScroll: 1, 121 variableWidth: true, 122 regionLabel:"Onglets : utilisez les flèches du clavier pour passer d'un onglet à l'autre. Sur un mobile, il y a des boutons suivants et précédent atteignables par tabulation.", 123 } 124 if (langPage == "en") { 125 settings = { 126 mobilefirst: true, 127 infinite: false, 128 prevArrow: "<button class=\"slick-prev slick-arrow\"><qc-icon icon='chevron_left' use-material aria-hidden='true'></qc-icon><span class='visuallyHidden'>Previous tab</span></button>", 129 nextArrow: "<button class=\"slick-next slick-arrow\"><qc-icon icon='chevron_right' use-material aria-hidden='true'></qc-icon><span class='visuallyHidden'>Next tab</span></button>", 130 slidesToShow: 1, 131 slidesToScroll: 1, 132 variableWidth: true, 133 regionLabel:"Tabs: use the arrows on the keyboard to move from one tab to another. On a mobile, there are next and previous buttons that can be reached by tabulation.", 134 } 135 } 136 // Afficher le slider si nécessaire 137 afficherSliderOnglets($slick_slider,settings); 138 // S'il y a un slider, ajouter les listeners et quelques éléments pour l'accessibilités 139 if($(".slick-list").length){ 140 ajouterListenertabSlider($slick_slider); 141 ajouterAttributAccessibilite(); 142 tabWidth(); 143 } 144 // Au resize du navigateur, valider à nouveau les onglets qui ont besoin ou non d'un slider 145 $(window).on('resize', function() { 146 afficherSliderOnglets($slick_slider,settings); 147 if($(".slick-list").length){ 148 ajouterListenertabSlider($slick_slider); 149 ajouterAttributAccessibilite(); 150 tabWidth(); 151 } 152 }); 153 } 154 155 // Tous les types d'onglets de gridelement 156 if($('.nav-tabs').length){ 157 // accessibilité - clavier 158 tabs = document.querySelectorAll('[role="tab"]'); 159 160 // Bind listeners 161 for (i = 0; i < tabs.length; ++i) { 162 addListeners(i); 163 }; 164 165 function addListeners (index) { 166 tabs[index].addEventListener('keydown', keydownEventListenerTabs); 167 }; 168 169 // Onglets de grid_element 170 $('.nav-tabs').attr("role","tablist"); 171 $('.nav-tabs').find("li").attr("role","none"); 172 $(".tab-content .tab-pane").attr("tabindex","0") 173 $('.nav-tabs .nav-item .nav-link:not([aria-selected])').attr("aria-selected","false"); 174 175 // Changer le tabindex selon l'onglet actif 176 var $tabs = $(".nav-tabs .nav-item a"); 177 var observer = new MutationObserver(function(mutations) { 178 mutations.forEach(function(mutation) { 179 if($(mutation.target).parents(".slick-slide").length > 0){ 180 $(mutation.target).parents(".slick-slide").attr("aria-hidden",""); 181 } 182 if (mutation.attributeName === "class") { 183 if($(mutation.target).hasClass( "active" )){ 184 $(mutation.target).removeAttr("tabindex"); 185 }else{ 186 $(mutation.target).attr("tabindex","-1"); 187 } 188 } 189 }); 190 }); 191 192 $('.nav-tabs .nav-item a').each(function() { 193 observer.observe(this, { 194 attributes: true 195 }); 196 }); 197 } 198 199 // wrapper tuiles 200 if($('.tuiles-section').length){ 201 zoneTuilesMemeHauteur(); 202 $(window).resize(function() { zoneTuilesMemeHauteur(); }); 203 } 204 205 if($('#main .searchinfo').length){ 206 $('.col-12').addClass('sansBorder'); 207 } 208 // Permettre au formulaire de recherche RPS de créer le lien qui amène à la page de recherche/résultats 209 if($('#inputKeydown').length){ 210 if(langPage=="en"){ 211 var pageResultats = "results"; 212 }else{ 213 var pageResultats = "resultats"; 214 } 215 $('#inputKeydown').on("input", function() { 216 var dInput = this.value; 217 if(langPage=="en"||langPage=="fr"){ }else{langPage=="fr"} 218 $('#linkToForm').prop("href", "https://"+document.location.host+document.location.pathname+pageResultats+"/#query="+dInput+"&lang="+langPage+"&searchType=allWords&collectionName=rps-sujets"); 219 }); 220 // Donner l'illusion que le Enter fonctionne pour l'envoi du formulaire. 221 $("#inputKeydown").on('keyup', function (e) { 222 if (e.keyCode == 13) { 223 var dInput = this.value; 224 if(langPage=="en"||langPage=="fr"){ }else{langPage=="fr"} 225 window.location.href = "https://"+document.location.host+document.location.pathname+pageResultats+"/#query="+dInput+"&lang="+langPage+"&searchType=allWords&collectionName=rps-sujets"; 226 } 227 }); 228 } 229 // CSS de base pour table 230 /*if ($('table')) { 231 var tds = document.querySelectorAll("td, th"); 232 var groups = []; 233 234 for (var i = 0; i < tds.length; i++) { 235 if (tds[i].getAttribute('rowspan') != null) { 236 var rspan = tds[i]; 237 groups.push({ 238 parent: rspan.parentNode, 239 height: rspan.getAttribute('rowspan') 240 }); 241 } 242 } 243 244 var count = 0; 245 var rows = document.querySelectorAll('tr'); 246 var dark = true; 247 248 for (var i = 1; i < rows.length; i++) { 249 var row = rows[i]; 250 var index = groupIndex(row); 251 if (index != null) { 252 var group = groups[index]; 253 var height = parseInt(group.height); 254 if (dark) { 255 for (var j = i; j < i + height; j++) { 256 rows[j].classList.add('fonce'); 257 } 258 } 259 i += height - 1; 260 dark = !dark; 261 continue; 262 } 263 if (dark) { 264 rows[i].classList.add('fonce'); 265 } 266 dark = !dark; 267 } 268 } 269 // groupage de tr 270 function groupIndex(element){ 271 for(var i = 0; i < groups.length; i++){ 272 var group = groups[i].parent; 273 if(group == element){ 274 return i; 275 } 276 } 277 return null; 278 }*/ 279 // Seulement pour le desktop 280 if($(window).innerWidth() >= 767) { 281 // Animation du menu 3 niveaux pour les thèmes 282 // Clique sur le niveau 2 283 $('.navThemeNiveauDeux a.menuDeplacement').click(function (event) { 284 // Variable pour la destination du lien 285 event.preventDefault(); 286 var href = this.href; 287 // Animation 288 $('.navThemeNiveauDeux').animate({ 289 marginLeft: '-17%' 290 }, 800, function () { 291 // Après l'animation, on redirige vers la cible de la page 292 window.location = href; 293 }); 294 }); 295 // Clique sur le niveau 1 296 $('.navThemeNiveauUn a').click(function (event) { 297 // Variable pour la destination du lien 298 event.preventDefault(); 299 var href = this.href; 300 // Validation que le niveau 2 avait déjà été animé 301 if ($('.navThemeNiveauDeux').hasClass('niveauDeuxDesactive')) { 302 // Animation (revenir avant la première animation) 303 $('.navThemeNiveauDeux').animate({ 304 marginLeft: '0' 305 }, 800, function () { 306 // Après l'animation, on redirige vers la cible de la page 307 window.location = href; 308 }); 309 } else { 310 window.location = href; 311 } 312 313 }); 314 } 315 316 // Fonction du clic du bouton de contrôle du menu secondaire de la section Système de design
317 $('#lienOuvreCNGImage').mouseup(function (event) { 318 if($('.menuSousPagesCNG-gauche').css('display') == 'none'){ 319 $('.menuSousPagesCNG-gauche').slideDown('slow'); 320 $('.menuSousPagesCNG-gaucheHR').fadeIn('slow'); 321 $('.menuSousPagesCNG-gaucheTitre').attr('aria-expanded', true); 322 } else { 323 $('.menuSousPagesCNG-gauche').slideUp('slow'); 324 $('.menuSousPagesCNG-gaucheHR').fadeOut('slow'); 325 $('.menuSousPagesCNG-gaucheTitre').attr('aria-expanded', false); 326 } 327 $('#lienOuvreCNGImage').toggleClass("ouvert"); 328 }); 329 330 // Cacher le menu secondaire de la section Système de design lors du chargement de la page en mobile 331 if ($(window).width() < 768) { 332 $('.menuSousPagesCNG-gauche').hide(); 333 $('.menuSousPagesCNG-gaucheHR').hide(); 334 } 335 336 337 // Interdiction de coller dans un champ 338 $(document).ready(function () { 339 $('.disablecopypaste').bind('copy paste', function (e) { 340 e.preventDefault(); 341 }); 342 }); 343 344 const forms = document.querySelectorAll('.powermail_form'); 345 forms.forEach(function(form) { 346 let formValidation = form.powermailFormValidation; 347 formValidation.addValidator('confirmationCourriel', function(field) { 348 if ($("input#powermail_field_courriel").length && field.hasAttribute('data-powermail-confirmation-courriel')) { 349 msg = "Inscrivez le même courriel quâau champ précédent."; 350 if (langPage == "en") { 351 msg = 'This email should be the same email.' 352 } 353 var test = field.value !== $("#powermail_field_courriel").val() 354 if(test === true){ 355 $(field).attr('data-powermail-error-message', msg) 356 } 357 return test; 358 } 359 return false; 360 }); 361 }); 362 363 //Si la page contient un bloc de type Zone vidéo 364 if( $('#conteneurVideos').length ) { 365 $('#conteneurVideos').attr("id","conteneurVideos-js"); 366 $( "#conteneurVideos-js" ).closest( "#main" ).removeClass( "videoCampagne" ); 367 $(window).resize(function() { zoneVideoBG(); }); 368 zoneVideoBG(); 369 $('.thumbnails-videos-to-move').find("a").first().attr("aria-selected","true"); 370 } 371 //Liens passer au prochain/précédent pour éviter la vidéo au clavier (accessibilité) 372 if( $('.link-pass-over-video').length ){ 373 $('.link-pass-over-video').each(function( index ) { 374 var arrIdParent = $(this).attr("id").split('_'); 375 var strIdParent = "c"+arrIdParent[0]; 376 var targetDetecte = new RegExp('prochain$'); 377 var arrLink = [$("#"+strIdParent).prev(),'_precedent','_precedent_target', $("#"+strIdParent).parent().prev()]; 378 379 // Si le lien est pour le prochain contenu au lieu du contenu précédent 380 if (targetDetecte.test($(this).attr("id"))) { 381 arrLink = [$("#"+strIdParent).next(),'_prochain','_suivant_target', $("#"+strIdParent).parent().next()]; 382 } 383 // S'il n'y a pas d'élément suivant/précédent, on monte d'un niveau. 384 if(arrLink[0].length == 0){ 385 arrLink[0] = arrLink[3]; 386 } 387 // S'il n'a pas de id, ajouter un id 388 if(arrLink[0].attr("id") == undefined){ 389 arrLink[0].attr("id",arrIdParent[0]+arrLink[2]); 390 } 391 $("#"+arrIdParent[0]+arrLink[1]).attr("href","#"+arrLink[0].attr("id")); 392 }); 393 }; 394 395 if (typeof hc !== 'undefined') { 396 397 var options = { 398 lang: { 399 contextButtonTitle:'Chart context menu', 400 downloadCSV:'Télécharger le CSV', 401 downloadJPEG:'Télécharger l\'image en JPEG', 402 downloadPDF:'Télécharger le PDF', 403 downloadPNG:'Télécharger l\'image en PNG', 404 downloadSVG:'Télécharger l\'image en SVG', 405 downloadXLS:'Télécharger le XLS', 406 printChart:'Imprimer le graphique', 407 resetZoom:'Réinitialiser le zoom', 408 viewFullscreen:'Plein écran', 409 viewData:'Voir la table de données', 410 months: ["janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"], 411 shortMonths: ["jan", "fév", "mar", "avr", "mai", "juin", "juil", "aou", "sep", "oct", "nov", "déc"] 412 }, 413 exporting: { 414 buttons: { 415 contextButton: { 416 menuItems: ['viewFullscreen', 'printChart', 'separator', 'downloadPNG', "downloadJPEG", "downloadPDF"] 417 } 418 } 419 }, 420 plotOptions: { 421 series: { 422 label: { 423 enabled: false 424 } 425 } 426 }, 427 credits: { 428 enabled: false 429 } 430 } 431 Highcharts.setOptions($.extend(hc.options || {}, options)); 432 $.each(hc.graphs, function (id, conf) { 433 if (typeof conf.csv != 'undefined') { 434 $.get(conf.csv, function(csvData) { 435 conf.settings.data.csv = csvData 436 Highcharts.chart(id, conf.settings); 437 }); 438 } 439 else { 440 Highcharts.chart(id, conf.settings); 441 } 442 }) 443 } 444 //Blockquotes 445 if($('blockquote').length){ 446 $('blockquote').each(function( index ) { 447 if($(this).text().length <= 140){ $(this).attr("class", "bq-font-size")} 448 if ($(this).find("p").attr("lang")) { 449 var blockquoteLang = $(this).find("p").attr("lang"); 450 $(this).addClass('lang-'+blockquoteLang); 451 } 452 // Nom de la source 453 var nextAllBlockquote = $(this).nextAll("p"); 454 nextAllBlockquote.each(function(){ 455 if($(this).find("br").length > 0){
456 var strSource = $(this).html(); 457 var strAuteur = strSource.slice(0, strSource.indexOf("<br>")); 458 var strTitre = strSource.slice(strSource.indexOf("<br>") +4); 459 $(this).html(strAuteur+"<span>"+strTitre+"</span>"); 460 } 461 }); 462 }); 463 } 464 465 // AJOUT : recalcul continu de l'arrière-plan vidéo pendant l'animation de l'accordéon 466 if ($('#conteneurVideos-js').length) { 467 var _accordionAnimating = false; 468 469 $('div[id^="collapse-"]').on('show.bs.collapse hide.bs.collapse', function () { 470 471 if (_accordionAnimating) return; 472 _accordionAnimating = true; 473 474 function rafLoop() { 475 zoneVideoBG(); 476 //Verifier si l'animation est encore en cours 477 if (_accordionAnimating) { 478 //requestAnimationFrame: fuinction navigateur pour exécute une fonction juste avant le prochain rendu visuel de l'écran 479 //planifie un autre appel à la prochaine frame 480 requestAnimationFrame(rafLoop); 481 } 482 } 483 requestAnimationFrame(rafLoop); 484 }); 485 486 $('div[id^="collapse-"]').on('shown.bs.collapse hidden.bs.collapse', function () { 487 _accordionAnimating = false; 488 zoneVideoBG(); // recalcul final une fois l'animation terminée 489 }); 490 } 491}); 492 493//Zone vidéo - Scroll les thumbnails 494function scrollVideoThumb(direction) { 495 var scrollDistance = $(".thumbnails-videos-to-move").height() * 0.80; 496 if ($( document ).width() < 768 || $(".thumbnails-videos-to-move").parents('.col-md-7').length) { 497 if (direction == "haut") { 498 $(".thumbnails-videos-to-move").stop().animate({scrollLeft: "-=" + scrollDistance}, 888, "easeOutCubic"); 499 } else { 500 $(".thumbnails-videos-to-move").stop().animate({scrollLeft: "+=" + scrollDistance}, 888, "easeOutCubic"); 501 } 502 } else { 503 if (direction == "haut") { 504 $(".thumbnails-videos-to-move").stop().animate({scrollTop: "-=" + scrollDistance}, 888, "easeOutCubic"); 505 } else { 506 $(".thumbnails-videos-to-move").stop().animate({scrollTop: "+=" + scrollDistance}, 888, "easeOutCubic"); 507 } 508 } 509} 510 511//Zone vidéo - Ajout d'un fond bleu pleine largeur 512function zoneVideoBG() { 513 514 if ($( document ).width() < 992 || $(".thumbnails-videos-to-move").parents('.qc-col-md-7').length) { 515 $(".thumbnails-videos").find("ul.d-flex").addClass("flex-row"); 516 $(".thumbnails-videos").find("ul.d-flex").removeClass("flex-column"); 517 var largeurDispo = $(".thumbnails-videos").width(); 518 var largeurBesoin = $('.thumbnails-videos-to-move')[0].scrollWidth; 519 520 if (largeurBesoin > largeurDispo) { 521 $(".thumbnails-videos-scroll-haut").removeClass("displayNone"); 522 $(".thumbnails-videos-scroll-bas").removeClass("displayNone"); 523 } else { 524 $(".thumbnails-videos-scroll-haut").addClass("displayNone"); 525 $(".thumbnails-videos-scroll-bas").addClass("displayNone"); 526 } 527 } else { 528 $(".thumbnails-videos").find("ul.d-flex").addClass("flex-column"); 529 $(".thumbnails-videos").find("ul.d-flex").removeClass("flex-row"); 530 var hauteurDispo = $(".thumbnails-videos").parent().height(); 531 var hauteurBesoin = $('.thumbnails-videos-to-move')[0].scrollHeight; 532 var hauteurMax = $('.thumbnails-videos-to-move').css("max-height").replace("px", ""); 533 534 if (hauteurDispo > hauteurBesoin && hauteurMax > hauteurBesoin) { 535 $(".thumbnails-videos-scroll-haut").addClass("displayNone"); 536 $(".thumbnails-videos-scroll-bas").addClass("displayNone"); 537 $(".thumbnails-videos").addClass("thumbnails-videos-bottom"); 538 $("#conteneurVideos-js").addClass("zone-videos-bottom"); 539 } else { 540 $(".thumbnails-videos-scroll-haut").removeClass("displayNone"); 541 $(".thumbnails-videos-scroll-bas").removeClass("displayNone"); 542 $(".thumbnails-videos").removeClass("thumbnails-videos-bottom"); 543 $("#conteneurVideos-js").removeClass("zone-videos-bottom"); 544 } 545 } 546 var positionZone = $(".frame-zoneVideos").offset().top - $( "#conteneurVideos-js" ).closest( "#main" ).offset().top; 547 var positionBG = positionZone + 33; 548 var longueurBG = $(".frame-zoneVideos").height() + positionZone; 549 var couleurBG = "#dae6f0"; 550 longueurBG = longueurBG - 24; 551 552 if (typeof couleurBGCampagneDoktype != 'undefined') { 553 couleurBG = couleurBGCampagneDoktype; 554 } 555 556 //Si dans une page de campagne, utiliser la couleur du fond des vidéos. 557 if( $('.videoCampagne').length ) 558 couleurBG = $("<div>").appendTo("body").addClass("videoCampagne").css("background-color"); 559 $( "#conteneurVideos-js" ) 560 .closest( "#main" ) 561 .removeClass( "videoCampagne" ) 562 .css( "background", "linear-gradient(white 0px, white " +positionBG+ "px, " +couleurBG+ " " +positionBG+ "px, " +couleurBG+ " " +longueurBG+ "px, white " +longueurBG+ "px)" ); 563 564} 565 566$("form .submit").addClass("displayNone"); 567$(window).scroll(function(){ 568 var distanceBas = 1000; 569 // Seulement pour le mobile 570 if($(window).innerWidth() <= 767) { 571 distanceBas = 1700; 572 } 573 toScroll = $(document).height() - $(window).height() - distanceBas; 574 if ( $(this).scrollTop() > toScroll ) { 575 $(".grecaptcha-badge").addClass("displayBlock"); 576 }else{ 577 $(".grecaptcha-badge").removeClass("displayBlock"); 578 } 579}); 580$(window).on('load',function(){ 581 $("form .submit").removeClass("displayNone"); 582 /* $(".grecaptcha-badge").addClass("displayNone");*/ 583}) 584 585/* Cacher et montrer les champs du formulaire de bas de page */ 586if($("form .powermail_fieldwrap_commentpage")){ 587 /* Ajouter le aria-describedby au commentaire de bas de page pour le textarea */ 588 $(".powermail_fieldwrap_commentpage #infoMaxCaracteres").removeAttr("aria-hidden"); 589 $(".powermail_fieldwrap_commentpage #powermail_field_commentpage").attr("aria-describedby","infoMaxCaracteres"); 590 $("form input[name='tx_powermail_pi1[field][pageutile]']").click(function (event) { 591 $("form .powermail_fieldwrap_commentpage").addClass("displayBlock"); 592 $(".powermail_fieldwrap_soumettrebaspage input[type='submit']").addClass("displayBlock"); 593 $("#formBasPageCommentaire .powermail_submit").addClass("displayBlock"); 594 $(".formBasPage .powermail_fieldwrap_zoneinformationjs").addClass("displayBlock"); 595 if(typeof hideAvis == 'undefined'){ 596 $(".powermail_fieldwrap_servicesquebecform").addClass("displayFlex"); 597 } 598 }); 599} 600 601// Ajoute le noms des fichiers à téléverser sous le bouton "Télécharger" 602$(":file").change(function() { 603 listeFichierSpan = $(this).next('.btnFile').next('.fichiersEnCours'); 604 if($(this).next('.btnFile').next('span').next('.fichiersEnCours').length){ 605 listeFichierSpan = $(this).next('.btnFile').next('span').next('.fichiersEnCours'); 606 } 607 listeFichierSpan.html(""); 608 textLangCache = "Fichiers téléversés :"; 609 if(document.documentElement.lang=="en"){ 610 textLangCache = "Uploaded files :"; 611 } 612 var i = listeFichierSpan.clone(); 613 var arrFiles = $(this)[0].files; 614 var file = ""; 615 $.each(arrFiles, function( index, value ) { 616 file = file+value.name+", "; 617 }); 618 file = file.slice(0, -2); 619 listeFichierSpan.append("<span class='visuallyHidden'>"+textLangCache+"</span>"+file); 620}); 621 622// Renvoie un booléen sur l'existence d'un attribut 623function attributeExiste(id, nameAttr){ 624 var attr = $("#"+id).attr(nameAttr); 625 var boolAttr = false;
626 if (typeof attr !== typeof undefined && attr !== false) { 627 boolAttr = true; 628 } 629 return boolAttr; 630}; 631 632// Renvoie le id de l'erreur 633function getErrorId(idField){ 634 switch ($("#"+idField).attr('type')) { 635 case 'radio': 636 errorId = $("#"+idField).closest('.powermail_fieldwrap_type_radio fieldset .flex-radio') 637 .children('.powermail_field_error_container') 638 .children('ul').attr('id'); 639 break; 640 case 'checkbox': 641 errorId = $("#"+idField).closest('.powermail_fieldwrap_type_check fieldset .checkboxGroup') 642 .children('.powermail_field_error_container') 643 .children('ul').attr('id'); 644 break; 645 default: 646 errorId = $("#"+idField).next('ul').attr('id'); 647 } 648 return errorId; 649}; 650 651// Renvoie si le champ est un btn radio/checkbox ou pas 652function getBtnRadioCheckBox(idField){ 653 switch ($("#"+idField).attr('type')) { 654 case 'radio': 655 radioBtnCheckBox=1; 656 break; 657 case 'checkbox': 658 radioBtnCheckBox=1; 659 break; 660 default: 661 radioBtnCheckBox=0; 662 } 663 return radioBtnCheckBox; 664}; 665// Ajouter des listeners aux boutons du slider des onglets 666function ajouterListenertabSlider($slick_slider) { 667 $(".slick-prev").on('click', function () { 668 $(this).next(".slick-list").find(".slick-track .slick-active a").focus(); 669 var $focused = $(':focus'); 670 $(".nav-link").removeClass("slick-tab-focused"); 671 $focused.addClass("slick-tab-focused") 672 }); 673 $(".slick-next").on('click', function () { 674 $(this).prev(".slick-list").find(".slick-track .slick-active a").focus(); 675 var $focused = $(':focus'); 676 $(".nav-link").removeClass("slick-tab-focused"); 677 $focused.addClass("slick-tab-focused"); 678 }); 679 $(".slick-list a").on('click', function () { 680 var partieCommuneIdCacher = $(this).attr("aria-controls").slice(0, -2); 681 682 $(this).parents(".slick-list").find("a").removeClass("active"); 683 $(this).addClass("active"); 684 685 $(this).parents(".slick-list").find("a").attr("aria-selected", "false"); 686 $(this).attr("aria-selected", "true"); 687 688 $("div[id^='" + partieCommuneIdCacher + "']").removeClass("show active"); 689 $("#" + $(this).attr("aria-controls")).addClass("show active"); 690 691 var slideno = $(this).attr('id'); 692 var arrSlideno = slideno.split("-"); 693 var noSlide = arrSlideno[2].substring(3); 694 // console.log("Slide "+noSlide - +1); 695 $(this).parents(".slick-list").find("a").removeClass("slick-tab-focused"); 696 $(this).addClass("slick-tab-focused"); 697 698 $(this).parents("ul.slick-slider").slick('slickGoTo', noSlide - 1); 699 700 }); 701} 702// ajouter des attributs sur certaines balises pour rendre le slider des onglets plus accessible 703function ajouterAttributAccessibilite(){ 704 $(".slick-slide li").attr("style",""); 705 $(".slick-slide").attr("aria-label",""); 706 $(".slick-slide").attr("aria-hidden",""); 707 $(".slick-slider").addClass("nav nav-tabs"); 708 $(".nav-tabs").attr("role","tablist"); 709 $(".slick-prev").attr("style",""); 710}; 711// fonction pour vérifier que l'onglet est plus court que la zone 712function tabWidth(){ 713 var elementsLi = $(".slick-slide"); 714 $(".slick-list").removeClass("tabsMaxHeight"); 715 716 for (var i = 0; i < elementsLi.length; i++) { 717 var parentUl = elementsLi[i].closest(".slick-list"); 718 maxWidth = parentUl.offsetWidth - 40; 719 if(elementsLi[i].offsetWidth >= maxWidth){ 720 $(parentUl).addClass("tabsMaxHeight"); 721 $(parentUl).find("li").css('max-width',maxWidth - 40+"px"); 722 } 723 }; 724}; 725// Afficher les onglets avec un slider 726function afficherSliderOnglets($slick_slider,settings) { 727 $slick_slider.each(function() { 728 // Si la liste d'onglets est plus longue que la zone visible 729 if(isOverflowing(this)==true){ 730 // Si les onglets n'ont pas déjà le slider, on l'ajoute 731 if($(this).children(":first").hasClass("nav-item") == true) $(this).slick(settings); 732 }else{ 733 // Si la liste d'onglets est plus courte que la zone visible et qu'il y avait déjà le slider, on l'enlève. 734 if($(this).hasClass('slick-initialized')) $(this).slick('unslick'); 735 } 736 }); 737} 738// Valider si la liste des onglets est plus large que la zone déterminée 739function isOverflowing(element) { 740 var childrenWidth = 0; 741 // On additionne la largeur de chaque onglet 742 $(element).find('.nav-item').each(function( index ) { 743 childrenWidth += this.offsetWidth; 744 }); 745 // On renvoit true/false seulon la largeur total des onglets et la largeur de la zone visible 746 return (childrenWidth > element.offsetWidth); 747} 748 749// Navigation par clavier pour le onglets (flèches) 750function keydownEventListenerTabs (event) { 751 // Déclaration des variables pour les touches et les onglets en début/fin de liste 752 let key = event.keyCode, gauche, droite, premier, dernier; 753 // Si le slider existe 754 if (isOverflowing($(this).parents("ul.nav-tabs")[0]) == true) { 755 gauche = $(this).parents(".slick-slide").prev().find("div li a"); 756 droite = $(this).parents(".slick-slide").next().find("div li a"); 757 premier = $(this).parents(".slick-track").find("div.slick-slide:first-child").find("li a"); 758 dernier = $(this).parents(".slick-track").find("div.slick-slide:last-child").find("li a"); 759 }else{ 760 // S'il n'y a pas de slider, juste les onglets 761 gauche = $(this).parent().prev().find("a"); 762 droite = $(this).parent().next().find("a"); 763 premier = $(this).parents("ul.nav-tabs").find("li:first-child").find("a"); 764 dernier = $(this).parents("ul.nav-tabs").find("li:last-child").find("a"); 765 } 766 // Ajuster le focus selon la touche du clavier et l'emplacement dans la liste des onglets 767 switch (key) { 768 //Gauche 769 case 37:
770 (gauche.text() != "") ? gauche.focus() : dernier.focus(); 771 break; 772 //Droite 773 case 39: 774 (droite.text() != "") ? droite.focus() : premier.focus(); 775 break; 776 }; 777}; 778 779// Fonction permettant d'ajuster la hauteur de toutes les tuiles d'un même conteneur 780function zoneTuilesMemeHauteur(){ 781 $('.tuiles-section').each(function() { 782 var hauteurMax=0; 783 $(this).find(".tuiles-liste li").height("auto"); 784 $(this).find(".tuiles-liste li").each(function() { 785 hauteurMax = $( this ).height() > hauteurMax ? $( this ).height() : hauteurMax; 786 }); 787 $(this).find(".tuiles-liste li").height(hauteurMax); 788 }); 789}; 790 791// affichage de l'onglet qui correspond au hash de l'url 792window.addEventListener("load", (event) => { 793 var hash = location.hash; 794 if (hash) { 795 $('.nav-tabs ' + hash).tab('show'); 796 } 797 798 // Change hash for page-reload 799 $('.nav-tabs a').on('shown.bs.tab', function (e) { 800 location.hash = '#' + this.id; 801 }) 802}) 803 804// fusion des notes de bas de page 805window.addEventListener("load", e => { 806 document.querySelectorAll('.list-notes-bas-page').forEach(container => { 807 let notesStack = {}; 808 809 //On ne cherche les notes que dans ce conteneur précis 810 container.querySelectorAll("li.note-bas-page").forEach(noteLi => { 811 let text = noteLi.querySelector("span:not(.note-bas-page-num)").innerHTML; 812 let previousSameNote = Object.entries(notesStack).filter(([k,v]) => v == text)[0] ?? false; 813 814 if (previousSameNote) { 815 let link = noteLi.querySelector("span.note-bas-page-num"), 816 previousId = previousSameNote[0], 817 previousSameNoteLi = document.getElementById(previousId), 818 previousLink = previousSameNoteLi.querySelector("span.note-bas-page-num"), 819 previousSRText = previousSameNoteLi.firstElementChild, 820 id = noteLi.id, 821 currentNum = id.split("-")[1], 822 conjonction = document.documentElement.lang === "fr" ? " et " : " and "; 823 824 previousSRText.textContent = 825 previousSRText.textContent 826 .replace("note","notes") 827 .replace(conjonction, ",") 828 + conjonction + currentNum; 829 830 previousLink.parentNode.insertBefore(link, previousLink); 831 noteLi.remove() 832 link.id = id 833 } 834 else { 835 notesStack[noteLi.id] = text; 836 } 837 838 }) 839 840 // Affichage du conteneur 841 container.classList.add("show-and-expand"); 842 }) 843 // console.log("notesStack",notesStack) 844} ) 845
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.