Resolve #3441346 "Event listener fixes"
Related to #3441346
- Checks if the menu is open before trying to close it (behaviour from !88)
- Moves all document level event listeners into the init() function so they're only added once. Previously they were added every time the menu closed, and for each menu link.
- Merges duplicate mobile and desktop event listeners for closing the menu when a click is detected outside. If the behaviour is the same on desktop and on mobile then we only need one. I think this is fairly standard behaviour which the user would expect, but if not we should make a configuration option to disable it rather than tying it to something arbitrary like whether or not the menu has arrows.