2023-11-30 17:33:32 +01:00
|
|
|
/**
|
|
|
|
* @file
|
|
|
|
* erabletheme behaviors.
|
|
|
|
*/
|
|
|
|
(function (Drupal) {
|
|
|
|
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Drupal.behaviors.erabletheme = {
|
|
|
|
attach: function (context, settings) {
|
|
|
|
|
2023-12-06 17:06:45 +01:00
|
|
|
(function($, window) {
|
|
|
|
let slickEl = $('.slick-container').children().first().children().first().children().first().children().first();
|
|
|
|
$(slickEl).slick({
|
|
|
|
arrows: false,
|
|
|
|
dots: true,
|
|
|
|
appendDots: $('#carousel_dots')
|
|
|
|
});
|
|
|
|
})(jQuery, window);
|
|
|
|
|
2023-12-14 06:01:09 +01:00
|
|
|
//
|
|
|
|
// Toggle du menu
|
|
|
|
//
|
2023-12-06 05:01:23 +01:00
|
|
|
const hamburgerBtn = document.getElementById("hamburger");
|
2023-12-14 06:01:09 +01:00
|
|
|
const hamburgerIcon = document.querySelector(".burger-icon");
|
2023-12-06 05:01:23 +01:00
|
|
|
const menu = hamburgerBtn.nextElementSibling;
|
2023-12-14 06:01:09 +01:00
|
|
|
const menuItems = menu.children;
|
|
|
|
const opacityDelay = 50;
|
|
|
|
|
|
|
|
function toggleMenuItems(action) {
|
|
|
|
let delay = opacityDelay;
|
|
|
|
for (let i = 0; i < menuItems.length; i++) {
|
|
|
|
setTimeout(() => {
|
|
|
|
if (action === 'show') {
|
|
|
|
menuItems[i].classList.add('visible');
|
|
|
|
} else if (action === 'hide') {
|
|
|
|
menuItems[menuItems.length - i - 1].classList.remove('visible');
|
|
|
|
}
|
|
|
|
}, delay);
|
|
|
|
delay += opacityDelay;
|
|
|
|
}
|
|
|
|
}
|
2023-12-06 05:01:23 +01:00
|
|
|
|
|
|
|
// Toggle menu visibility on hamburger click
|
|
|
|
hamburgerBtn.addEventListener("click", function(event) {
|
|
|
|
event.stopPropagation();
|
2023-12-14 06:01:09 +01:00
|
|
|
hamburgerIcon.classList.toggle('open');
|
|
|
|
if(menu.classList.contains('active')) {
|
|
|
|
setTimeout(() => {
|
|
|
|
menu.style.display = "none";
|
|
|
|
}, 700);
|
|
|
|
toggleMenuItems('hide');
|
|
|
|
} else {
|
|
|
|
menu.style.display = "block";
|
|
|
|
toggleMenuItems('show');
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
|
|
|
menu.classList.toggle("active");
|
|
|
|
}, 1);
|
|
|
|
|
2023-12-06 05:01:23 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
// Close menu when clicking outside of the menu
|
|
|
|
document.addEventListener("click", function(event) {
|
|
|
|
const isHamburgerClicked = event.target === hamburgerBtn;
|
2023-12-14 06:01:09 +01:00
|
|
|
const isMenuClicked = event.target === menu || event.target.parentElement === menu;
|
2023-12-06 05:01:23 +01:00
|
|
|
if (!isMenuClicked && !isHamburgerClicked) {
|
2023-12-14 06:01:09 +01:00
|
|
|
hamburgerIcon.classList.remove('open');
|
2023-12-06 05:01:23 +01:00
|
|
|
menu.classList.remove("active");
|
2023-12-14 06:01:09 +01:00
|
|
|
toggleMenuItems('hide');
|
2023-12-06 05:01:23 +01:00
|
|
|
}
|
|
|
|
});
|
2023-11-30 17:33:32 +01:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
} (Drupal));
|