Skip to content

Instantly share code, notes, and snippets.

@lean8086
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lean8086/9379744 to your computer and use it in GitHub Desktop.
Save lean8086/9379744 to your computer and use it in GitHub Desktop.
Improve the #navigation-menu behavior
(function (doc) {
var input = doc.getElementById('ml-header-user');
// Only works when a user menu exists (for logged users)
if (!input) return;
// Listen for every click on <html>
// The support for IE8+ was dropped because of lack of support of :checked pseudo-selector
doc.documentElement.addEventListener('click', function (ev) {
// Avoid to close if I click on the trigger. In that case, it will use CSS
if (input.checked && ev.target !== input && ev.target !== input.previousElementSibling) input.checked = false;
});
}(document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment