online / offline events should be attached to window rather than document.body

Issue #551