reha.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. // 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
  140. // $(document).ready(function(){
  141. // $('.page-node-site .node-type-site .entete_site .image-site .field--name-field-image > div:nth-child(2)').slick({
  142. // slidesToShow: 1,
  143. // slidesToScroll: 1,
  144. // dots: true,
  145. // arrows: false,
  146. // adaptiveHeight: true,
  147. // // centerMode: true,
  148. // // centerPadding: '100px',
  149. // responsive: [
  150. // {
  151. // breakpoint: 810,
  152. // settings: {
  153. // slidesToShow: 1,
  154. // adaptiveHeight: true,
  155. // arrows: false,
  156. // draggable: true,
  157. // centerMode: true,
  158. // }
  159. // }]
  160. // });
  161. // console.log('slick site');
  162. // });
  163. // /////////////////
  164. //// ancre dans texte au click parragraphe correspondant arrive en dessous du header
  165. // (function($, window) {
  166. // var adjustAnchor = function() {
  167. // var $anchor = $('.block-region-first'),
  168. // fixedElementHeight = 300;
  169. // console.log($anchor);
  170. // if ($anchor.length > 0) {
  171. // $('html, body').stop().animate({scrollTop: $anchor.offset().top - fixedElementHeight }, 0);
  172. // }
  173. // };
  174. // $(window).on('hashchange', function() {
  175. // adjustAnchor();
  176. // });
  177. // });
  178. function adjustAnchor() {
  179. var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
  180. var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
  181. if ($anchor.length > 0) {
  182. $('html, body').stop().animate({
  183. scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
  184. }, 0);
  185. }
  186. }
  187. // Call the function on page load if there's a hash
  188. if (window.location.hash) {
  189. adjustAnchor();
  190. }
  191. // Adjust the anchor on hash change
  192. $(window).on('hashchange', function() {
  193. adjustAnchor();
  194. });
  195. //////////////////////////////////////////
  196. // menu ancre paragraphe quand actif
  197. jQuery(function($) {
  198. // Function to set the active class based on the current path
  199. function setActiveLink() {
  200. var path = window.location.href;
  201. console.log(path);
  202. $(".layout__region--first .block-region-first li a").each(function() {
  203. if (this.href === path) {
  204. $(this).closest('a').addClass('active');
  205. }
  206. });
  207. }
  208. // Initially set the active link based on the current URL
  209. setActiveLink();
  210. // Update the active link on click
  211. $(".layout__region--first .block-region-first li a").on('click', function() {
  212. $(".layout__region--first .block-region-first li a").removeClass('active');
  213. $(this).addClass('active');
  214. });
  215. });
  216. })(jQuery, window);