Improve offline detection. (#13250)

This patch is almost a copied and pasted solution for touchkit 3.0
taken from https://dev.vaadin.com/review/#/c/3376/

- Move offline/online detection to entry-point so as we dont depend
  on the connector being loaded if we are disconnected.
- Listen for HTML-5 online/offline events
- Listen for Phonegap (Cordova) events
- Listen for postMessage events when the app is in an iframe, so
  as parent cordova iframe can communicate with the app.
- Exported a couple of JS methods to force offline/online from
  the console: tkGoOffline() tkGoOnline()
- Some other tricks to make android behave well

Change-Id: I26441f84a9101534acc66c583e38895d1c7da7b9