Enabling clicking to close the context menu in Presentation Mode, without going to the next page

This PR is the third in a series of patches that will improve the presentation mode implementation. (The previous ones were #3752 and #3763.)

This patch enables the user to close the context menu without changing page unintentionally. Fixes #3276.
(The PR also moves the event listeners for the context menu items from `viewer.js` to `presentation_mode.js`.)