Commit 4e0251a6 authored by Jaque's avatar Jaque Committed by Robert Lyon

Bug #1692757: Collapse main menu by pressing Esc key

Add js to hide navigation menu when focus is moved away
from menu or ESC is pressed

behatnotneeded

Change-Id: Ieefc13be65a8c2e7409e9336be13f0d42caa1ed7
parent f3170517
......@@ -257,5 +257,18 @@ jQuery(function($) {
$(".js-select2 select").select2({});
/*
* Close navigation when ESC is pressed or focus is moved from navigation menu
*/
$(document).on('click keyup', function(event) {
// keyESCAPE constant is used since jQuerty.ui is not loaded on all pages
var keyESCAPE = 27;
if (
(event.type=='click' && !$(event.target).closest('.navbar-toggle').length) ||
(event.type == 'keyup' && event.keyCode == keyESCAPE)
) {
$('.navbar-collapse.collapse.in').collapse('hide');
}
});
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment