Move Presentation Mode related code from viewer.js to its own file

This PR is the first of in a series of patches that aims to make a couple of improvements (and simplifications) in the presentation mode code.
The current PR is just the first step, hence this patch only moves the presentation mode code to its own file.