1/** 2 * @file 3 * Atout France - Tourisme durable behaviors. 4 */ 5 6if(window.location.hostname =='dev.francetourismedurable.gouv.fr') { 7 var obj = document.createElement('DIV'); 8 obj.id="tailleecran" 9 obj.innerHTML = 'taille écran : ' + screen.width + " x " + screen.height; 10 document.querySelector(".fr-footer__bottom-copy").append( obj ); 11} 12 13(function (Drupal, $) { 14 15 'use strict'; 16 17 Drupal.behaviors.atftd = { 18 attach (context, settings) { 19 var selects = document.querySelectorAll('select[data-select-a11y]'); 20 var selectA11ys = Array.prototype.map.call(selects, function(select){ 21 new Select(select) 22 }); 23 // SCROLL TO TOP 24 var btn = $('#scroll-to-top'); 25 $(window).scroll(function () { 26 if ($(window).scrollTop() > 100) { 27 btn.addClass('show'); 28 } 29 else { 30 btn.removeClass('show'); 31 } 32 }); 33 34 35 36 37 // ATF 38 function createAnchorFromH2(h2Element) { 39 const text = h2Element.textContent; 40 const sanitizedText = text 41 .normalize("NFD") 42 .replace(/[\u0300-\u036f]/g, "") 43 .replace(/[^a-zA-Z0-9 -]/g, "") 44 .trim() 45 .replace(/ /g, " ") 46 .replace(/ /g, "-") 47 .toLowerCase(); 48 return sanitizedText; 49 } 50 51 // SOMMAIRE 52 //let itemSommaire = 0; 53 let markupSommaire = ''; 54 if ($('article > nav.sommaire').length > 0 && $('article > nav.sommaire > ol > li').length == 0) { 55 $('article > div.content > div.body > h2, .fr-page-content h2').each(function (){ 56 //itemSommaire++; 57 //let id = 'itemSommaire' + itemSommaire; 58 let id = createAnchorFromH2(this); 59 60 $(this).prop('id', id); 61 $(this).prop('tabindex', "-1"); 62 let itemSommaireText = $(this).text(); 63 if (itemSommaireText === '') { 64 markupSommaire += ''; 65 } 66 else { 67 markupSommaire += "<li><a href='#" + id + "' class='fr-summary__link'>" + itemSommaireText + "</a></li>"; 68 } 69 }); 70 $('article > nav.sommaire').find('ol.fr-summary__list').append(markupSommaire); 71 } 72 73 $(document).ready(function () { 74 if ($(this).find('.splide').length > 0) { 75 var splide = new Splide('.splide', { 76 type: 'loop', 77 perPage: 3, 78 perMove: 1, 79 pagination: false, 80 autoWidth: true, 81 focus: 'center', 82 padding: { left: '3rem', right: '3rem' }, 83 gap: '4rem', 84 breakpoints: { 85 768: { 86 perPage: 1, 87 } 88 } 89 }); 90 splide.mount(); 91 } 92 if (window.innerWidth < 768 && $('article > nav.sommaire').length > 0) { 93 document.getElementById('fr-summary-title').setAttribute('aria-expanded', 'false'); 94 } 95 96 }); 97 98 document.addEventListener('DOMContentLoaded', function() { 99 // Switch theme. 100 // Select all radios groupe fr-radios-theme 101 var radioButtons = document.querySelectorAll('input[name="fr-radios-theme"]'); 102 // Add change event for each radio 103 radioButtons.forEach(function(radioButton) { 104 radioButton.addEventListener('change', function() { 105 document.documentElement.setAttribute('data-fr-theme', this.value); 106 }); 107 }); 108 109 // Navigation par onglet dans le compte utilisateur 110 document.querySelectorAll(".user-tab-menu") 111 .forEach(tabItem => { 112 tabItem.addEventListener("click", function(e){ 113 e.preventDefault(); 114 e.stopPropagation(); 115 // Declare all variables 116 var i, tabcontent, tablinks; 117 118 // hide all 119 tabcontent = document.getElementsByClassName("page-user-item"); 120 for (i = 0; i < tabcontent.length; i++) { 121 tabcontent[i].classList.remove('show'); 122 } 123 124 // Desactive all links 125 tablinks = document.getElementsByClassName("user-tab-menu"); 126 for (i = 0; i < tablinks.length; i++) { 127 tablinks[i].classList.remove('fr-sidemenu__item--active'); 128 tablinks[i].removeAttribute('aria-current'); 129 } 130 131 // Show the current tab, and add an "active" class to the link that opened the tab 132 document.getElementById(this.getAttribute('data-target')).classList.add('show'); 133 this.classList.add('fr-sidemenu__item--active'); 134 this.setAttribute("aria-current", "page"); 135 }); 136 }); 137 $('.views-exposed-form #edit-sort-order').change(function() { 138 // Submit form onChange sort 139 $(this).parents('form').submit(); 140 }); 141 }); 142 $('select[name="field_secteur_activite"] option:not(:contains("-"))').addClass('parent-term-activity'); 143 } 144 }; 145 146} (Drupal, jQuery)); 147 148 149 150 151/* DPM - add bt close action */ 152(function (Drupal, once) { 153 Drupal.behaviors.closableMessages = { 154 attach: function (context) { 155 once('closableMessages', '.messages', context).forEach(function (message) { 156 // Create the close button. 157 var closeBtn = document.createElement('button'); 158 closeBtn.setAttribute('type', 'button'); 159 closeBtn.classList.add('message-close'); 160 closeBtn.setAttribute('aria-label', 'Close message'); 161 closeBtn.innerHTML = 'Ã'; // cross icon 162 163 // Insert the button at the start of the message. 164 message.insertBefore(closeBtn, message.firstChild); 165 166 // Click handler: hide/remove the message. 167 closeBtn.addEventListener('click', function () { 168 message.remove(); 169 }); 170 }); 171 } 172 }; 173})(Drupal, once);
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.