diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-11-07 18:24:57 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-11-07 18:24:57 -0500 |
| commit | 5b801067f0da66191090465e72d1758826461fd3 (patch) | |
| tree | 8b02ce4443f7e5bbefb59c29ffa9219eaf02a56f /public/assets/javascripts/ui/reader/ReaderView.js | |
| parent | 22c4fd94cd4b3f5f881f0ad91597b7c208e89eff (diff) | |
| parent | f246a18bf02d2476b5f2bbc87a563b997b384a2c (diff) | |
merge
Diffstat (limited to 'public/assets/javascripts/ui/reader/ReaderView.js')
| -rw-r--r-- | public/assets/javascripts/ui/reader/ReaderView.js | 56 |
1 files changed, 49 insertions, 7 deletions
diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js index c132609..aea681a 100644 --- a/public/assets/javascripts/ui/reader/ReaderView.js +++ b/public/assets/javascripts/ui/reader/ReaderView.js @@ -13,22 +13,64 @@ var ReaderView = View.extend({ }, load: function(name){ - if (window.location.search.indexOf("noui") !== -1) { - $(".logo,.topLinks,#editorView").hide() + var opt = this.getQS() + var mode = "default" + var name = sanitize(name) + + if (opt.noui) { + $(".logo, .topLinks, #editorView, #keyhint").hide() + mode = "noui" } - else { - this.tracker = new Tracker () + if (opt.embed) { + $(".topLinks, .share, #edit-room-link, #keyhint").hide() + mode = "embed" } - if (window.location.search.indexOf("mute") !== -1) { + if (opt.mute) { app.muted = true } - name = sanitize(name) - $.get(this.projectAction + name, this.ready.bind(this)) + + this.tracker = new Tracker ({ mode: mode }) + + $.get(this.projectAction + name, this.ready.bind(this)) + }, + + getQS: function(){ + var qs = {} + window.location.search.replace(/^\?/,"").split("&").forEach(function(s){ + var pair = s.split("=") + if (pair.length < 2) { + qs[pair[0]] = true + } + else { + qs[pair[0]] = pair[1] + } + }) + return qs }, ready: function(data){ $("#map").hide() + this.data = data + var is_landscape = window.innerWidth > window.innerHeight + if (is_desktop || (is_mobile && is_landscape)) { + this.build(data) + return + } + + // don't build anything until we're in landscape mode, otherwise ios might crash + var orientationFn = orientationchange.bind(this) + window.addEventListener('orientationchange', orientationFn) + function orientationchange (e) { + var is_landscape = window.innerWidth > window.innerHeight + if (is_landscape) { + window.removeEventListener('orientationchange', orientationFn) + this.build(data) + } + } + }, + + build: function(data){ data.rooms && Rooms.deserialize(data.rooms) data.walls && Walls.deserialize(data.walls) data.media && Scenery.deserialize(data.media) |
