var IntroView = View.extend({ el: "#intro", events: { "click .store": "store", "click .hub": "hub", "click .story": "story", "click .archive": "archive", }, initialize: function(){ this.compass = this.$("#compass").get(0) this.orient = this.deviceorientation.bind(this) }, show: function(){ this.$el.show() window.addEventListener("deviceorientation", this.orient) // get location.. }, hide: function(){ this.$el.hide() window.removeEventListener("deviceorientation", this.orient) }, deviceorientation: function(e){ var heading if ('webkitCompassHeading' in e) { heading = e.webkitCompassHeading } else { heading = e.alpha } this.compass.css[transformProp] = "translateZ(0) rotate(" + heading + "deg)" }, store: function(){ app.router.go("store") }, hub: function(){ app.router.go("hub") }, story: function(){ app.router.go("story") }, archive: function(){ app.router.go("archive") }, })