summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/reader/ReaderView.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui/reader/ReaderView.js')
-rw-r--r--public/assets/javascripts/ui/reader/ReaderView.js56
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)