reha.js 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. // Gestion toggle du panneau au clic sur le h2
  79. $("aside.layout-sidebar-second h2").click(function () {
  80. const aside = $(".layout-sidebar-second");
  81. const heading = $("aside.layout-sidebar-second h2");
  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. // Forcer la fermeture du panneau au clic sur .views-field-title
  94. $("aside.layout-sidebar-second .view-current-user-doc-profile .views-field-title").click(function () {
  95. $(".layout-sidebar-second").addClass('close');
  96. $(".layout-sidebar-second h2").addClass('__close');
  97. sessionStorage.setItem('asideOpened', 'true');
  98. });
  99. });
  100. });
  101. // slideshow home
  102. (function($, window) {
  103. console.log('hello slick')
  104. $(document).ready(function(){
  105. $('.view-id-sites.view-display-id-block_1').slick({
  106. slidesToShow: 1,
  107. // slidesToScroll: 1,
  108. dots: false,
  109. arrows: true,
  110. centerMode: true,
  111. adaptiveHeight: true,
  112. // centerPadding: '100px',
  113. autoplay: true,
  114. autoplaySpeed: 3000,
  115. responsive: [
  116. {
  117. breakpoint: 810,
  118. settings: {
  119. slidesToShow: 1,
  120. adaptiveHeight: true,
  121. arrows: false,
  122. draggable: true,
  123. centerMode: true,
  124. }
  125. }]
  126. });
  127. console.log('salut slick home');
  128. });
  129. $(document).ready(function(){
  130. $('.view-id-actus.view-display-id-block_1 ').slick({
  131. slidesToShow: 1,
  132. slidesToScroll: 1,
  133. // dots: true,
  134. arrows: true,
  135. // centerMode: true,
  136. draggable: true,
  137. centerPadding: '100px',
  138. responsive: [
  139. {
  140. breakpoint: 810,
  141. settings: {
  142. slidesToShow: 1,
  143. slidesToScroll: 1,
  144. adaptiveHeight: true,
  145. arrows: false,
  146. draggable: true,
  147. // centerMode: true,
  148. }
  149. }]
  150. });
  151. console.log('slick actu');
  152. });
  153. $(document).ready(function(){
  154. $('.node-type-site .page-node-site .field--name-field-image .field__items').slick({
  155. slidesToShow: 1,
  156. slidesToScroll: 1,
  157. dots: true,
  158. arrows: false,
  159. // adaptiveHeight: true,
  160. centerMode: true,
  161. // centerPadding: '100px',
  162. autoplay:true,
  163. autoplaySpeed: 2000,
  164. responsive: [
  165. {
  166. breakpoint: 810,
  167. settings: {
  168. slidesToShow: 1,
  169. adaptiveHeight: true,
  170. arrows: false,
  171. draggable: true,
  172. centerMode: true,
  173. }
  174. }]
  175. });
  176. console.log('slick site');
  177. });
  178. // /////////////////
  179. //// ancre dans texte au click parragraphe correspondant arrive en dessous du header
  180. function adjustAnchor() {
  181. var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
  182. var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
  183. if ($anchor.length > 0) {
  184. $('html, body').stop().animate({
  185. scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
  186. }, 0);
  187. }
  188. }
  189. // Call the function on page load if there's a hash
  190. if (window.location.hash) {
  191. adjustAnchor();
  192. }
  193. // Adjust the anchor on hash change
  194. $(window).on('hashchange', function() {
  195. adjustAnchor();
  196. });
  197. //////////////////////////////////////////
  198. // menu ancre paragraphe quand actif
  199. jQuery(function($) {
  200. // Function to set the active class based on the current path
  201. function setActiveLink() {
  202. var path = window.location.href;
  203. console.log(path);
  204. $(".layout__region--first .block-region-first li a").each(function() {
  205. if (this.href === path) {
  206. $(this).closest('a').addClass('active');
  207. }
  208. });
  209. }
  210. // Initially set the active link based on the current URL
  211. setActiveLink();
  212. // Update the active link on click
  213. $(".layout__region--first .block-region-first li a").on('click', function() {
  214. $(".layout__region--first .block-region-first li a").removeClass('active');
  215. $(this).addClass('active');
  216. });
  217. });
  218. })(jQuery, window);
  219. /////////////////// déplace synthèse de tous les sites (dans block config 3) dans node site pour faciliter css ///////////////////
  220. (function ($, Drupal) {
  221. Drupal.behaviors.moveFieldContent = {
  222. attach: function (context, settings) {
  223. // Vérifiez que les éléments existent avant de tenter de les manipuler
  224. if ($('#block-reha-config-pages-3 .field--name-field-fichier', context).length && $('.node-type-site .body-content-site .links-content', context).length) {
  225. // Déplacer le contenu de .field--name-field-fichier vers .links-content
  226. var fieldContent = $('#block-reha-config-pages-3 .field--name-field-fichier', context).detach();
  227. $('.node-type-site .body-content-site .links-content', context).append(fieldContent);
  228. }
  229. if ($('#block-reha-titredepage h1', context).length && $('.node-type-actualite .entete_actu .infos_content', context).length) {
  230. // Déplacer le contenu de .field--name-field-fichier vers .links-content
  231. var fieldContent = $('#block-reha-titredepage h1', context).detach();
  232. $('.node-type-actualite .entete_actu .infos_content', context).append(fieldContent);
  233. }
  234. }
  235. };
  236. })(jQuery, Drupal);
  237. // //////////////////// start déplacer block-reha-titredepage dans node-type-actu & ressource infos-content ////////////////////////
  238. // (function ($, Drupal) {
  239. // Drupal.behaviors.moveFieldContent = {
  240. // attach: function (context, settings) {
  241. // // Vérifiez que les éléments existent avant de tenter de les manipuler
  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. // //////////////////// end div infos site ////////////////////////
  251. function initDescriptionTooltips(root = document) {
  252. root.querySelectorAll('.description').forEach(el => {
  253. if (!el.hasAttribute('data-text')) {
  254. el.setAttribute('data-text', el.textContent.trim());
  255. }
  256. });
  257. }
  258. // Initialisation sur la page actuelle
  259. initDescriptionTooltips();
  260. // Observer pour détecter les nouveaux éléments ajoutés au DOM
  261. const observer = new MutationObserver(mutations => {
  262. mutations.forEach(mutation => {
  263. mutation.addedNodes.forEach(node => {
  264. if (node.nodeType === 1) { // élément HTML
  265. if (node.matches('.description')) {
  266. initDescriptionTooltips(node.parentNode);
  267. } else {
  268. // Si c'est un conteneur qui contient des .description
  269. initDescriptionTooltips(node);
  270. }
  271. }
  272. });
  273. });
  274. });
  275. // Observer sur tout le body
  276. observer.observe(document.body, { childList: true, subtree: true });