reha.js 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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. $(document).ready(function() {
  64. // Vérifier l'état initial depuis sessionStorage
  65. if (sessionStorage.getItem('asideOpened') === 'true') {
  66. $(".layout-sidebar-second").addClass('close');
  67. $("h2").addClass('__close');
  68. }
  69. $(".profile--type--collaborateur").click(function(event) {
  70. // Ouvrir .tiroir fichiers
  71. $(".layout-sidebar-second").addClass('close');
  72. $("h2").addClass('__close');
  73. sessionStorage.setItem('asideOpened', 'true');
  74. });
  75. $("#block-reha-views-block-current-user-doc-profile-block-1 > h2").click(function(event) {
  76. // Fermer .tiroir fichiers
  77. $(".layout-sidebar-second").removeClass('close');
  78. $("h2").removeClass('__close');
  79. sessionStorage.setItem('asideOpened', 'false');
  80. });
  81. });
  82. });
  83. // slideshow home
  84. (function($, window) {
  85. console.log('hello slick')
  86. $(document).ready(function(){
  87. $('.view-id-sites.view-display-id-block_1').slick({
  88. slidesToShow: 1,
  89. // slidesToScroll: 1,
  90. dots: false,
  91. arrows: true,
  92. centerMode: true,
  93. adaptiveHeight: true,
  94. // centerPadding: '100px',
  95. responsive: [
  96. {
  97. breakpoint: 810,
  98. settings: {
  99. slidesToShow: 1,
  100. adaptiveHeight: true,
  101. arrows: false,
  102. draggable: true,
  103. centerMode: true,
  104. }
  105. }]
  106. });
  107. console.log('salut slick home');
  108. });
  109. $(document).ready(function(){
  110. $('.view-id-actus.view-display-id-block_1').slick({
  111. slidesToShow: 3,
  112. // slidesToScroll: 1,
  113. dots: false,
  114. arrows: true,
  115. centerMode: true,
  116. // centerPadding: '100px',
  117. responsive: [
  118. {
  119. breakpoint: 810,
  120. settings: {
  121. slidesToShow: 1,
  122. adaptiveHeight: true,
  123. arrows: false,
  124. draggable: true,
  125. centerMode: true,
  126. }
  127. }]
  128. });
  129. console.log('slick actu');
  130. });
  131. // html.js body.node-type-site.node-id-58 div.dialog-off-canvas-main-canvas div.layout-container.page-node-site main div.layout-content.home-page-layout-content div.region.region-content div#block-reha-contenudelapageprincipale.block.block-system.block-system-main-block article.node-type-site div.entete_site div.image-site div.field.field--name-field-image.field--type-image.field--label-visually_hidden div.field__items
  132. $(document).ready(function(){
  133. $('.page-node-site .field--name-field-image .field__items').slick({
  134. slidesToShow: 1,
  135. // slidesToScroll: 1,
  136. dots: true,
  137. arrows: false,
  138. // adaptiveHeight: true,
  139. centerMode: true,
  140. // centerPadding: '100px',
  141. responsive: [
  142. {
  143. breakpoint: 810,
  144. settings: {
  145. slidesToShow: 1,
  146. adaptiveHeight: true,
  147. arrows: false,
  148. draggable: true,
  149. centerMode: true,
  150. }
  151. }]
  152. });
  153. console.log('slick site');
  154. });
  155. // /////////////////
  156. //// ancre dans texte au click parragraphe correspondant arrive en dessous du header
  157. function adjustAnchor() {
  158. var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
  159. var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
  160. if ($anchor.length > 0) {
  161. $('html, body').stop().animate({
  162. scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
  163. }, 0);
  164. }
  165. }
  166. // Call the function on page load if there's a hash
  167. if (window.location.hash) {
  168. adjustAnchor();
  169. }
  170. // Adjust the anchor on hash change
  171. $(window).on('hashchange', function() {
  172. adjustAnchor();
  173. });
  174. //////////////////////////////////////////
  175. // menu ancre paragraphe quand actif
  176. jQuery(function($) {
  177. // Function to set the active class based on the current path
  178. function setActiveLink() {
  179. var path = window.location.href;
  180. console.log(path);
  181. $(".layout__region--first .block-region-first li a").each(function() {
  182. if (this.href === path) {
  183. $(this).closest('a').addClass('active');
  184. }
  185. });
  186. }
  187. // Initially set the active link based on the current URL
  188. setActiveLink();
  189. // Update the active link on click
  190. $(".layout__region--first .block-region-first li a").on('click', function() {
  191. $(".layout__region--first .block-region-first li a").removeClass('active');
  192. $(this).addClass('active');
  193. });
  194. });
  195. })(jQuery, window);