reha.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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. $(".layout-sidebar-second h2").addClass('__close');
  68. }
  69. $(".view-current-user-doc-profile").click(function(event) {
  70. // Ouvrir .tiroir fichiers
  71. $(".layout-sidebar-second").addClass('close');
  72. $(".layout-sidebar-second 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. $(".layout-sidebar-second 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: 1,
  112. slidesToScroll: 1,
  113. // dots: true,
  114. arrows: true,
  115. // centerMode: true,
  116. draggable: true,
  117. centerPadding: '100px',
  118. responsive: [
  119. {
  120. breakpoint: 810,
  121. settings: {
  122. slidesToShow: 1,
  123. adaptiveHeight: true,
  124. arrows: false,
  125. draggable: true,
  126. centerMode: true,
  127. }
  128. }]
  129. });
  130. console.log('slick actu');
  131. });
  132. // 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
  133. $(document).ready(function(){
  134. $('.node-type-site .page-node-site .field--name-field-image .field__items').slick({
  135. slidesToShow: 1,
  136. // slidesToScroll: 1,
  137. dots: true,
  138. arrows: false,
  139. // adaptiveHeight: true,
  140. centerMode: true,
  141. // centerPadding: '100px',
  142. responsive: [
  143. {
  144. breakpoint: 810,
  145. settings: {
  146. slidesToShow: 1,
  147. adaptiveHeight: true,
  148. arrows: false,
  149. draggable: true,
  150. centerMode: true,
  151. }
  152. }]
  153. });
  154. console.log('slick site');
  155. });
  156. // /////////////////
  157. //// ancre dans texte au click parragraphe correspondant arrive en dessous du header
  158. function adjustAnchor() {
  159. var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
  160. var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
  161. if ($anchor.length > 0) {
  162. $('html, body').stop().animate({
  163. scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
  164. }, 0);
  165. }
  166. }
  167. // Call the function on page load if there's a hash
  168. if (window.location.hash) {
  169. adjustAnchor();
  170. }
  171. // Adjust the anchor on hash change
  172. $(window).on('hashchange', function() {
  173. adjustAnchor();
  174. });
  175. //////////////////////////////////////////
  176. // menu ancre paragraphe quand actif
  177. jQuery(function($) {
  178. // Function to set the active class based on the current path
  179. function setActiveLink() {
  180. var path = window.location.href;
  181. console.log(path);
  182. $(".layout__region--first .block-region-first li a").each(function() {
  183. if (this.href === path) {
  184. $(this).closest('a').addClass('active');
  185. }
  186. });
  187. }
  188. // Initially set the active link based on the current URL
  189. setActiveLink();
  190. // Update the active link on click
  191. $(".layout__region--first .block-region-first li a").on('click', function() {
  192. $(".layout__region--first .block-region-first li a").removeClass('active');
  193. $(this).addClass('active');
  194. });
  195. });
  196. })(jQuery, window);
  197. /////////////////// déplace synthèse de tous les sites (dans block config 3) dans node site pour faciliter css ///////////////////
  198. (function ($, Drupal) {
  199. Drupal.behaviors.moveFieldContent = {
  200. attach: function (context, settings) {
  201. // Vérifiez que les éléments existent avant de tenter de les manipuler
  202. if ($('#block-reha-config-pages-3 .field--name-field-fichier', context).length && $('.node-type-site .body-content-site .links-content', context).length) {
  203. // Déplacer le contenu de .field--name-field-fichier vers .links-content
  204. var fieldContent = $('#block-reha-config-pages-3 .field--name-field-fichier', context).detach();
  205. $('.node-type-site .body-content-site .links-content', context).append(fieldContent);
  206. }
  207. }
  208. };
  209. })(jQuery, Drupal);