Improve handling of JS environment detection under Browserify and browse...

Depending on the environment under which Dropbox-js is used,
there will be different ways to:

 - Access web APIs like XMLHttpRequest, base64 encoding, typed arrays
   etc.
 - Export Dropbox functionality for use by other code - eg. via
   module.exports or a property on `window` or `self`
 - Import functionality for use by Dropbox-js - eg. via require()

Previously there was an assumption that Dropbox-js was running
under one of three main types of environment - a browser, Node.js
or a web worker. The code first detected one of these types of
environment and set all of the above facets accordingly.

This broke apps in hybrid environments like Browserify which provide
both the `window` object but also a Node.js-like module environment for
example.

This commit refactors environment setup to deal with each of the facets
of the environment (web API access, module export, module import)
separately.

This fixes an issue where Dropbox-js did not work in a Browserify-like environment because it assumed it was running under Node.js. In Browserify this will use 'window' as the global (so we use native XHR + Dropbox' workarounds for various XHR quirks) but still export functionality via modules.export for use in other Browserify modules.