348 lines
10 KiB
JavaScript
348 lines
10 KiB
JavaScript
/**
|
|
* @file
|
|
* reha behaviors.
|
|
*/
|
|
(function (Drupal) {
|
|
|
|
'use strict';
|
|
|
|
Drupal.behaviors.reha = {
|
|
attach: function (context, settings) {
|
|
|
|
console.log('It works!');
|
|
|
|
}
|
|
};
|
|
|
|
|
|
} (Drupal));
|
|
|
|
jQuery(document).ready(function($){
|
|
|
|
// menu déroulant
|
|
|
|
////////////// contacts ///////
|
|
|
|
$(".bouton-contact").click(function(event) {
|
|
// Fermer .connexion-full s'il est déroulé
|
|
if ($(".connexion-full").is(":visible")) {
|
|
$(".connexion-full").slideUp();
|
|
}
|
|
if ($(".connected-full").is(":visible")) {
|
|
$(".connected-full").slideUp();
|
|
}
|
|
// Ouvrir .contacts-full
|
|
$(".contacts-full").slideToggle();
|
|
|
|
});
|
|
|
|
////////////// connexion ///////
|
|
|
|
$(".bouton-connexion").click(function(event) {
|
|
// Fermer .contacts-full s'il est déroulé
|
|
if ($(".contacts-full").is(":visible")) {
|
|
$(".contacts-full").slideUp();
|
|
}
|
|
// Ouvrir .connexion-full
|
|
$(".connexion-full").slideToggle();
|
|
});
|
|
|
|
$(".bouton-connected").click(function(event) {
|
|
// Fermer .contacts-full s'il est déroulé
|
|
if ($(".contacts-full").is(":visible")) {
|
|
$(".contacts-full").slideUp();
|
|
}
|
|
// Ouvrir .connected-full
|
|
$(".connected-full").slideToggle();
|
|
});
|
|
|
|
$(".titre").click(function(event) {
|
|
if ($(".connected-full").is(":visible")) {
|
|
$(".connected-full").slideUp();
|
|
}
|
|
if ($(".contacts-full").is(":visible")) {
|
|
$(".contacts-full").slideUp();
|
|
}
|
|
if ($(".connexion-full").is(":visible")) {
|
|
$(".connexion-full").slideUp();
|
|
}
|
|
// // Ouvrir .connexion-full
|
|
// $(".connected-full").slideToggle();
|
|
});
|
|
|
|
$("#edit-field-dossier-de-candidature-0--label").click(function(event) {
|
|
event.preventDefault();
|
|
// Ouvrir .connexion-full
|
|
$("#edit-field-dossier-de-candidature-0--description>ul.main").slideToggle();
|
|
});
|
|
|
|
|
|
////////////// tiroir fichiers ///////
|
|
|
|
$(document).ready(function() {
|
|
|
|
// Check the initial state for mobile and add class if needed
|
|
function checkMobileAndApplyClass() {
|
|
if (window.innerWidth <= 768) { // Adjust the width to match your mobile breakpoint
|
|
$(".layout-sidebar-second").addClass('display-none');
|
|
} else {
|
|
$(".layout-sidebar-second").removeClass('display-none');
|
|
}
|
|
}
|
|
|
|
// Run the mobile check on page load
|
|
checkMobileAndApplyClass();
|
|
|
|
// Re-check when the window is resized
|
|
$(window).resize(function() {
|
|
checkMobileAndApplyClass();
|
|
});
|
|
|
|
// Gestion toggle du panneau au clic sur le h2
|
|
$("aside.layout-sidebar-second h2").click(function () {
|
|
const aside = $(".layout-sidebar-second");
|
|
const heading = $("aside.layout-sidebar-second h2");
|
|
const isClosed = aside.hasClass('close');
|
|
|
|
if (isClosed) {
|
|
aside.removeClass('close');
|
|
heading.removeClass('__close');
|
|
sessionStorage.setItem('asideOpened', 'false');
|
|
} else {
|
|
aside.addClass('close');
|
|
heading.addClass('__close');
|
|
sessionStorage.setItem('asideOpened', 'true');
|
|
}
|
|
});
|
|
|
|
// Forcer la fermeture du panneau au clic sur .views-field-title
|
|
$("aside.layout-sidebar-second .view-current-user-doc-profile .views-field-title").click(function () {
|
|
$(".layout-sidebar-second").addClass('close');
|
|
$(".layout-sidebar-second h2").addClass('__close');
|
|
sessionStorage.setItem('asideOpened', 'true');
|
|
});
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
// slideshow home
|
|
|
|
(function($, window) {
|
|
console.log('hello slick')
|
|
$(document).ready(function(){
|
|
$('.view-id-sites.view-display-id-block_1').slick({
|
|
slidesToShow: 1,
|
|
// slidesToScroll: 1,
|
|
dots: false,
|
|
arrows: true,
|
|
centerMode: true,
|
|
adaptiveHeight: true,
|
|
// centerPadding: '100px',
|
|
// autoplay: true,
|
|
// autoplaySpeed: 5000,
|
|
responsive: [
|
|
{
|
|
breakpoint: 810,
|
|
settings: {
|
|
slidesToShow: 1,
|
|
// adaptiveHeight: false,
|
|
dots: false,
|
|
arrows: false,
|
|
draggable: true,
|
|
centerMode: true,
|
|
centerPadding: '5%',
|
|
|
|
}
|
|
}]
|
|
});
|
|
console.log('salut slick home');
|
|
|
|
});
|
|
|
|
$(document).ready(function(){
|
|
$('.view-id-actus.view-display-id-block_1').slick({
|
|
slidesToShow: 3,
|
|
slidesToScroll: 1,
|
|
dots: true,
|
|
arrows: true,
|
|
// centerMode: true,
|
|
draggable: true,
|
|
// centerPadding: '100px',
|
|
infinite: false,
|
|
responsive: [
|
|
{
|
|
breakpoint: 810,
|
|
settings: {
|
|
slidesToShow: 1,
|
|
slidesToScroll: 1,
|
|
adaptiveHeight: true,
|
|
arrows: false,
|
|
draggable: true,
|
|
// centerMode: true,
|
|
}
|
|
}]
|
|
});
|
|
console.log('slick actu');
|
|
});
|
|
|
|
|
|
$(document).ready(function(){
|
|
$('.node-type-site .page-node-site .field--name-field-image .field__items').slick({
|
|
slidesToShow: 1,
|
|
slidesToScroll: 1,
|
|
dots: true,
|
|
arrows: false,
|
|
// adaptiveHeight: true,
|
|
centerMode: true,
|
|
// centerPadding: '100px',
|
|
autoplay:true,
|
|
autoplaySpeed: 5000,
|
|
responsive: [
|
|
{
|
|
breakpoint: 810,
|
|
settings: {
|
|
slidesToShow: 1,
|
|
adaptiveHeight: true,
|
|
arrows: false,
|
|
draggable: true,
|
|
centerMode: true,
|
|
}
|
|
}]
|
|
});
|
|
console.log('slick site');
|
|
});
|
|
|
|
|
|
|
|
|
|
// /////////////////
|
|
//// ancre dans texte au click parragraphe correspondant arrive en dessous du header
|
|
|
|
function adjustAnchor() {
|
|
var $anchor = $(window.location.hash); // Select the anchor element based on the hash in the URL
|
|
var fixedElementHeight = $('.block-region-first').outerHeight(); // Get the height of the sticky element
|
|
|
|
if ($anchor.length > 0) {
|
|
$('html, body').stop().animate({
|
|
scrollTop: $anchor.offset().top - fixedElementHeight // Adjust the scroll position to account for the sticky element height
|
|
}, 0);
|
|
}
|
|
}
|
|
|
|
// Call the function on page load if there's a hash
|
|
if (window.location.hash) {
|
|
adjustAnchor();
|
|
}
|
|
|
|
// Adjust the anchor on hash change
|
|
$(window).on('hashchange', function() {
|
|
adjustAnchor();
|
|
});
|
|
|
|
|
|
|
|
//////////////////////////////////////////
|
|
// menu ancre paragraphe quand actif
|
|
|
|
jQuery(function($) {
|
|
// Function to set the active class based on the current path
|
|
function setActiveLink() {
|
|
var path = window.location.href;
|
|
console.log(path);
|
|
$(".layout__region--first .block-region-first li a").each(function() {
|
|
if (this.href === path) {
|
|
$(this).closest('a').addClass('active');
|
|
}
|
|
});
|
|
}
|
|
|
|
// Initially set the active link based on the current URL
|
|
setActiveLink();
|
|
|
|
// Update the active link on click
|
|
$(".layout__region--first .block-region-first li a").on('click', function() {
|
|
$(".layout__region--first .block-region-first li a").removeClass('active');
|
|
$(this).addClass('active');
|
|
});
|
|
});
|
|
|
|
|
|
})(jQuery, window);
|
|
|
|
|
|
/////////////////// déplace synthèse de tous les sites (dans block config 3) dans node site pour faciliter css ///////////////////
|
|
|
|
(function ($, Drupal) {
|
|
Drupal.behaviors.moveFieldContent = {
|
|
attach: function (context, settings) {
|
|
// Vérifiez que les éléments existent avant de tenter de les manipuler
|
|
if ($('#block-reha-config-pages-3 .field--name-field-fichier', context).length && $('.node-type-site .body-content-site .links-content', context).length) {
|
|
// Déplacer le contenu de .field--name-field-fichier vers .links-content
|
|
var fieldContent = $('#block-reha-config-pages-3 .field--name-field-fichier', context).detach();
|
|
$('.node-type-site .body-content-site .links-content', context).append(fieldContent);
|
|
}
|
|
if ($('#block-reha-titredepage h1', context).length && $('.node-type-actualite .entete_actu .infos_content', context).length) {
|
|
// Déplacer le contenu de .field--name-field-fichier vers .links-content
|
|
var fieldContent = $('#block-reha-titredepage h1', context).detach();
|
|
$('.node-type-actualite .entete_actu .infos_content', context).append(fieldContent);
|
|
}
|
|
}
|
|
};
|
|
})(jQuery, Drupal);
|
|
|
|
|
|
|
|
|
|
// //////////////////// start déplacer block-reha-titredepage dans node-type-actu & ressource infos-content ////////////////////////
|
|
|
|
// (function ($, Drupal) {
|
|
// Drupal.behaviors.moveFieldContent = {
|
|
// attach: function (context, settings) {
|
|
// // Vérifiez que les éléments existent avant de tenter de les manipuler
|
|
// if ($('#block-reha-titredepage h1', context).length && $('.node-type-actualite .entete_actu .infos_content', context).length) {
|
|
// // Déplacer le contenu de .field--name-field-fichier vers .links-content
|
|
// var fieldContent = $('#block-reha-titredepage h1', context).detach();
|
|
// $('.node-type-actualite .entete_actu .infos_content', context).append(fieldContent);
|
|
// }
|
|
// }
|
|
// };
|
|
// })(jQuery, Drupal);
|
|
// //////////////////// end div infos site ////////////////////////
|
|
|
|
|
|
// document.querySelectorAll('.description').forEach(el => {
|
|
// el.setAttribute('data-text', el.textContent.trim());
|
|
// });
|
|
|
|
function initDescriptionTooltips(root = document) {
|
|
root.querySelectorAll('.description').forEach(el => {
|
|
if (!el.hasAttribute('data-text')) {
|
|
el.setAttribute('data-text', el.textContent.trim());
|
|
}
|
|
});
|
|
}
|
|
|
|
// Initialisation sur la page actuelle
|
|
initDescriptionTooltips();
|
|
|
|
// Observer pour détecter les nouveaux éléments ajoutés au DOM
|
|
const observer = new MutationObserver(mutations => {
|
|
mutations.forEach(mutation => {
|
|
mutation.addedNodes.forEach(node => {
|
|
if (node.nodeType === 1) { // élément HTML
|
|
if (node.matches('.description')) {
|
|
initDescriptionTooltips(node.parentNode);
|
|
} else {
|
|
// Si c'est un conteneur qui contient des .description
|
|
initDescriptionTooltips(node);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
// Observer sur tout le body
|
|
observer.observe(document.body, { childList: true, subtree: true }); |