main.js 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. console.log('salut');
  2. // menu burger open
  3. var burger = document.getElementById("block-burger");
  4. var burgertitle = document.getElementById("block-burger-menu");
  5. burgertitle.addEventListener("click", toggleMenu);
  6. function toggleMenu(event) {
  7. console.log(event);
  8. burger.classList.toggle('opened');
  9. }
  10. // faq reponse open
  11. var answers = document.getElementsByClassName("field--name-field-reponse");
  12. var questions = document.getElementsByClassName("field--name-field-question");
  13. for (let i = 0; i < questions.length; i++) {
  14. const question = questions[i]
  15. question.addEventListener("click", toggleFaq);
  16. }
  17. function toggleFaq(event) {
  18. console.log(event, this);
  19. // fermé tout
  20. for (let i = 0; i < answers.length; i++) {
  21. answers[i].classList.remove('opened');
  22. }
  23. // la réponse correspndante a la question clické
  24. // | this c'est l'élément sur le quel on a clické
  25. // | |le parent |la réponse dans le parent
  26. let answer = this.parentNode.querySelector('.field--name-field-reponse');
  27. // console.log(answer);
  28. answer.classList.add('opened');
  29. }
  30. // /////////////////
  31. //// ancre dans texte
  32. document.querySelector('.paragraph--view-mode--textes-toc').click( function() {
  33. var page = this.attr('href');
  34. var speed = 750; // gérer la vitesse de défliement
  35. // Ici on retranche la hauteur du bandeau (201px dans ta feuille de styles)
  36. document.querySelector('html, body').animate( { scrollTop: page.offset().top - 201 }, speed );
  37. return false;
  38. });
  39. /// sticky header on scroll
  40. // // When the user scrolls the page, execute myFunction
  41. // window.onscroll = function() {stickyHeader()};
  42. // console.log(Event);
  43. // // Get the header
  44. // var header = document.getElementById("header-top");
  45. // // Get the offset position of the navbar
  46. // var sticky = header.offsetTop;
  47. // // Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
  48. // function stickyHeader() {
  49. // if (window.pageYOffset > sticky) {
  50. // header.classList.add("sticky");
  51. // } else {
  52. // header.classList.remove("sticky");
  53. // }
  54. // }
  55. ///////////////////
  56. // document.addEventListener('click', function(e) {
  57. // if (e.target.classList.contains('rect_white_left') {
  58. // e.target.parentNode.nextElementSibling.classList.toggle('opened');}
  59. // }
  60. // fonction pour attribuer la class du parents
  61. // var fields = document.getElementsByClassName("field--name-field-titre");
  62. // var paragraphs = document.getElementsByClassName("paragraph--type--texte");
  63. // for (let i = 0; i < fields.length; i++) {
  64. // const field = fields[i]
  65. // }
  66. // function giveIdParent(){
  67. // document.field.classList="paragraphs";
  68. // }
  69. // Function mouseOut ()
  70. // {
  71. // document.getelementbyid("flashdiv").classname="flash-I";
  72. // }
  73. // open external link in new window
  74. // $(".ext").each(
  75. // function(i,e){
  76. // window.open(e, '_blank');
  77. // }
  78. // );
  79. // var target = document.getElementsByClassName("ext");
  80. // document.addEventListener("click", function(e) {
  81. // if (e.target == true )
  82. // {
  83. // e.target.setAttribute("target", "_blank");
  84. // }
  85. // });
  86. // add id to field
  87. // Add data-extlink attribute.
  88. // $links_to_process.attr('data-extlink', '');
  89. // var i;
  90. // var length = $links_to_process.length;
  91. // for (i = 0; i < length; i++) {
  92. // var $link = $($links_to_process[i]);
  93. // if (drupalSettings.data.extlink.extUseFontAwesome) {
  94. // if (class_name === drupalSettings.data.extlink.mailtoClass) {
  95. // $link[icon_placement]('<span class="fa-' + class_name + ' extlink"><span class="' + drupalSettings.data.extlink.extFaMailtoClasses + '" aria-label="' + drupalSettings.data.extlink.mailtoLabel + '"></span></span>');
  96. // }
  97. // else {
  98. // $link[icon_placement]('<span class="fa-' + class_name + ' extlink"><span class="' + drupalSettings.data.extlink.extFaLinkClasses + '" aria-label="' + drupalSettings.data.extlink.extLabel + '"></span></span>');
  99. // }
  100. // }
  101. // else {
  102. // if (class_name === drupalSettings.data.extlink.mailtoClass) {
  103. // $link[icon_placement]('<svg focusable="false" class="' + class_name + '" role="img" aria-label="' + drupalSettings.data.extlink.mailtoLabel + '" xmlns="http://www.w3.org/2000/svg" viewBox="0 10 70 20"><metadata><sfw xmlns="http://ns.adobe.com/SaveForWeb/1.0/"><sliceSourceBounds y="-8160" x="-8165" width="16389" height="16384" bottomLeftOrigin="true"/><optimizationSettings><targetSettings targetSettingsID="0" fileFormat="PNG24Format"><PNG24Format transparency="true" filtered="false" interlaced="false" noMatteColor="false" matteColor="#FFFFFF"/></targetSettings></optimizationSettings></sfw></metadata><title>' + drupalSettings.data.extlink.mailtoLabel + '</title><path d="M56 14H8c-1.1 0-2 0.9-2 2v32c0 1.1 0.9 2 2 2h48c1.1 0 2-0.9 2-2V16C58 14.9 57.1 14 56 14zM50.5 18L32 33.4 13.5 18H50.5zM10 46V20.3l20.7 17.3C31.1 37.8 31.5 38 32 38s0.9-0.2 1.3-0.5L54 20.3V46H10z"/></svg>');
  104. // }
  105. // else {
  106. // $link[icon_placement]('<svg focusable="false" class="' + class_name + '" role="img" aria-label="' + drupalSettings.data.extlink.extLabel + '" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 80 40"><metadata><sfw xmlns="http://ns.adobe.com/SaveForWeb/1.0/"><sliceSourceBounds y="-8160" x="-8165" width="16389" height="16384" bottomLeftOrigin="true"/><optimizationSettings><targetSettings targetSettingsID="0" fileFormat="PNG24Format"><PNG24Format transparency="true" filtered="false" interlaced="false" noMatteColor="false" matteColor="#FFFFFF"/></targetSettings></optimizationSettings></sfw></metadata><title>' + drupalSettings.data.extlink.extLabel + '</title><path d="M48 26c-1.1 0-2 0.9-2 2v26H10V18h26c1.1 0 2-0.9 2-2s-0.9-2-2-2H8c-1.1 0-2 0.9-2 2v40c0 1.1 0.9 2 2 2h40c1.1 0 2-0.9 2-2V28C50 26.9 49.1 26 48 26z"/><path d="M56 6H44c-1.1 0-2 0.9-2 2s0.9 2 2 2h7.2L30.6 30.6c-0.8 0.8-0.8 2 0 2.8C31 33.8 31.5 34 32 34s1-0.2 1.4-0.6L54 12.8V20c0 1.1 0.9 2 2 2s2-0.9 2-2V8C58 6.9 57.1 6 56 6z"/></svg>');
  107. // }
  108. // }
  109. // }
  110. // };