jQuery(document).ready(function($) {
// Cache selectors for performance
var $headerUserName = $('.header-user-name');
var $headerUserMenu = $('.head-user-menu');
var $navButtonWrap = $('.nav-button-wrap.color-bg');
var $mainMenu = $('.main-menu');
// Function to hide all menus
function hideAllMenus() {
$headerUserMenu.removeClass('hu-menu-vis');
$headerUserName.removeClass('hu-menu-visdec');
$mainMenu.removeClass('vismobmenu');
}
// Click event for header user name menu
$headerUserName.on('click', function(e) {
e.preventDefault(); // Prevent default action if it's a link
hideAllMenus();
$headerUserMenu.addClass('hu-menu-vis');
$headerUserName.addClass('hu-menu-visdec');
});
// Click event for main menu
$navButtonWrap.on('click', function(e) {
e.preventDefault(); // Prevent default action if it's a link
hideAllMenus();
$mainMenu.addClass('vismobmenu');
});
// Optional: Hide menus if clicking outside of them
$(document).on('click', function(e) {
if (!$(e.target).closest('.header-user-name, .head-user-menu, .nav-button-wrap.color-bg, .main-menu').length) {
hideAllMenus();
}
});
});