drupal-erable/web/themes/erabletheme/js/erabletheme.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-11-30 17:33:32 +01:00
/**
* @file
* erabletheme behaviors.
*/
(function (Drupal) {
'use strict';
Drupal.behaviors.erabletheme = {
attach: function (context, settings) {
(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);
const hamburgerBtn = document.getElementById("hamburger");
const menu = hamburgerBtn.nextElementSibling;
// Toggle menu visibility on hamburger click
hamburgerBtn.addEventListener("click", function(event) {
event.stopPropagation();
menu.classList.toggle("active");
});
// Close menu when clicking outside of the menu
document.addEventListener("click", function(event) {
const isMenuClicked = event.target.closest("#menu") !== null;
const isHamburgerClicked = event.target === hamburgerBtn;
if (!isMenuClicked && !isHamburgerClicked) {
menu.classList.remove("active");
}
});
2023-11-30 17:33:32 +01:00
}
};
} (Drupal));