reha.js 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /**
  2. * @file
  3. * reha behaviors.
  4. */
  5. (function (Drupal) {
  6. 'use strict';
  7. Drupal.behaviors.reha = {
  8. attach: function (context, settings) {
  9. console.log('It works!');
  10. }
  11. };
  12. } (Drupal));
  13. jQuery(document).ready(function($){
  14. // menu déroulant
  15. ////////////// contacts ///////
  16. $(".bouton-contact").click(function(event) {
  17. // Fermer .connexion-full s'il est déroulé
  18. if ($(".connexion-full").is(":visible")) {
  19. $(".connexion-full").slideUp();
  20. }
  21. if ($(".connected-full").is(":visible")) {
  22. $(".connected-full").slideUp();
  23. }
  24. // Ouvrir .contacts-full
  25. $(".contacts-full").slideToggle();
  26. });
  27. ////////////// connexion ///////
  28. $(".bouton-connexion").click(function(event) {
  29. // Fermer .contacts-full s'il est déroulé
  30. if ($(".contacts-full").is(":visible")) {
  31. $(".contacts-full").slideUp();
  32. }
  33. // Ouvrir .connexion-full
  34. $(".connexion-full").slideToggle();
  35. });
  36. $(".bouton-connected").click(function(event) {
  37. // Fermer .contacts-full s'il est déroulé
  38. if ($(".contacts-full").is(":visible")) {
  39. $(".contacts-full").slideUp();
  40. }
  41. // Ouvrir .connected-full
  42. $(".connected-full").slideToggle();
  43. });
  44. $(".titre").click(function(event) {
  45. if ($(".connected-full").is(":visible")) {
  46. $(".connected-full").slideUp();
  47. }
  48. if ($(".contacts-full").is(":visible")) {
  49. $(".contacts-full").slideUp();
  50. }
  51. if ($(".connexion-full").is(":visible")) {
  52. $(".connexion-full").slideUp();
  53. }
  54. // // Ouvrir .connexion-full
  55. // $(".connected-full").slideToggle();
  56. });
  57. $("#edit-field-dossier-de-candidature-0--label").click(function(event) {
  58. event.preventDefault();
  59. // Ouvrir .connexion-full
  60. $("#edit-field-dossier-de-candidature-0--description>ul.main").slideToggle();
  61. });
  62. ////////////// tiroir fichiers ///////
  63. // $(".profile--type--collaborateur").click(function(event) {
  64. // // Ouvrir .tiroir fichiers
  65. // $(".layout-sidebar-second").animate({translate:'90%'},350);
  66. // });
  67. // $("#block-reha-views-block-current-user-doc-profile-block-1 > h2").click(function(event) {
  68. // // Ouvrir .tiroir fichiers
  69. // $(".layout-sidebar-second").animate({translate:'0%'},350);
  70. // });
  71. $(document).ready(function() {
  72. // Vérifier l'état initial depuis sessionStorage
  73. if (sessionStorage.getItem('asideOpened') === 'true') {
  74. $(".layout-sidebar-second").addClass('close');
  75. $("h2").addClass('__close');
  76. }
  77. $(".profile--type--collaborateur").click(function(event) {
  78. // Ouvrir .tiroir fichiers
  79. $(".layout-sidebar-second").addClass('close');
  80. $("h2").addClass('__close');
  81. sessionStorage.setItem('asideOpened', 'true');
  82. });
  83. $("#block-reha-views-block-current-user-doc-profile-block-1 > h2").click(function(event) {
  84. // Fermer .tiroir fichiers
  85. $(".layout-sidebar-second").removeClass('close');
  86. $("h2").removeClass('__close');
  87. sessionStorage.setItem('asideOpened', 'false');
  88. });
  89. });
  90. });
  91. // slideshow home
  92. (function($, window) {
  93. console.log('hello slick')
  94. $(document).ready(function(){
  95. $('.view-id-sites.view-display-id-block_1').slick({
  96. slidesToShow: 1,
  97. // slidesToScroll: 1,
  98. dots: false,
  99. arrows: true,
  100. centerMode: true,
  101. adaptiveHeight: true,
  102. // centerPadding: '100px',
  103. responsive: [
  104. {
  105. breakpoint: 810,
  106. settings: {
  107. slidesToShow: 1,
  108. adaptiveHeight: true,
  109. arrows: false,
  110. draggable: true,
  111. centerMode: true,
  112. }
  113. }]
  114. });
  115. console.log('salut slick home');
  116. });
  117. $(document).ready(function(){
  118. $('.view-id-actus.view-display-id-block_1').slick({
  119. slidesToShow: 3,
  120. // slidesToScroll: 1,
  121. dots: false,
  122. arrows: true,
  123. centerMode: true,
  124. // centerPadding: '100px',
  125. responsive: [
  126. {
  127. breakpoint: 810,
  128. settings: {
  129. slidesToShow: 1,
  130. adaptiveHeight: true,
  131. arrows: false,
  132. draggable: true,
  133. centerMode: true,
  134. }
  135. }]
  136. });
  137. console.log('slick actu');
  138. });
  139. $(document).ready(function(){
  140. $('.page-node-site .node-type-site .field--name-field-image > div:nth-child(2)').slick({
  141. slidesToShow: 1,
  142. slidesToScroll: 1,
  143. dots: true,
  144. arrows: false,
  145. adaptiveHeight: true,
  146. // centerMode: true,
  147. // centerPadding: '100px',
  148. responsive: [
  149. {
  150. breakpoint: 810,
  151. settings: {
  152. slidesToShow: 1,
  153. adaptiveHeight: true,
  154. arrows: false,
  155. draggable: true,
  156. centerMode: true,
  157. }
  158. }]
  159. });
  160. console.log('slick actu');
  161. });
  162. // /////////////////
  163. //// ancre dans texte au click parragraphe correspondant arrive en dessous du header
  164. // (function($, window) {
  165. // var adjustAnchor = function() {
  166. // var $anchor = $('.block-region-first'),
  167. // fixedElementHeight = 300;
  168. // console.log($anchor);
  169. // if ($anchor.length > 0) {
  170. // $('html, body').stop().animate({scrollTop: $anchor.offset().top - fixedElementHeight }, 0);
  171. // }
  172. // };
  173. // $(window).on('hashchange', function() {
  174. // adjustAnchor();
  175. // });
  176. // });
  177. function adjustAnchor() {
  178. var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
  179. var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
  180. if ($anchor.length > 0) {
  181. $('html, body').stop().animate({
  182. scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
  183. }, 0);
  184. }
  185. }
  186. // Call the function on page load if there's a hash
  187. if (window.location.hash) {
  188. adjustAnchor();
  189. }
  190. // Adjust the anchor on hash change
  191. $(window).on('hashchange', function() {
  192. adjustAnchor();
  193. });
  194. //////////////////////////////////////////
  195. // menu ancre paragraphe quand actif
  196. jQuery(function($) {
  197. // Function to set the active class based on the current path
  198. function setActiveLink() {
  199. var path = window.location.href;
  200. console.log(path);
  201. $(".layout__region--first .block-region-first li a").each(function() {
  202. if (this.href === path) {
  203. $(this).closest('a').addClass('active');
  204. }
  205. });
  206. }
  207. // Initially set the active link based on the current URL
  208. setActiveLink();
  209. // Update the active link on click
  210. $(".layout__region--first .block-region-first li a").on('click', function() {
  211. $(".layout__region--first .block-region-first li a").removeClass('active');
  212. $(this).addClass('active');
  213. });
  214. });
  215. })(jQuery, window);