Implementation based on http://www.w3.org/TR/2011/WD-orientation-event-20111201/