Skip to content

Commit

Permalink
SAK-30529; fix close of user nav menu
Browse files Browse the repository at this point in the history
  • Loading branch information
clhedrick committed Mar 31, 2016
1 parent a90ef9d commit ea85c4b
Showing 1 changed file with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* ESC handler to dismiss user nav
*/

function userNavEscHandler(e){
if (e.keyCode === 27) { // esc keycode
toggleUserNav(e);
}
}

/**
* Toggle user nav in header:
*/
Expand All @@ -10,11 +20,16 @@ function toggleUserNav(event){
// Add an invisible overlay to allow clicks to close the dropdown

var overlay = $('<div class="user-dropdown-overlay" />');
overlay.on('click', function () { $(event.target).trigger('click'); });
overlay.on('click', function (e) {toggleUserNav(e)});

$('body').prepend(overlay);

// ESC key also closes it
$(document).on('keyup',userNavEscHandler);

} else {
$('.user-dropdown-overlay').remove();
$(document).off('keyup',userNavEscHandler);
}
}

Expand Down

0 comments on commit ea85c4b

Please sign in to comment.