main.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. //////////////////////////
  11. // faq reponse open
  12. var answers = document.getElementsByClassName("field--name-field-reponse");
  13. var fichiers = document.getElementsByClassName("field--name-field-fichiers");
  14. var questions = document.getElementsByClassName("field--name-field-question");
  15. for (let i = 0; i < questions.length; i++) {
  16. const question = questions[i]
  17. question.addEventListener("click", toggleFaq);
  18. }
  19. function toggleFaq(event) {
  20. console.log(event, this);
  21. // fermé tout
  22. for (let i = 0; i < answers.length; i++) {
  23. answers[i].classList.remove('opened');
  24. }
  25. // la réponse correspndante a la question clické
  26. // | this c'est l'élément sur le quel on a clické
  27. // | |le parent |la réponse dans le parent
  28. let answer = this.parentNode.querySelector('.field--name-field-reponse');
  29. // console.log(answer);
  30. answer.classList.add('opened');
  31. }
  32. ///// répète fonction pour les fichiers, les liens et ressources
  33. //// il faudrait créer un tableau d'objet ?
  34. var fichiers = document.getElementsByClassName("field--name-field-fichiers");
  35. var questions = document.getElementsByClassName("field--name-field-question");
  36. for (let i = 0; i < questions.length; i++) {
  37. const question = questions[i]
  38. question.addEventListener("click", toggleFaqFichiers);
  39. }
  40. function toggleFaqFichiers(event) {
  41. console.log(event, this);
  42. for (let i = 0; i < fichiers.length; i++) {
  43. fichiers[i].classList.remove('opened');
  44. }
  45. let fichier = this.parentNode.querySelector('.field--name-field-fichiers');
  46. fichier.classList.add('opened');
  47. }
  48. //////
  49. var liens = document.getElementsByClassName("field--name-field-liens");
  50. var questions = document.getElementsByClassName("field--name-field-question");
  51. for (let i = 0; i < questions.length; i++) {
  52. const question = questions[i]
  53. question.addEventListener("click", toggleFaqLiens);
  54. }
  55. function toggleFaqLiens(event) {
  56. console.log(event, this);
  57. for (let i = 0; i < liens.length; i++) {
  58. liens[i].classList.remove('opened');
  59. }
  60. let lien = this.parentNode.querySelector('.field--name-field-liens');
  61. lien.classList.add('opened');
  62. }
  63. var ressources = document.getElementsByClassName("field--name-field-ress");
  64. var questions = document.getElementsByClassName("field--name-field-question");
  65. for (let i = 0; i < questions.length; i++) {
  66. const question = questions[i]
  67. question.addEventListener("click", toggleFaqRessources);
  68. }
  69. function toggleFaqRessources(event) {
  70. console.log(event, this);
  71. for (let i = 0; i < resources.length; i++) {
  72. ressources[i].classList.remove('opened');
  73. }
  74. let ressource = this.parentNode.querySelector('.field--name-field-ress');
  75. ressource.classList.add('opened');
  76. }
  77. ///////////////////////////////
  78. // fleche qui tourne faq
  79. // var questions = document.getElementsByClassName("field--name-field-question");
  80. // var paragraph = document.querySelector('.field--name-field-question p')
  81. // console.log(element)
  82. // var styles = window.getComputedStyle(element,':after')
  83. // var content = styles['content']
  84. // console.log(content)
  85. // for (let i = 0; i < questions.length; i++) {
  86. // const question = questions[i]
  87. // question.addEventListener("click", rotateFleche);
  88. // }
  89. // function rotateFleche(event) {
  90. // console.log(event, this);
  91. // // for (let i = 0; i < answers.length; i++) {
  92. // // answers[i].classList.remove('opened');
  93. // // }
  94. // }
  95. //////////////////////////////////////////
  96. // block collection reste bleu quand actif
  97. jQuery(function($) {
  98. var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
  99. console.log(path);
  100. $(".view-id-collections .view-content .views-row a").each(function() {
  101. if (this.href === path) {
  102. $(this).parent().closest('.views-row').addClass('active');
  103. }
  104. });
  105. });
  106. ///////////////////////////////////////////
  107. // border box change color when protagoniste change
  108. // var protagoniste = document.getElementsByClassName("type-de-protagoniste-7");
  109. // console.log(protagoniste);
  110. // ressource.classList.add('opened');
  111. /**
  112. * Return the term id for a given term name.
  113. */
  114. // function _get_tid_from_term_name($term_name) {
  115. // $vocabulary = 'Type de protagoniste';
  116. // $arr_terms = taxonomy_get_term_by_name($term_name, $vocabulary);
  117. // if (!empty($arr_terms)) {
  118. // $arr_terms = array_values($arr_terms);
  119. // $tid = $arr_terms[0]->tid;
  120. // }
  121. // else {
  122. // $vobj = taxonomy_vocabulary_machine_name_load($vocabulary);
  123. // $term = new stdClass();
  124. // $term->name = $term_name;
  125. // $term->vid = $vobj->vid;
  126. // taxonomy_term_save($term);
  127. // $tid = $term->tid;
  128. // }
  129. // return $tid;
  130. // }
  131. // function getVal() {
  132. // const val = document. querySelector('input').value;
  133. // log(val);
  134. // }
  135. // /////////////////
  136. //// ancre dans texte
  137. // document.querySelector('.paragraph--view-mode--textes-toc').click( function() {
  138. // var page = this.attr('href');
  139. // var speed = 750; // gérer la vitesse de défliement
  140. // // Ici on retranche la hauteur du bandeau (201px dans ta feuille de styles)
  141. // document.querySelector('html, body').animate( { scrollTop: page.offset().top - 201 }, speed );
  142. // return false;
  143. // });
  144. /// sticky header on scroll
  145. // // When the user scrolls the page, execute myFunction
  146. // window.onscroll = function() {stickyHeader()};
  147. // console.log(Event);
  148. // // Get the header
  149. // var header = document.getElementById("header-top");
  150. // // Get the offset position of the navbar
  151. // var sticky = header.offsetTop;
  152. // // Add the sticky class to the header when you reach its scroll position. Remove "sticky" when you leave the scroll position
  153. // function stickyHeader() {
  154. // if (window.pageYOffset > sticky) {
  155. // header.classList.add("sticky");
  156. // } else {
  157. // header.classList.remove("sticky");
  158. // }
  159. // }
  160. ///////////////////