From c267933fb823969f6a13e53c66f10898710f92a2 Mon Sep 17 00:00:00 2001 From: Eric Riggs Date: Thu, 8 Mar 2018 20:01:32 -0400 Subject: [PATCH] - Make navigation bar collapse work by code instead of CSS classes. - Collapse navigation bar on Escape key. Signed-off-by: Eric Riggs --- mayan/apps/appearance/static/appearance/js/base.js | 1 + .../appearance/static/appearance/js/mayan_app.js | 14 ++++++++++++++ .../navigation/generic_link_instance.html | 3 +-- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mayan/apps/appearance/static/appearance/js/base.js b/mayan/apps/appearance/static/appearance/js/base.js index cadcecfe01..0d66318699 100644 --- a/mayan/apps/appearance/static/appearance/js/base.js +++ b/mayan/apps/appearance/static/appearance/js/base.js @@ -9,6 +9,7 @@ var partialNavigation = new PartialNavigation({ jQuery(document).ready(function() { app.setupFullHeightResizing(); + app.setupNavbarCollapse(); partialNavigation.initialize(); }); diff --git a/mayan/apps/appearance/static/appearance/js/mayan_app.js b/mayan/apps/appearance/static/appearance/js/mayan_app.js index 2aad29d7a0..15325fa20b 100644 --- a/mayan/apps/appearance/static/appearance/js/mayan_app.js +++ b/mayan/apps/appearance/static/appearance/js/mayan_app.js @@ -194,6 +194,20 @@ App.prototype.setupAutoSubmit = function () { }); } +App.prototype.setupNavbarCollapse = function () { + $(document).keyup(function(e) { + if (e.keyCode === 27) { + $('.navbar-collapse').collapse('hide'); + } + }); + + $('body').on('click', 'a', function (event) { + if (!$(this).hasAnyClass(['dropdown-toggle'])) { + $('.navbar-collapse').collapse('hide'); + } + }); +} + App.prototype.setupNewWindowAnchor = function () { $('a.new_window').click(function (event) { event.preventDefault(); diff --git a/mayan/apps/appearance/templates/navigation/generic_link_instance.html b/mayan/apps/appearance/templates/navigation/generic_link_instance.html index de2c2376db..727b983df9 100644 --- a/mayan/apps/appearance/templates/navigation/generic_link_instance.html +++ b/mayan/apps/appearance/templates/navigation/generic_link_instance.html @@ -4,7 +4,7 @@ {% else %} {% if link.disabled %} - {% if link.icon %}{% endif %}{% if link.icon_class %}{{ link.icon_class.render }}{% endif %} {{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %} + {% if link.icon %}{% endif %}{% if link.icon_class %}{{ link.icon_class.render }}{% endif %} {{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %} {% else %} {% if link.icon %}{% endif %}{% if link.icon_class %}{{ link.icon_class.render }}{% endif %} {{ link.text }}{% if link.error %} - {{ link.error }}{% endif %}{% if horizontal %}{% if not forloop.last %} {% endif %}{% endif %} {% endif %} {% endif %}