summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/reader
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui/reader')
-rw-r--r--public/assets/javascripts/ui/reader/EmbedView.js50
-rw-r--r--public/assets/javascripts/ui/reader/ReaderView.js1
-rw-r--r--public/assets/javascripts/ui/reader/ShareView.js40
3 files changed, 86 insertions, 5 deletions
diff --git a/public/assets/javascripts/ui/reader/EmbedView.js b/public/assets/javascripts/ui/reader/EmbedView.js
new file mode 100644
index 0000000..a0b3c6f
--- /dev/null
+++ b/public/assets/javascripts/ui/reader/EmbedView.js
@@ -0,0 +1,50 @@
+var EmbedView = ModalView.extend({
+ el: ".embedView",
+
+ events: {
+ "keydown": "stopPropagation",
+ "input [name=width]": "build",
+ "input [name=height]": "build",
+ "click [name=mute]": "build",
+ "click textarea": "selectAll",
+ },
+
+ defaultWidth: 600,
+ defaultHeight: 450,
+
+ initialize: function(opt){
+ this.parent = opt.parent
+ this.$embedCode = this.$("#embedCode")
+ this.$width = this.$("[name=width]")
+ this.$height = this.$("[name=height]")
+ this.$mute = this.$("[name=mute]")
+
+ this.$width.val(this.defaultWidth)
+ this.$height.val(this.defaultHeight)
+ },
+
+ show: function(){
+ this.build()
+ this.__super__.show.call(this)
+ },
+
+ build: function(){
+ var mute = this.$mute.prop('checked') ? 1 : 0
+ var width = clamp( this.$width.int(), 0, 2000) || this.defaultWidth
+ var height = clamp( this.$height.int(), 0, 2000) || this.defaultHeight
+ var link = this.parent.getLink()
+ link += "?mute=" + mute
+// link += "&noui=1"
+ var kode = "<iframe src='" + encodeURI(link) + "' width='" + width + "' height='" + height + "'"
+ + " seamless scrolling='no' style='border: 0'"
+ + " webkitAllowFullScreen mozallowfullscreen allowfullscreen"
+ + "></iframe>"
+
+ this.$embedCode.val( kode )
+ },
+
+ selectAll: function(){
+ this.$embedCode[0].select()
+ },
+
+})
diff --git a/public/assets/javascripts/ui/reader/ReaderView.js b/public/assets/javascripts/ui/reader/ReaderView.js
index c132609..9e0d21e 100644
--- a/public/assets/javascripts/ui/reader/ReaderView.js
+++ b/public/assets/javascripts/ui/reader/ReaderView.js
@@ -29,6 +29,7 @@ var ReaderView = View.extend({
ready: function(data){
$("#map").hide()
+ this.data = data
data.rooms && Rooms.deserialize(data.rooms)
data.walls && Walls.deserialize(data.walls)
data.media && Scenery.deserialize(data.media)
diff --git a/public/assets/javascripts/ui/reader/ShareView.js b/public/assets/javascripts/ui/reader/ShareView.js
index 4e5f832..dbe6f64 100644
--- a/public/assets/javascripts/ui/reader/ShareView.js
+++ b/public/assets/javascripts/ui/reader/ShareView.js
@@ -2,31 +2,61 @@ var ShareView = View.extend({
el: ".share",
events: {
+ "keydown": "stopPropagation",
"click #share_facebook": "facebook",
"click #share_twitter": "twitter",
+ "click #share_embed": "embed",
},
initialize: function(opt){
this.parent = opt.parent
+ this.embedView = new EmbedView ({ parent: this })
+ this.$link = this.$("#share_link")
+ },
+
+ toggle: function(state){
+ if (typeof state == "boolean") {
+ this.$el.toggleClass("active", state)
+ }
+ else {
+ this.$el.toggleClass("active")
+ }
+ },
+ show: function(){
+ this.toggle(true)
+ },
+ hide: function(){
+ this.toggle(false)
+ },
+
+ setLink: function(url){
+ this.$link.val( url )
+ },
+ getLink: function(){
+ var link = window.location.origin + window.location.pathname
+ link = link.replace(/\/edit\/?$/, "")
+ return link
},
facebook: function (e) {
e.preventDefault()
- var msg = $(".roomName").html() + " on VValls"
- var url = "https://www.facebook.com/share.php?u=" + encodeURIComponent(window.location.origin + window.location.pathname) + "&t=" + encodeURIComponent(msg);
+ var link = this.getLink()
+ var msg = app.controller.data.name + " on VValls"
+ var url = "https://www.facebook.com/share.php?u=" + encodeURIComponent(link) + "&t=" + encodeURIComponent(msg)
window.open(url, "_blank")
},
twitter: function (e) {
e.preventDefault()
- var msg = $(".roomName").html() + " on VValls"
- var url = "https://twitter.com/home?status=" + encodeURIComponent(window.location.origin + window.location.pathname + " " + msg);
+ var link = this.getLink()
+ var msg = app.controller.data.name + " on VValls"
+ var url = "https://twitter.com/home?status=" + encodeURIComponent(link + " " + msg)
window.open(url, "_blank")
},
embed: function (e) {
e.preventDefault()
-
+ this.embedView.show()
},
})