1/** 2 * @file 3 * Theme javascript. 4 */ 5(function ($) { 6 "use strict"; 7 8 Drupal.behaviors.backToTop = { 9 attach: function () { 10 const btt = document.getElementById('back-to-top'); 11 let memo = false; 12 13 if (!(btt !== null && typeof btt !== 'undefined' && btt.length > 0)) { 14 return; 15 } 16 17 btt.addEventListener('click', () => { 18 btt.classList.remove('visible'); 19 window.scrollTo({ 20 top: 0, 21 left: 0, 22 behavior: 'smooth' 23 }); 24 }); 25 26 window.addEventListener('scroll', () => { 27 if(window.scrollY === 0 && memo) { 28 memo = false; 29 btt.classList.remove('visible'); 30 } else if(!memo) { 31 memo = true; 32 btt.classList.add('visible'); 33 } 34 }); 35 36 window.addEventListener('load', () => { 37 if(window.scrollY !== 0) { 38 memo = true; 39 btt.classList.add('visible'); 40 } 41 }); 42 } 43 }; 44 45 Drupal.behaviors.commonExternalLink = { 46 attach: function (context, settings) { 47 $('a', context).each(function () { 48 let href = this.href; 49 if (href === '#') { 50 return; 51 } 52 53 let match = href.match(/^.*\.([a-z0-9]+)$/i); 54 if (match != null) { 55 $(this).attr('target', '_blank').attr('rel', 'noopener'); 56 } 57 58 if (Drupal.url.isLocal(href) === true) { 59 return; 60 } 61 62 // Les liens vers des domaines differents sont ouverts dans une 63 // nouvelle fenêtre, sauf pour ceux ayant déjà un attribut target. 64 if ($(this).attr('target') && $(this).attr('target') != '_blank') { 65 return; 66 } 67 68 $(this).attr('target', '_blank').attr('rel', 'noopener'); 69 let title = $(this).prop("innerText"); 70 $(this).attr('title', title.trim() + Drupal.t(' - ouverture dans un nouvel onglet')).attr('rel', 'noopener'); 71 $(this).addClass('external-website'); 72 73 let positionFacebook = $(this).attr('href').search('facebook'); 74 if (positionFacebook > 0) { 75 $(this).addClass('facebook'); 76 } 77 let positionTwitter = $(this).attr('href').search('twitter'); 78 if (positionTwitter > 0) { 79 $(this).addClass('twitter'); 80 } 81 82 }); 83 } 84 }; 85 86 Drupal.behaviors.mobileMenu = { 87 attach: function (context, settings) { 88 let navBurger = $('header .navburger', context); 89 navBurger.on('click', function () { 90 if ($(this).parent().hasClass('active')) { 91 $('html').removeClass('menu'); 92 } else { 93 $('html').addClass('menu').scrollTop(0); 94 $(this).parent().addClass('closing'); 95 } 96 $(this).parent().toggleClass('active closing'); 97 $(this).next('.region-header').slideToggle({ 98 duration: 300, 99 start: function () { 100 jQuery(this).css('display', 'flex'); 101 } 102 }); 103 $(this).next('.region-header').find('.header_sub').css('left', '100%').delay(400).fadeOut(0); 104 $(this).next('.region-header').find('.link-lvl3').css('left', '100%').delay(300).fadeOut(0); 105 $(this).next('.region-header').find('.link-lvl4 .link-lvl4').css('left', '100%').delay(200).fadeOut(0); 106 }); 107 } 108 }; 109 110 Drupal.behaviors.subMenu = { 111 attach: function (context, settings) { 112 const $subMenu = $('header #block-rsfmenuprincipalblock .header_nav-items > .item-list > ul > li', context); 113 const desktopWidth = 992; 114 115 if (!$('header').children('.header_sub-overlay').length) { 116 $('header').prepend('<div class="header_sub-overlay"></div>'); 117 } 118 119 $subMenu.each(function () { 120 let $subMenuFirstItem = $(this).find('>span'); 121 let $subMenuItem = $(this).find('.header_sub span.with-sublinks'); 122 let $linkLvl2 = $(this).find('.header_sub .link-lvl2'); 123 let $headerMea = $(this).find('.header_sub .header_mea'); 124 125 $subMenuFirstItem.on('keypress click', function (e) { 126 127 if (e.which === 13 || e.type === 'click') { 128 if ($(window).width() < desktopWidth) { 129 let $subMenuIteamHeader = $(this).next().find('.header_sub-left'); 130 if (!$subMenuIteamHeader.children('.header_sub-back').length) { 131 $subMenuIteamHeader.prepend('<div class="header_sub-back"></div>'); 132 } 133 $('.header_sub-overlay').hide(); 134 $(this).next().toggle({ 135 duration: 0, 136 start: function () { 137 $(this).css('left', '0'); 138 } 139 }); 140 $(this).next().find('.header_sub-back').on('click', function () { 141 $(this).parent().parent().css('left', '100%').delay(200).fadeOut(0); 142 }); 143 } else { 144 if ($(this).parent().hasClass('active')) { 145 $subMenu.removeClass('active'); 146 $subMenu.find('.header_sub').fadeOut(150).css('z-index', '0'); 147 $('html').removeClass('menu'); 148 } else { 149 $subMenu.removeClass('active'); 150 $('html').addClass('menu').scrollTop(0); 151 $(this).parent().addClass('active'); 152 $('header #block-rsfmenuprincipalblock .header_nav-items > .item-list > ul > li:not(.active)') 153 .find('.header_sub').css('z-index', '0').delay(100).fadeOut(150); 154 $(this).next('.header_sub').fadeIn({ 155 duration: 100, 156 start: function () { 157 jQuery(this).css({ 158 display: 'flex', 159 'z-index': '2' 160 }); 161 } 162 }); 163 } 164 } 165 } 166 }); 167 168 var debounce = null; 169 170 $subMenuItem.on('keypress click mouseenter', function (e) { 171 let $subMenuIteamHeader = $(this).next().find('.header_sub-left'); 172 173 if ($(window).width() < desktopWidth) { 174 if (e.which === 13 || e.type === 'click') { 175 if (!$subMenuIteamHeader.length) { 176 $(this).next().prepend('<div class="header_sub-left"><div class="header_sub-back"></div><div class="title"></div></div>'); 177 $(this).clone().prependTo($(this).next().find('.header_sub-left .title')).find('.with-sublinks').removeClass('.with-sublinks'); 178 } 179 $headerMea.fadeIn(); 180 $(this).next().toggle({ 181 duration: 0, 182 start: function () { 183 $(this).css('left', '0'); 184 } 185 }); 186 $(this).next().find('.header_sub-back').on('click', function () { 187 $(this).parent().parent().css('left', '100%').delay(400).fadeOut(0); 188 }); 189 } 190 } else { 191 clearTimeout(debounce); 192 if (e.which === 13 || e.type === 'mouseenter') { 193 const $this = $(this); 194 debounce = setTimeout(function () { 195 if (!$this.parent().hasClass('active')) { 196 $this.parent().parent().children().removeClass('active').children('span').next().fadeOut(50); 197 $this.parent().addClass('active'); 198 $this.next().fadeIn(200); 199 } else { 200 $this.parent(':not(.active)').removeClass('active').children('span').next().fadeOut(50); 201 } 202 if ($linkLvl2.hasClass('active')) { 203 $headerMea.fadeOut(50); 204 } else { 205 $headerMea.fadeIn(200); 206 } 207 }, 150); 208 } 209 } 210 }); 211 212 $('.header_sub-overlay').on('click', function () { 213 $subMenu.removeClass('active').find('.header_sub').fadeOut(200); 214 $('html').removeClass('menu'); 215 }); 216 }); 217 } 218 }; 219 220 Drupal.behaviors.searchHeader = { 221 attach: function (context, settings) { 222 let search = $('header #block-rsfformulaireverslarecherche', context);
223 let searchWrapper = search.children('#search_form_display'); 224 const desktopWidth = 992; 225 226 if ($(window).width() < desktopWidth) { 227 $('.header-wrapper').append('<div class="search-loop"></div>'); 228 } 229 230 let searchBtn = $('.search-loop'); 231 232 searchBtn.on('click', function () { 233 $('html').toggleClass('search'); 234 searchWrapper.fadeToggle(200); 235 }); 236 237 $('header .header_sub-overlay').on('click', function () { 238 $('html').removeClass('search'); 239 searchWrapper.fadeOut(100); 240 if ($(window).width() < desktopWidth) { 241 $('.region-header').hide(); 242 } 243 }); 244 } 245 }; 246 247 Drupal.behaviors.switchLanguage = { 248 attach: function (context, settings) { 249 250 const language = once('rsf-languageswitcher', '#block-selecteurdelangue', context); 251 language.forEach((element) => { 252 let languageMenu = $(element).children('.links'); 253 $(element).prepend('<span>' + $('html')[0].lang + '</span>'); 254 255 $(element).on('click', function (event) { 256 event.stopPropagation(); 257 $(this).children('ul').fadeToggle(); 258 }); 259 260 $('body').on('click', function (e) { 261 if (!languageMenu.is(e.target) && languageMenu.parent().has(e.target).length === 0 && $(element).has(e.target).length === 0) { 262 languageMenu.fadeOut(); 263 } 264 }); 265 }); 266 } 267 }; 268 269 Drupal.behaviors.twitterAll = { 270 attach: function (context, settings) { 271 272 let wrapper = $('.wrapper-twitter', context); 273 274 wrapper.each(function () { 275 $(this).find('.link-twitter').on('click', function (event) { 276 event.stopPropagation(); 277 $(this).toggleClass('active').next().fadeToggle(); 278 }); 279 280 }); 281 282 $('body').on('click', function (e) { 283 if (!wrapper.is(e.target) && wrapper.has(e.target).length === 0 && wrapper.has(e.target).length === 0) { 284 wrapper.find('.link-twitter').removeClass('active').next().fadeOut(); 285 } 286 }); 287 288 } 289 }; 290 291 Drupal.behaviors.paragraphAccordeon = { 292 attach: function (context, settings) { 293 294 let accordeon = $('.element_accordeon, .element-accordeon', context); 295 296 accordeon.each(function () { 297 $(this).children('.field--name-title').on('click', function () { 298 $(this).toggleClass('active').next().slideToggle(); 299 }); 300 }); 301 } 302 }; 303 304 Drupal.behaviors.monthPicker = { 305 attach: function (context, settings) { 306 307 let monthPicker = $('.wrapper-date>.js-form-item', context); 308 309 monthPicker.each(function () { 310 $(this).append('<div class="month-picker"><select></select><ul class="month"></ul></div>'); 311 let input = $(this).children('input'); 312 let select = $(this).find('select'); 313 let month = $(this).find('.month'); 314 let minYear = 2010; 315 let years = ''; 316 let today = new Date(); 317 let todayMonth = String(today.getMonth() + 2); 318 let todayYear = today.getFullYear(); 319 const months = Array.from({length: 12}, (e, i) => { 320 return '<li>' + new Date(null, i + 1, null).toLocaleDateString('default', {month: "short"}) + '<span>' + new Date(null, i + 1, null).toLocaleDateString('default', {month: "2-digit"}) + '</span></li>'; 321 }); 322 323 // Rule date min for year select. 324 if (input.attr("date-min")) { 325 minYear = input.attr("date-min"); 326 } 327 328 for (var i = minYear; i <= new Date().getFullYear(); i++) { 329 years += '<option value="' + i + '">' + i + '</option>'; 330 } 331 332 select.html(years); 333 month.html(months); 334 335 // InputDisplay, different format view for I18N. 336 let inputVal = input.val(); 337 let inputDisplayYear = inputVal.substring(0, 4); 338 let inputDisplayMonth = inputVal.slice(inputVal.length - 2); 339 input.hide().after('<div class="input-month-picker"></div>'); 340 let inputDisplay = input.next('.input-month-picker'); 341 if (inputVal.length) { 342 inputDisplay.text(inputDisplayMonth + '.' + inputDisplayYear); 343 } else { 344 if ($(this).hasClass('form-item-date-publication-min')) { 345 inputDisplay.text('01.' + minYear); 346 input.val(minYear + '-01'); 347 } 348 if ($(this).hasClass('form-item-date-publication-max')) { 349 let dMonth = String(today. getMonth() + 1). padStart(2, '0'); 350 inputDisplay.text(dMonth + '.' + todayYear); 351 input.val(todayYear + '-' + dMonth); 352 } 353 } 354 355 // input on click 356 inputDisplay.on("click", function (event) { 357 event.stopPropagation(); 358 $('.month-picker').fadeOut(); 359 $(this).parent().find('.month-picker').fadeIn(); 360 361 // d-date max month 362 select.on('change', function () { 363 month.find('li').removeClass('disabled'); 364 if ($(this).find(":selected").text() == todayYear) { 365 month.find('li').removeClass('disabled'); 366 month.find('li:nth-child(n+' + todayMonth + ')').addClass('disabled'); 367 } 368 }).trigger('change'); 369 370 // min date for max date 371 if ($(this).parent().hasClass("js-form-item-date-publication-max") && !$('.js-form-item-date-publication-min input').val()) { 372 $(this).next().find('select option[value="' + todayYear + '"]').attr('selected', 'selected'); 373 month.find('li').removeClass('disabled'); 374 month.find('li:nth-child(n+' + todayMonth + ')').addClass('disabled'); 375 } 376 377 // max date, change select and month select with min date 378 if ($(this).parent().hasClass("js-form-item-date-publication-max") && $('.js-form-item-date-publication-min input').val()) { 379 let minDate = $('.js-form-item-date-publication-min').children('input').val(); 380 let minYear = minDate.substring(0, 4); 381 let year = $(this).val().substring(0, 4); 382 let minMonth = minDate.slice(minDate.length - 2) - 1; 383 let newYears = ''; 384 385 for (var i = minYear; i <= new Date().getFullYear(); i++) { 386 newYears += '<option value="' + i + '">' + i + '</option>'; 387 } 388 389 select.empty(); 390 select.html(newYears); 391 select.children().removeAttr('selected'); 392 $(this).next().find('select option[value="' + year + '"]').attr('selected', 'selected'); 393 394 select.on('change', function () { 395 if ($(this).find(":selected").text() == minYear) { 396 month.find('li').removeClass('disabled'); 397 month.find('li:nth-child(-n+' + minMonth + ')').addClass('disabled'); 398 } 399 }).trigger('change'); 400 } 401 402 // if this year is select for max month 403 if (select.children('option').length == 1 && select.children().text() == todayYear) { 404 month.find('li').removeClass('disabled'); 405 month.find('li:nth-child(n+' + todayMonth + ')').addClass('disabled'); 406 } 407 408 // selected option with input val 409 if ($(this).html().length) { 410 $(this).next('.month-picker').find("option[value='" + inputDisplayYear + "']:first").attr("selected","selected"); 411 } 412 }); 413 414 $(this).find('li').on('click', function () { 415 let year = $("option:selected", select).text(); 416 let month = $(this).find('span').text(); 417 monthPicker.find('.month-picker').fadeOut(); 418 input.val( function () { 419 return year + '-' + month; 420 }); 421 inputDisplay.text(month + '.' + year); 422 423 // Rules if min date is taller than max date 424 let minDateDisplayVal = $('.js-form-item-date-publication-min .input-month-picker').text(); 425 let maxDateDisplayVal = $('.js-form-item-date-publication-max .input-month-picker').text(); 426 if (minDateDisplayVal.slice(minDateDisplayVal.length - 4) > maxDateDisplayVal.slice(maxDateDisplayVal.length - 4)) { 427 $('.js-form-item-date-publication-max .input-month-picker').text(''); 428 } 429 }); 430 431 $('body').on('click', function (e) { 432 if (!input.is(e.target) && input.parent().has(e.target).length === 0 && input.parent().find('.month_picker').has(e.target).length === 0) { 433 input.parent().find('.month-picker').fadeOut(); 434 } 435 }); 436 }); 437 } 438 }; 439 440 Drupal.behaviors.selectCustom = { 441 attach: function (context, settings) { 442 443 let selectMultiple = $(".form-select[multiple='multiple']:not(#edit-exaction-victimes-pays, #edit-pays, select[name='pays[]'])", context); 444 445 selectMultiple.each(function () { 446 let label = $(this).prev().text(); 447 let once = false;
448 $(this).SumoSelect({ 449 search: true, 450 searchText: Drupal.t('Rechercher'), 451 placeholder: label, 452 captionFormat: Drupal.t('{0} sélectionnés'), 453 captionFormatAllSelected: Drupal.t('Tous sélectionnés ({0})'), 454 }); 455 456 $(this).on('sumo:opening', function () { 457 let sumoGroup = $(this).nextAll('.optWrapper').first().children(); 458 459 if (sumoGroup.children('.opt.selected').length && !once) { 460 sumoGroup.children('.opt.selected').detach().prependTo(sumoGroup); 461 once = true; 462 } 463 }); 464 }); 465 466 let selectSearch = $(".form-select.with-search", context); 467 468 selectSearch.each(function () { 469 $(this).SumoSelect({search: true, searchText: Drupal.t('Rechercher')}); 470 }); 471 472 const $selectPays = $('#edit-exaction-victimes-pays, #edit-pays, select[name="pays[]"]'); 473 474 $selectPays.each(function () { 475 let label = $(this).prev().text(); 476 $(this).SumoSelect({ 477 search: true, 478 selectAll: true, 479 searchText: Drupal.t('Rechercher'), 480 placeholder: label, 481 captionFormat: Drupal.t('{0} sélectionnés'), 482 captionFormatAllSelected: Drupal.t('Tous sélectionnés ({0})'), 483 locale: [Drupal.t('OK'), Drupal.t('Annulé'), Drupal.t('Tout sélectionner')], 484 }); 485 }); 486 } 487 }; 488 489 Drupal.behaviors.externMenu = { 490 attach: function (context, settings) { 491 492 let menu = $('.extern-menu', context); 493 let navburger = menu.children('.extern-menu__navburger'); 494 495 $(once('extern-menu', navburger, context)).on('click', function (){ 496 $(this).parent().toggleClass('active closing'); 497 $(this).next('.extern-menu__wrapper').slideToggle({ 498 duration: 300, 499 start: function () { 500 jQuery(this).css('display', 'flex'); 501 } 502 }); 503 }); 504 } 505 }; 506 507 Drupal.behaviors.externMenuAnalyses = { 508 attach: function (context, settings) { 509 510 let menu = $('.extern-menu__classement', context); 511 let analyse = menu.find('.analyse-links .analyse-links__title'); 512 let link = analyse.next().children(); 513 514 if (link.hasClass('active')) { 515 analyse.parent().addClass('active'); 516 analyse.next().slideDown(); 517 } 518 519 $(once('extern-menu-analyses', analyse, context)).on('click', function (){ 520 if ($(this).parent().hasClass('active')) { 521 $(this).parent().removeClass('active'); 522 $(this).next().slideUp(); 523 } else { 524 $(this).parent().addClass('active'); 525 $(this).next().slideDown(); 526 } 527 }); 528 } 529 }; 530 531 Drupal.behaviors.switchClassementMapList = { 532 attach: function (context, settings) { 533 534 if (localStorage.getItem("RsfclassementSelectMode") === 'list') { 535 $('.mode-map').removeClass('active'); 536 $('.mode-list').addClass('active'); 537 } 538 539 function switchMapList(type) { 540 let className = $('.mode-' + type); 541 let wrapper = $('.classement-content-wrapper'); 542 543 if (className.hasClass('active')) { 544 wrapper.children().hide(); 545 wrapper.find('.classement-content-' + type).show(); 546 } 547 548 $(once('switch-classement-map-list', className, context)).on('click', function (){ 549 $(this).parent().children().removeClass('active'); 550 $(this).addClass('active'); 551 $(this).parent().siblings('.classement-content-wrapper').children().fadeOut(); 552 $(this).parent().siblings('.classement-content-wrapper').find('.classement-content-' + type).fadeIn(); 553 $(this).parent().siblings('.extern-actions').attr('class', 'extern-actions').addClass(type); 554 }); 555 } 556 557 switchMapList('map'); 558 switchMapList('list'); 559 560 $('.mode-list').on('click', function () { 561 localStorage.setItem('RsfclassementSelectMode', 'list'); 562 }); 563 $('.mode-map').on('click', function () { 564 localStorage.setItem('RsfclassementSelectMode', 'map'); 565 }); 566 567 } 568 }; 569 570 Drupal.behaviors.rsfTableHref = { 571 attach: function (context, settings) { 572 $('tr[data-href]').on("click", function () { 573 document.location = $(this).data('href'); 574 }); 575 } 576 }; 577 578 Drupal.behaviors.rsfTableSort = { 579 attach: function (context, settings) { 580 let table = $('table.js-sortable', context); 581 let th = table.find('thead th'); 582 583 th.click(function () { 584 let table = $(this).parents('table').eq(0); 585 let rows = table.find('tr:gt(0)').toArray().sort(comparer($(this).index())); 586 th.removeClass('active'); 587 $(this).addClass('active'); 588 this.asc = !this.asc; 589 if (!this.asc) { 590 rows = rows.reverse(); 591 $(this).removeClass('up').addClass('down'); 592 } else { 593 $(this).removeClass('down').addClass('up'); 594 } 595 for (var i = 0; i < rows.length; i++) { 596 table.append(rows[i]); 597 } 598 }); 599 600 function comparer(index) { 601 return function (a, b) { 602 let valA = getCellValue(a, index), valB = getCellValue(b, index); 603 return $.isNumeric(valA) && $.isNumeric(valB) ? valA - valB : valA.toString().localeCompare(valB); 604 }; 605 } 606 607 function getCellValue(row, index) { 608 return $(row).children('td').eq(index).text(); 609 } 610 } 611 }; 612 613 Drupal.behaviors.rsfCarrousel = { 614 attach: function (context, settings) { 615 let carrousel = $('.wrapper-carrousel', context); 616 617 function rtl_slick() { 618 let dir = $("html").attr("dir"); 619 if (dir == "rtl") { 620 return true; 621 } else { 622 return false;
623 } 624 } 625 626 carrousel.each(function () { 627 let carrouselView = $(this).attr('data-carrousel-view'); 628 $(this).slick({ 629 infinite: false, 630 slidesToShow: Math.max(2, carrouselView), 631 slidesToScroll: 1, 632 arrows: true, 633 dots: false, 634 rtl: rtl_slick(), 635 adaptiveHeight: false, 636 responsive: [ 637 { 638 breakpoint: 1200, 639 settings: { 640 slidesToShow: Math.max(2, carrouselView - 1), 641 } 642 }, 643 { 644 breakpoint: 1024, 645 settings: { 646 slidesToShow: Math.max(2, carrouselView - 2), 647 } 648 }, 649 { 650 breakpoint: 680, 651 settings: { 652 slidesToShow: Math.max(1, carrouselView - 3), 653 } 654 } 655 ] 656 }); 657 }); 658 659 } 660 }; 661 662 Drupal.behaviors.rsfTableMaxItems = { 663 attach: function (context, settings) { 664 let table = $('.paragraph--type--tableau-pays table', context); 665 let country = table.find('tbody tr'); 666 let country10 = table.find('tbody tr:lt(8)'); 667 668 if (country.length > 7) { 669 table.parent().parent().append('<div class="wrapper-btn"><button class="btn-outline">' + Drupal.t('Afficher tous les pays') + '</button></div>'); 670 country.hide(); 671 country10.show(); 672 673 let btn = table.parent().next('.wrapper-btn').children('.btn-outline'); 674 675 btn.on('click', function () { 676 country.fadeIn(); 677 $(this).parent().remove(); 678 }); 679 } 680 } 681 }; 682 683 Drupal.behaviors.rsfStickyTopBar = { 684 attach: function (context, settings) { 685 let stickyTopBar = 686 $('.page-node-type-article .wrapper-block-sticky,' + 687 '.page-node-type-campagne .wrapper-block-sticky,' + 688 '.page-node-type-petition .wrapper-block-sticky,' + 689 '.page-node-type-interpellation .wrapper-block-sticky,' + 690 '.path-taxonomy .wrapper-block-sticky', context); 691 let stickyMinPos = 300; 692 693 $(window).scroll(function () { 694 // Topbar slide up / down on scroll 695 if ($(window).scrollTop() > stickyMinPos) { 696 stickyTopBar.slideDown(300); 697 } else { 698 stickyTopBar.slideUp(100); 699 } 700 }); 701 } 702 }; 703 704 Drupal.behaviors.rsfStickyLeftBar = { 705 attach: function (context, settings) { 706 let stickyLeftBar = 707 $('.page-node-type-page-froide .wrapper-block-sticky,' + 708 '.page-node-type-site-debloque .wrapper-block-sticky,' + 709 '.page-node-type-initiative .wrapper-block-sticky', context); 710 711 stickyLeftBar.find('.wrapper-sticky-anchors .links > li').slice(1) 712 .wrapAll('<ul class="anchors-menu"></ul>') 713 .parent().before('<li class="anchors-select"></li>'); 714 715 let select = stickyLeftBar.find('.anchors-select'); 716 let menu = stickyLeftBar.find('.anchors-menu'); 717 const desktopWidth = 992; 718 719 // Show active link on mobile 720 function selectName() { 721 let linkActive = menu.find('li a.active').html(); 722 let linkFirst = menu.find('li:first-child a').html(); 723 if (linkActive == undefined) { 724 stickyLeftBar.find('.anchors-select').html('<div>' + linkFirst + '</div>'); 725 } else { 726 stickyLeftBar.find('.anchors-select').html('<div>' + linkActive + '</div>'); 727 } 728 } 729 730 if (stickyLeftBar.length) { 731 let stickyLeftBarPos = stickyLeftBar.offset().top; 732 733 select.on('click', function () { 734 if ($(window).width() < desktopWidth) { 735 select.toggleClass('active'); 736 menu.slideToggle(300); 737 } 738 }); 739 740 menu.find('a').on('click', function () { 741 if ($(window).width() < desktopWidth) { 742 select.removeClass('active'); 743 menu.slideUp(200); 744 } 745 }); 746 747 selectName(); 748 749 $(window).scroll(function () { 750 // LeftBar active on scroll 751 if ($(window).scrollTop() > stickyLeftBarPos + 64) { 752 stickyLeftBar.addClass('sticky'); 753 } else { 754 stickyLeftBar.removeClass('sticky'); 755 } 756 selectName(); 757 }); 758 } 759 } 760 }; 761 762 Drupal.behaviors.rsfAnchor = { 763 attach: function (context, settings) { 764 let wrapperAnchor = $('.wrapper-sticky-anchors', context); 765 let stickyAnchor = wrapperAnchor.find('.links li a'); 766 767 $(window).scroll(function () { 768 // Active link on scroll 769 let scrollPos = $(document).scrollTop(); 770 stickyAnchor.each(function () { 771 let refElement = $($(this).prop("hash")); 772 let refElementTop = refElement.offset().top - 60; 773 774 if (refElementTop <= scrollPos) { 775 stickyAnchor.removeClass("active"); 776 $(this).addClass("active"); 777 } else { 778 $(this).removeClass("active"); 779 } 780 }); 781 }); 782 } 783 }; 784 785 Drupal.behaviors.rsfMobileReadMore = { 786 attach: function (context, settings) { 787 let thematiqueWrapper = $('.path-taxonomy .taxonomy-term .wrapper-content > .wrapper-left > .field--name-field-chapo', context); 788 let thematiqueText = thematiqueWrapper.children('p'); 789 const multiLine = 8; 790 const desktopWidth = 992; 791 792 function thematiqueMobileMaxLine() { 793 let thematiqueLine = (thematiqueText.outerHeight() / 27); 794 795 if ($(window).width() < desktopWidth && thematiqueLine >= multiLine) { 796 if (!thematiqueWrapper.children('.display_more-wrapper').length && !thematiqueWrapper.children('.btn-display-more').length) { 797 thematiqueWrapper.wrapInner('<div class="display_more-wrapper" style="-webkit-line-clamp:' + multiLine + '"></div>'); 798 thematiqueWrapper.append('<button class="btn-display-more cta-leger">' + Drupal.t('Lire plus') + '</button>'); 799 } 800 } else { 801 thematiqueWrapper.children('.btn-display-more').remove(); 802 thematiqueWrapper.find('.display_more-wrapper').children().unwrap(); 803 } 804 805 thematiqueWrapper.children('.btn-display-more').on('click', function () { 806 $(this).prev().children().unwrap(); 807 $(this).remove(); 808 }); 809 } 810 811 thematiqueMobileMaxLine(); 812 813 $(window).on('resize',function () { 814 thematiqueMobileMaxLine(); 815 }); 816 817 } 818 }; 819 820 Drupal.behaviors.rsfMobileFilters = { 821 attach: function (context, settings) { 822 let filtersWrapper = $('.rsf-filters > .rsf-filters__wrapper', context); 823 824 const desktopWidth = 992; 825 826 function showFilters() { 827 if ($(window).width() < desktopWidth) { 828 if (!filtersWrapper.children('.filters').length) { 829 filtersWrapper.wrapInner('<div class="filters" style="display: none;"></div>'); 830 filtersWrapper.prepend('<div class="btn-show-more">' + Drupal.t('Afficher les filtres') + '</div>'); 831 } 832 833 filtersWrapper.children('.btn-show-more').unbind('click').click(function () { 834 if ($(this).hasClass('active')) { 835 $(this).next().slideUp(); 836 $(this).removeClass('active').html(Drupal.t('Afficher les filtres')); 837 } else { 838 $(this).next().slideDown(); 839 $(this).addClass('active').html(Drupal.t('Masquer les filtres')); 840 } 841 }); 842 } else { 843 filtersWrapper.find('.filters').children().unwrap(); 844 filtersWrapper.find('.btn-show-more').remove(); 845 } 846 } 847 848 showFilters(); 849 850 $(window).on('resize',function () { 851 showFilters(); 852 }); 853 854 } 855 }; 856 857 Drupal.behaviors.rsfMobilePetition = { 858 attach: function (context, settings) { 859 let petitionWrapper = $('.page-node-type-petition.en-cours .no
859de--type-petition', context); 860 861 if (petitionWrapper.length) { 862 petitionWrapper.append('<div class="cta-fort btn-mobile-petition">Signer la pétition</div>'); 863 let petitionForm = petitionWrapper.find('.wrapper-main > .wrapper-content > .signature-objectif-wrapper'); 864 let petitionButton = petitionWrapper.children('.btn-mobile-petition'); 865 let petitionVisuel = petitionWrapper.find('.wrapper-inner > .visuel-petition'); 866 let petitionProgressBar = petitionWrapper.find('.petition-salesforce-form > .wrapper-signature'); 867 868 petitionProgressBar.clone().appendTo(petitionVisuel); 869 870 petitionForm.prepend( 871 '<div class="signature-objectif-header">' + 872 '<div class="signature-objectif-title">' + Drupal.t('Signez la pétition') + 873 '</div><i class="signature-objectif-close"></i></div>'); 874 875 petitionButton.on('click', function () { 876 petitionForm.fadeIn({ 877 duration: 300, 878 start: function () { 879 jQuery(this).css('display', 'flex'); 880 } 881 }); 882 $('html').addClass('is-petition'); 883 }); 884 885 let petitionClose = petitionForm.find('.signature-objectif-close'); 886 887 petitionClose.on('click', function () { 888 petitionForm.fadeOut(); 889 $('html').removeClass('is-petition'); 890 }); 891 } 892 } 893 }; 894 895 Drupal.behaviors.rsfPassezAction = { 896 attach: function (context, settings) { 897 let passezAction = $('.passer-action .wrapper-passer-action', context); 898 899 if (typeof passezAction === 'undefined' || passezAction.length == 0) { 900 return; 901 } 902 903 let passezActionTop = passezAction.offset().top; 904 let stickyAnchor = passezAction.find('.wrapper-left .item-list ul li a'); 905 let firstAnchor = passezAction.find('.wrapper-left .item-list ul li:first-child a'); 906 907 $(window).scroll(function () { 908 let scrollPos = $(document).scrollTop(); 909 stickyAnchor.each(function () { 910 let refElement = $($(this).prop("hash")); 911 let refElementTop = refElement.offset().top; 912 913 if ( (passezActionTop + 240) > scrollPos) { 914 firstAnchor.addClass("active"); 915 } 916 917 if (refElementTop <= scrollPos + 300) { 918 stickyAnchor.removeClass("active"); 919 $(this).addClass("active"); 920 } else { 921 $(this).removeClass("active"); 922 } 923 }); 924 }); 925 } 926 }; 927 928 Drupal.behaviors.rsfFilters = { 929 attach: function (context, settings) { 930 let filters = $('.view-filters', context); 931 932 if (filters.length && typeof filters.offset() !== 'undefined') { 933 const filtersTop = filters.offset().top; 934 935 $(window).scroll(function () { 936 if ($(window).scrollTop() >= filtersTop) { 937 filters.addClass('is-sticky'); 938 } 939 else { 940 filters.removeClass('is-sticky'); 941 } 942 }); 943 } 944 } 945 }; 946 947 function isTablet() { 948 return window.matchMedia("(max-width: 73.75em)").matches; 949 } 950 951 function isMobile() { 952 return window.matchMedia("(max-width: 48em)").matches; 953 } 954 955 Drupal.behaviors.iframeHeight = { 956 attach: function (context, settings) { 957 const iframe = $('.media--type-iframe iframe', context); 958 959 if (!iframe.length) { 960 return; 961 } 962 963 function setHeight() { 964 iframe.each(function () { 965 const desktop = $(this).attr('data-desktop-height'); 966 const tablet = $(this).attr('data-tablette-height'); 967 const mobile = $(this).attr('data-mobile-height'); 968 969 let height = '0px'; 970 971 if (isMobile()) { 972 height = mobile + 'px'; 973 } else if (isTablet()) { 974 height = tablet + 'px'; 975 } else { 976 height = desktop + 'px'; 977 } 978 979 $(this).attr('height', height); 980 }); 981 } 982 983 setHeight(); 984 985 $(window).on('resize', function () { 986 setHeight(); 987 }); 988 } 989 }; 990 991 Drupal.behaviors.languageSwitcher = { 992 attach: function (context, settings) { 993 let $switcher = $('.language-switcher-language-url', context); 994 $switcher.find('span').attr('tabIndex', 0); 995 } 996 }; 997 998 Drupal.behaviors.persanSwitcher = { 999 attach: function (context, settings) { 1000 1001 if (document.documentElement.lang !== 'fa') { 1002 return; 1003 } 1004 1005 // Fix for classement Refs #69221. 1006 if ($('body').hasClass('path-classement')) { 1007 return; 1008 } 1009 1010 let persian = { 1011 0:'۰', 1012 1:'۱', 1013 2:'۲', 1014 3:'۳', 1015 4:'۴', 1016 5:'۵', 1017 6:'۶', 1018 7:'۷', 1019 8:'۸', 1020 9:'۹' 1021 }; 1022 1023 function traverseAndChangePersianNumber(el) {
1024 if (el.nodeType == 3) { 1025 let list = el.data.match(/[0-9]/g); 1026 if (list != null && list.length != 0) { 1027 for (var i = 0; i < list.length; i++) { 1028 el.data = el.data.replace(list[i], persian[list[i]]); 1029 } 1030 } 1031 } 1032 for (var j = 0; j < el.childNodes.length; j++) { 1033 traverseAndChangePersianNumber(el.childNodes[j]); 1034 } 1035 } 1036 traverseAndChangePersianNumber(document.body); 1037 } 1038 }; 1039 1040 Drupal.behaviors.regionHighlighted = { 1041 attach: function (context, settings) { 1042 1043 const regionHighlighted = $('.layout-container > .region-highlighted', context); 1044 const numberChild = regionHighlighted.children().length; 1045 1046 if (numberChild >= 2) { 1047 regionHighlighted.addClass('is-visible'); 1048 } else { 1049 regionHighlighted.removeClass('is-visible'); 1050 } 1051 1052 $('.view--recheche-recherche').find('.region-highlighted').removeClass('is-visible'); 1053 } 1054 }; 1055 1056 Drupal.behaviors.premiersSignataires = { 1057 attach: function (context, settings) { 1058 const button = $('.paragraph--type--premiers-signataires .cta-leger'); 1059 const paragraph = $('.paragraph--type--premiers-signataires'); 1060 1061 button.on('click', function () { 1062 paragraph.toggleClass('opened'); 1063 $(this).text($(this).text() == Drupal.t('Afficher tout') ? Drupal.t('Réduire') : Drupal.t('Afficher tout')); 1064 1065 if (!paragraph.hasClass('opened')) { 1066 $('html, body').animate({ 1067 scrollTop: paragraph.offset().top 1068 }, 20); 1069 } 1070 }); 1071 1072 } 1073 }; 1074 1075 Drupal.behaviors.imageCreditPosition = { 1076 attach: function (context, settings) { 1077 const imageCredit = $('.media--view-mode-entete-full .wrapper-footer'); 1078 const wrapperTop = $('.page-node-type-article.article-long-read .wrapper-main>.wrapper-top'); 1079 const articleImage = $('.page-node-type-article.article-long-read .wrapper-main>.media--view-mode-entete-full'); 1080 1081 if ($(window).width() > 976 ) { 1082 wrapperTop.append(imageCredit); 1083 } 1084 1085 $(window).on('resize', function () { 1086 if ($(this).width() > 976 ) { 1087 wrapperTop.append(imageCredit); 1088 } 1089 else if ($(this).width() < 992 ) { 1090 wrapperTop.remove(imageCredit); 1091 articleImage.append(imageCredit); 1092 } 1093 }); 1094 1095 } 1096 }; 1097 1098 Drupal.behaviors.moteurAutoDateRefresh = { 1099 attach: function (context, settings) { 1100 1101 const form = $('.path-recherche .rsf-filters .block-rsf-search-date-block form'); 1102 const dateInput = $('.path-recherche .rsf-filters .block-rsf-search-date-block .input-month-picker'); 1103 1104 dateInput.on('DOMSubtreeModified', function () { 1105 form.submit(); 1106 }); 1107 1108 } 1109 }; 1110 1111 Drupal.behaviors.parallax = { 1112 attach: function (context, settings) { 1113 const $parallax = $('.paragraph--type--parallaxe', context); 1114 1115 $parallax.each(function () { 1116 const image = this.getElementsByClassName('parallax__image'); 1117 1118 new simpleParallax(image, { 1119 delay: 0, 1120 orientation: 'down', 1121 scale: 1.7, 1122 }); 1123 }); 1124 } 1125 }; 1126 1127 Drupal.behaviors.bandeau = { 1128 attach: function (context, settings) { 1129 const $bandeau = $( 1130 once('beandeau', '.bandeaux .bandeau'), 1131 context 1132 ); 1133 1134 $bandeau.each(function () { 1135 const $this = $(this); 1136 const id = $this.attr('data-bandeau-id'); 1137 const nameId = 'RsfBandeau-' + id; 1138 $this.children('.bandeau__close').on('click', function () { 1139 $this.fadeOut(); 1140 localStorage.setItem(nameId, 'hide'); 1141 }); 1142 1143 if (localStorage.getItem(nameId) === 'hide') { 1144 $this.hide(); 1145 } else { 1146 $this.show(); 1147 } 1148 }); 1149 } 1150 }; 1151 1152 Drupal.behaviors.focalPointImage = { 1153 attach: function (context, settings) { 1154 const $focalPointImage = $( 1155 once('mediaFocalPoint', 'article.media--type-image[data-focal-point]'), 1156 context 1157 ); 1158 1159 $focalPointImage.each(function () { 1160 const $pos = $(this).attr('data-focal-point'); 1161 $(this).find('img').css('object-position', $pos); 1162 }); 1163 } 1164 }; 1165 1166 Drupal.behaviors.scrollToResultsPropaganda = { 1167 attach: function (context, settings) { 1168 const propagandaContent = $( 1169 once('scrollToResults', '.page-node-type-propaganda'), 1170 context 1171 ); 1172 1173 // map view 1174 const countries = propagandaContent.find('path.leaflet-interactive');
1175 const results = propagandaContent.find('#nos-publications'); 1176 1177 countries.each(function () { 1178 $(this).on('click', function () { 1179 $('html').animate({ 1180 scrollTop: results.offset().top - 20 1181 }, 0); 1182 }); 1183 }); 1184 1185 } 1186 }; 1187 1188})(jQuery); 1189 1190//# sourceMappingURL=app.js.map
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.