reha.js 8.7 KB

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