First version, for githup; UNSTABLE, DO NOT USE!
This commit is contained in:
52
www/intern/js/header.js
Normal file
52
www/intern/js/header.js
Normal file
@@ -0,0 +1,52 @@
|
||||
$(document).ready(function () {
|
||||
$('.menuLinksDiv>div').hover(function () {
|
||||
const $this = $(this);
|
||||
clearTimeout($this.data('hoverTimeout'));
|
||||
$this.find('.dropdown').stop(true, false).slideDown(200);
|
||||
$this.addClass('open');
|
||||
}, function () {
|
||||
const $this = $(this);
|
||||
const timeout = setTimeout(function () {
|
||||
$this.find('.dropdown').stop(true, false).slideUp(200);
|
||||
$this.removeClass('open');
|
||||
}, 200); // Small delay to prevent flickering
|
||||
$this.data('hoverTimeout', timeout);
|
||||
});
|
||||
$('.sidebar>div').on('click', function (e) {
|
||||
if ($(e.target).closest('.dropdown').length) {
|
||||
return;
|
||||
}
|
||||
if (!$(this).hasClass('open')) {
|
||||
$('.sidebar>div.open').removeClass('open').find('.dropdown').slideUp();
|
||||
$(this).addClass('open');
|
||||
$(this).find('.dropdown').slideDown();
|
||||
} else {
|
||||
$(this).find('.dropdown').slideUp();
|
||||
$(this).removeClass('open');
|
||||
}
|
||||
});
|
||||
$(document).on('click', function (e) {
|
||||
// If sidebar is not active, do nothing
|
||||
if ($(e.target).closest('.burgerMenuDiv').length) {
|
||||
$('.burgerMenuDiv').toggleClass('active');
|
||||
$('.sidebar').toggleClass('active');
|
||||
return;
|
||||
}
|
||||
|
||||
if (!$('.sidebar').hasClass('active')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If click is inside the sidebar or burger menu, do nothing
|
||||
if (
|
||||
$(e.target).closest('.sidebar').length ||
|
||||
$(e.target).closest('.burgerMenuDiv').length
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, close the sidebar
|
||||
$('.sidebar').removeClass('active');
|
||||
$('.burgerMenuDiv').removeClass('active');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user