Añadida funcionalidad de marcar el menu que esta activo

This commit is contained in:
unknown
2025-05-05 11:23:34 +02:00
parent ff648fec87
commit 4afcf05049
6 changed files with 35 additions and 242 deletions

View File

@ -152,7 +152,8 @@ $picture = "/assets/img/default-user.png";
<div class="sidebar-body">
<!-- Contacts -->
<h6 id="chat-message-notification-title">
<?= lang("Chat.no_messages_notification") ?> </h6>
<?= lang("Chat.no_messages_notification") ?>
</h6>
<ul class="list-unstyled chat-contact-list mb-0"
id="chat-notification-list">
@ -413,6 +414,31 @@ $picture = "/assets/img/default-user.png";
document.addEventListener('DOMContentLoaded', function () {
const browserUrl = window.location.pathname;
document.querySelectorAll('.menu-item a.menu-link').forEach(function (link) {
const href = link.getAttribute('href');
if (!href || href === 'javascript:void(0);') return;
const tempAnchor = document.createElement('a');
tempAnchor.href = href;
const linkPath = tempAnchor.pathname;
// Comparación exacta de ruta
if (browserUrl === linkPath) {
const menuItem = link.closest('.menu-item');
menuItem.classList.add('active');
const parent = menuItem.closest('.menu-sub');
if (parent) {
const parentItem = parent.closest('.menu-item');
if (parentItem) {
parentItem.classList.add('active', 'open');
}
}
}
});
function adjustSidebar4ContentWrapper() {
if ($('#sidebar').hasClass('d-none') && $(window).width() <= 768) {
$('#contentWrapper').addClass('full-width');