main.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. //////////////////////
  64. var ressources = document.getElementsByClassName("field--name-field-ress");
  65. var questions = document.getElementsByClassName("field--name-field-question");
  66. for (let i = 0; i < questions.length; i++) {
  67. const question = questions[i]
  68. question.addEventListener("click", toggleFaqRessources);
  69. }
  70. function toggleFaqRessources(event) {
  71. // console.log(event, this);
  72. for (let i = 0; i < resources.length; i++) {
  73. ressources[i].classList.remove('opened');
  74. }
  75. let ressource = this.parentNode.querySelector('.field--name-field-ress');
  76. ressource.classList.add('opened');
  77. }
  78. ///////////////////////////////
  79. ////////////////////////////////
  80. // fleche qui tourne faq
  81. // var questions = document.getElementsByClassName("field--name-field-question");
  82. // var paragraph = document.querySelector('.field--name-field-question p::after');
  83. // console.log(paragraph)
  84. // var styles = window.getComputedStyle(element,':after')
  85. // console.log(styles)
  86. // var content = styles['content']
  87. // console.log(content)
  88. // for (let i = 0; i < questions.length; i++) {
  89. // const question = questions[i]
  90. // question.addEventListener("click", rotateFleche);
  91. // }
  92. // function rotateFleche(event) {
  93. // console.log(event, this);
  94. // // for (let i = 0; i < answers.length; i++) {
  95. // // answers[i].classList.remove('opened');
  96. // // }
  97. // }
  98. //////////////////////////////////////////
  99. // block collection reste bleu quand actif
  100. jQuery(function($) {
  101. var path = window.location.href; // because the 'href' property of the DOM element is the absolute path
  102. console.log(path);
  103. $(".view-id-collections .view-content .views-row a").each(function() {
  104. if (this.href === path) {
  105. $(this).parent().closest('.views-row').addClass('active');
  106. }
  107. });
  108. });
  109. // /////////////////
  110. //// ancre dans texte au click parragraphe correspondant arrive en dessous du header
  111. (function($, window) {
  112. var adjustAnchor = function() {
  113. var $anchor = $('.block-entity-fieldnodefield-textes'),
  114. fixedElementHeight = 350;
  115. if ($anchor.length > 0) {
  116. $('html, body').stop().animate({scrollTop: $anchor.offset().top - fixedElementHeight }, 0);
  117. }
  118. };
  119. $(window).on('hashchange', function() {
  120. adjustAnchor();
  121. });
  122. })(jQuery, window);
  123. // ///////////////////////////////
  124. // slideshow home // marche pas. attention ai rajouter des class dans template views.view.html.twig et views-view-actus-blocks-pages--block-1.html.twig
  125. (function($, window) {
  126. console.log('hello')
  127. $(document).ready(function(){
  128. $('.path-frontpage .view-actus-blocks-pages .view-content').slick({
  129. slidesToShow: 1,
  130. // slidesToScroll: 1,
  131. dots: true,
  132. arrows: true,
  133. centerMode: true,
  134. // centerPadding: '100px',
  135. responsive: [
  136. {
  137. breakpoint: 810,
  138. settings: {
  139. slidesToShow: 1,
  140. adaptiveHeight: true,
  141. arrows: false,
  142. draggable: true,
  143. centerMode: true,
  144. }
  145. }]
  146. });
  147. console.log('salut slick home');
  148. $('.page-node-type-actualite .block-entity-fieldnodefield-images .field--type-image').slick({
  149. dots: true,
  150. arrows: false,
  151. adaptiveHeight: true,
  152. responsive: [
  153. {
  154. breakpoint: 800,
  155. settings: {
  156. adaptiveHeight: true
  157. }
  158. }]
  159. });
  160. console.log('salut slick actus');
  161. $('.page-node-type-projet .block-entity-fieldnodefield-photo .field--type-image').slick({
  162. slidesToShow: 1,
  163. dots: true,
  164. arrows: false,
  165. draggable: true,
  166. adaptiveHeight: true,
  167. responsive: [
  168. {
  169. breakpoint: 800,
  170. settings: {
  171. adaptiveHeight: true
  172. }
  173. }]
  174. });
  175. console.log('salut slick projets');
  176. });
  177. })(jQuery, window);