mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-01-15 19:23:58 +01:00
Added dynamic submenus
This commit is contained in:
parent
d8ec067675
commit
7a66184a46
@ -106,3 +106,11 @@ h3.footer-title{
|
|||||||
left: 100%; /* Positioniert das Submenü rechts vom Hauptmenü */
|
left: 100%; /* Positioniert das Submenü rechts vom Hauptmenü */
|
||||||
margin-top: -1px;
|
margin-top: -1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dropdown-menu.collapse {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-menu.collapse.show {
|
||||||
|
display: block;
|
||||||
|
}
|
21
app/static/js/close-submenus.js
Normal file
21
app/static/js/close-submenus.js
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
|
const dropdownSubmenus = document.querySelectorAll('.dropdown-submenu > .dropdown-item');
|
||||||
|
|
||||||
|
dropdownSubmenus.forEach((submenu) => {
|
||||||
|
submenu.addEventListener('click', (event) => {
|
||||||
|
event.preventDefault();
|
||||||
|
const targetMenu = document.querySelector(submenu.getAttribute('data-bs-target'));
|
||||||
|
const allSubmenus = document.querySelectorAll('.dropdown-menu.collapse');
|
||||||
|
|
||||||
|
// Schließe alle anderen Submenüs
|
||||||
|
allSubmenus.forEach((menu) => {
|
||||||
|
if (menu !== targetMenu) {
|
||||||
|
menu.classList.remove('show');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Toggle des aktuellen Submenüs
|
||||||
|
targetMenu.classList.toggle('show');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -39,6 +39,7 @@
|
|||||||
<!-- Include modal -->
|
<!-- Include modal -->
|
||||||
{% include "moduls/modal.html.j2" %}
|
{% include "moduls/modal.html.j2" %}
|
||||||
<script src="{{ url_for('static', filename='js/dynamic-modal.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/dynamic-modal.js') }}"></script>
|
||||||
|
<script src="{{ url_for('static', filename='js/close-submenus.js') }}"></script>
|
||||||
<script src="{{ url_for('static', filename='js/tooltip.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/tooltip.js') }}"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
@ -3,33 +3,34 @@
|
|||||||
{% for subitem in subitems %}
|
{% for subitem in subitems %}
|
||||||
{% if subitem.subitems %}
|
{% if subitem.subitems %}
|
||||||
<li class="dropdown-submenu">
|
<li class="dropdown-submenu">
|
||||||
<a class="dropdown-item" title="{{ subitem.description }}">
|
<a class="dropdown-item dropdown-toggle" href="#" id="submenu-{{ loop.index }}" data-bs-toggle="collapse" data-bs-target="#submenu-content-{{menu_type}}-{{ loop.index }}" aria-expanded="false" title="{{ subitem.description }}">
|
||||||
<i class="{{ subitem.icon.class }}"></i> {{ subitem.name }}
|
<i class="{{ subitem.icon.class }}"></i> {{ subitem.name }}
|
||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-submenu">
|
<ul class="dropdown-menu collapse" id="submenu-content-{{menu_type}}-{{ loop.index }}">
|
||||||
{{ render_subitems(subitem.subitems) }}
|
{{ render_subitems(subitem.subitems) }}
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
{% elif subitem.popup %}
|
{% elif subitem.popup %}
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item" onclick='openDynamicPopup({{subitem|tojson|safe}})' data-bs-toggle="tooltip" title="{{ subitem.description }}">
|
<a class="dropdown-item" onclick='openDynamicPopup({{ subitem|tojson|safe }})' data-bs-toggle="tooltip" title="{{ subitem.description }}">
|
||||||
<i class="{{ subitem.icon.class }}"></i> {{ subitem.name }}
|
<i class="{{ subitem.icon.class }}"></i> {{ subitem.name }}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% else %}
|
{% else %}
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item" href="{{ subitem.href }}" target="{{ subitem.target|default('_blank') }}" data-bs-toggle="tooltip" title="{{ subitem.description }}">
|
<a class="dropdown-item" href="{{ subitem.href }}" target="{{ subitem.target|default('_blank') }}" data-bs-toggle="tooltip" title="{{ subitem.description }}">
|
||||||
{% if subitem.icon is defined and subitem.icon.class is defined %}
|
{% if subitem.icon is defined and subitem.icon.class is defined %}
|
||||||
<i class="{{ subitem.icon.class }}"></i> {{ subitem.name }}
|
<i class="{{ subitem.icon.class }}"></i> {{ subitem.name }}
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>Fehlendes Icon im Subitem: {{ subitem }}</p>
|
<p>Fehlendes Icon im Subitem: {{ subitem }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
<!-- Navigation Bar -->
|
<!-- Navigation Bar -->
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
|
Loading…
Reference in New Issue
Block a user