summaryrefslogtreecommitdiff
path: root/public/assets/javascripts
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts')
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js10
-rw-r--r--public/assets/javascripts/ui/editor/EditorView.js4
-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
-rw-r--r--public/assets/javascripts/util.js13
6 files changed, 111 insertions, 7 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index 2b29961..026607a 100644
--- a/public/assets/javascripts/ui/editor/EditorSettings.js
+++ b/public/assets/javascripts/ui/editor/EditorSettings.js
@@ -110,7 +110,6 @@ var EditorSettings = FormView.extend({
clear: function(e){
e.preventDefault()
-
Scenery.removeAll()
},
@@ -215,6 +214,7 @@ var EditorSettings = FormView.extend({
clickSave: function(){
this.toggle(false)
this.save()
+ this.isVisible = true
},
success: function(data){
@@ -226,7 +226,13 @@ var EditorSettings = FormView.extend({
Minotaur.hide()
window.history.pushState(null, document.title, "/project/" + data.slug + "/edit")
-
+
+ this.parent.share.setLink( "http://vvalls.com/project/" + data.slug )
+ if (this.isVisible) {
+ this.isVisible = false
+ this.parent.share.show()
+ }
+
this.parent.data = data
},
diff --git a/public/assets/javascripts/ui/editor/EditorView.js b/public/assets/javascripts/ui/editor/EditorView.js
index 2872ab9..3773366 100644
--- a/public/assets/javascripts/ui/editor/EditorView.js
+++ b/public/assets/javascripts/ui/editor/EditorView.js
@@ -21,6 +21,7 @@ var EditorView = View.extend({
this.textEditor = new TextEditor ({ parent: this })
this.collaborators = new Collaborators ({ parent: this })
this.presets = new Presets ({ parent: this })
+ this.share = new ShareView ({ parent: this })
},
load: function(name){
@@ -41,6 +42,8 @@ var EditorView = View.extend({
ready: function(data){
$("#map").hide()
+ this.data = data
+
this.settings.load(data)
this.info.load(data)
},
@@ -70,6 +73,7 @@ var EditorView = View.extend({
hideExtras: function(){
this.mediaEditor.hide()
this.textEditor.hide()
+ this.share.hide()
Scenery.resize.hide()
Scenery.hovering = false
}
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()
},
})
diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js
index 2fa994a..1749836 100644
--- a/public/assets/javascripts/util.js
+++ b/public/assets/javascripts/util.js
@@ -239,4 +239,17 @@ if (!Function.prototype.bind) {
}());
+function selectElementContents(el) {
+ if (window.getSelection && document.createRange) {
+ var sel = window.getSelection();
+ var range = document.createRange();
+ range.selectNodeContents(el);
+ sel.removeAllRanges();
+ sel.addRange(range);
+ } else if (document.selection && document.body.createTextRange) {
+ var textRange = document.body.createTextRange();
+ textRange.moveToElementText(el);
+ textRange.select();
+ }
+}