Optimized javascript code for sidebar menu

This commit is contained in:
Pedro Moreno 2023-02-15 11:07:27 +01:00
parent 6af3ff81a1
commit c17bf36b24
2 changed files with 13 additions and 14 deletions

View file

@ -45,3 +45,15 @@
{% endif %}
</ul>
{% endblock %}
{% block javascripts %}
<script>
if ((window.innerWidth || document.documentElement.clientWidth) < 980){
/* Script for dropdown menu in sidebar */
$(".subitem_hide").hide(); /* this hides the list initially */
$(".dropdown-btn").click(function () {
$(this).next(".subitem_hide").slideToggle();
});
}
</script>
{% endblock %}

View file

@ -47,17 +47,4 @@
</section>
{% endif %}
</section>
<script>
{% if p.routable == false and p.children.count > 0 %}
$(".subitem_hide").hide(); // this hides the list initially
$(".dropdown-btn").click(function () {
$(this).next(".subitem_hide").slideToggle();
});
{% else %}
$(".subitem").attr("style", "display:block"); // this shows the list if it is routable
$(".dropdown-btn").click(function () {
$(this).next(".subitem_hide").slideToggle();
});
{% endif %}
</script>
</section>