reha.js 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  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. // Check the initial state for mobile and add class if needed
  65. function checkMobileAndApplyClass() {
  66. if (window.innerWidth <= 768) { // Adjust the width to match your mobile breakpoint
  67. $(".layout-sidebar-second").addClass('display-none');
  68. } else {
  69. $(".layout-sidebar-second").removeClass('display-none');
  70. }
  71. }
  72. // Run the mobile check on page load
  73. checkMobileAndApplyClass();
  74. // Re-check when the window is resized
  75. $(window).resize(function() {
  76. checkMobileAndApplyClass();
  77. });
  78. // $("aside.layout-sidebar-second h2").click(function(event) {
  79. // const aside = $(".layout-sidebar-second");
  80. // const heading = $("aside.layout-sidebar-second h2");
  81. // // Vérifie si la classe 'close' est présente
  82. // const isClosed = aside.hasClass('close');
  83. // if (isClosed) {
  84. // aside.removeClass('close');
  85. // heading.removeClass('__close');
  86. // sessionStorage.setItem('asideOpened', 'false');
  87. // } else {
  88. // aside.addClass('close');
  89. // heading.addClass('__close');
  90. // sessionStorage.setItem('asideOpened', 'true');
  91. // }
  92. // });
  93. // Gestion toggle du panneau au clic sur le h2
  94. $("aside.layout-sidebar-second h2").click(function () {
  95. const aside = $(".layout-sidebar-second");
  96. const heading = $("aside.layout-sidebar-second h2");
  97. const isClosed = aside.hasClass('close');
  98. if (isClosed) {
  99. aside.removeClass('close');
  100. heading.removeClass('__close');
  101. sessionStorage.setItem('asideOpened', 'false');
  102. } else {
  103. aside.addClass('close');
  104. heading.addClass('__close');
  105. sessionStorage.setItem('asideOpened', 'true');
  106. }
  107. });
  108. // Forcer la fermeture du panneau au clic sur .views-field-title
  109. $("aside.layout-sidebar-second .view-current-user-doc-profile .views-field-title").click(function () {
  110. $(".layout-sidebar-second").addClass('close');
  111. $(".layout-sidebar-second h2").addClass('__close');
  112. sessionStorage.setItem('asideOpened', 'true');
  113. });
  114. });
  115. });
  116. // slideshow home
  117. (function($, window) {
  118. console.log('hello slick')
  119. $(document).ready(function(){
  120. $('.view-id-sites.view-display-id-block_1').slick({
  121. slidesToShow: 1,
  122. // slidesToScroll: 1,
  123. dots: false,
  124. arrows: true,
  125. centerMode: true,
  126. adaptiveHeight: true,
  127. // centerPadding: '100px',
  128. autoplay: true,
  129. autoplaySpeed: 2000,
  130. responsive: [
  131. {
  132. breakpoint: 810,
  133. settings: {
  134. slidesToShow: 1,
  135. adaptiveHeight: true,
  136. arrows: false,
  137. draggable: true,
  138. centerMode: true,
  139. }
  140. }]
  141. });
  142. console.log('salut slick home');
  143. });
  144. $(document).ready(function(){
  145. $('.view-id-actus.view-display-id-block_1 ').slick({
  146. slidesToShow: 1,
  147. slidesToScroll: 1,
  148. // dots: true,
  149. arrows: true,
  150. // centerMode: true,
  151. draggable: true,
  152. centerPadding: '100px',
  153. responsive: [
  154. {
  155. breakpoint: 810,
  156. settings: {
  157. slidesToShow: 1,
  158. slidesToScroll: 1,
  159. adaptiveHeight: true,
  160. arrows: false,
  161. draggable: true,
  162. // centerMode: true,
  163. }
  164. }]
  165. });
  166. console.log('slick actu');
  167. });
  168. $(document).ready(function(){
  169. $('.node-type-site .page-node-site .field--name-field-image .field__items').slick({
  170. slidesToShow: 1,
  171. slidesToScroll: 1,
  172. dots: true,
  173. arrows: false,
  174. // adaptiveHeight: true,
  175. centerMode: true,
  176. // centerPadding: '100px',
  177. responsive: [
  178. {
  179. breakpoint: 810,
  180. settings: {
  181. slidesToShow: 1,
  182. adaptiveHeight: true,
  183. arrows: false,
  184. draggable: true,
  185. centerMode: true,
  186. }
  187. }]
  188. });
  189. console.log('slick site');
  190. });
  191. // /////////////////
  192. //// ancre dans texte au click parragraphe correspondant arrive en dessous du header
  193. function adjustAnchor() {
  194. var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
  195. var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
  196. if ($anchor.length > 0) {
  197. $('html, body').stop().animate({
  198. scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
  199. }, 0);
  200. }
  201. }
  202. // Call the function on page load if there's a hash
  203. if (window.location.hash) {
  204. adjustAnchor();
  205. }
  206. // Adjust the anchor on hash change
  207. $(window).on('hashchange', function() {
  208. adjustAnchor();
  209. });
  210. //////////////////////////////////////////
  211. // menu ancre paragraphe quand actif
  212. jQuery(function($) {
  213. // Function to set the active class based on the current path
  214. function setActiveLink() {
  215. var path = window.location.href;
  216. console.log(path);
  217. $(".layout__region--first .block-region-first li a").each(function() {
  218. if (this.href === path) {
  219. $(this).closest('a').addClass('active');
  220. }
  221. });
  222. }
  223. // Initially set the active link based on the current URL
  224. setActiveLink();
  225. // Update the active link on click
  226. $(".layout__region--first .block-region-first li a").on('click', function() {
  227. $(".layout__region--first .block-region-first li a").removeClass('active');
  228. $(this).addClass('active');
  229. });
  230. });
  231. })(jQuery, window);
  232. /////////////////// déplace synthèse de tous les sites (dans block config 3) dans node site pour faciliter css ///////////////////
  233. (function ($, Drupal) {
  234. Drupal.behaviors.moveFieldContent = {
  235. attach: function (context, settings) {
  236. // Vérifiez que les éléments existent avant de tenter de les manipuler
  237. if ($('#block-reha-config-pages-3 .field--name-field-fichier', context).length && $('.node-type-site .body-content-site .links-content', context).length) {
  238. // Déplacer le contenu de .field--name-field-fichier vers .links-content
  239. var fieldContent = $('#block-reha-config-pages-3 .field--name-field-fichier', context).detach();
  240. $('.node-type-site .body-content-site .links-content', context).append(fieldContent);
  241. }
  242. if ($('#block-reha-titredepage h1', context).length && $('.node-type-actualite .entete_actu .infos_content', context).length) {
  243. // Déplacer le contenu de .field--name-field-fichier vers .links-content
  244. var fieldContent = $('#block-reha-titredepage h1', context).detach();
  245. $('.node-type-actualite .entete_actu .infos_content', context).append(fieldContent);
  246. }
  247. }
  248. };
  249. })(jQuery, Drupal);
  250. // //////////////////// start déplacer block-reha-titredepage dans node-type-actu & ressource infos-content ////////////////////////
  251. // (function ($, Drupal) {
  252. // Drupal.behaviors.moveFieldContent = {
  253. // attach: function (context, settings) {
  254. // // Vérifiez que les éléments existent avant de tenter de les manipuler
  255. // if ($('#block-reha-titredepage h1', context).length && $('.node-type-actualite .entete_actu .infos_content', context).length) {
  256. // // Déplacer le contenu de .field--name-field-fichier vers .links-content
  257. // var fieldContent = $('#block-reha-titredepage h1', context).detach();
  258. // $('.node-type-actualite .entete_actu .infos_content', context).append(fieldContent);
  259. // }
  260. // }
  261. // };
  262. // })(jQuery, Drupal);
  263. // //////////////////// end div infos site ////////////////////////