summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/editor
diff options
context:
space:
mode:
authorJulie Lala <jules@okfoc.us>2014-08-15 09:26:10 -0400
committerJulie Lala <jules@okfoc.us>2014-08-15 09:26:10 -0400
commitaecaf2de2b4ed5277b34e9209a0f31602e8a7999 (patch)
tree78e46648032b91ebb0267e38f39f6227da7d8732 /public/assets/javascripts/ui/editor
parent02bde51c24ae1c6e189d031b80226e6a9f7cbc59 (diff)
parent1be685f9fe4a7f3a3e947d45f865fe07c03ddbaf (diff)
Merge branch 'walls' of github.com:okfocus/vvalls into walls
Diffstat (limited to 'public/assets/javascripts/ui/editor')
-rw-r--r--public/assets/javascripts/ui/editor/EditorSettings.js29
-rw-r--r--public/assets/javascripts/ui/editor/MediaEditor.js43
2 files changed, 58 insertions, 14 deletions
diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js
index d6a79fb..e9239e4 100644
--- a/public/assets/javascripts/ui/editor/EditorSettings.js
+++ b/public/assets/javascripts/ui/editor/EditorSettings.js
@@ -5,7 +5,7 @@ var EditorSettings = FormView.extend({
createAction: "/api/project/new",
updateAction: "/api/project/edit",
destroyAction: "/api/project/destroy",
-
+
events: {
"keydown": 'stopPropagation',
"keydown [name=name]": 'enterSubmit',
@@ -32,13 +32,17 @@ var EditorSettings = FormView.extend({
data.rooms && Rooms.deserialize(data.rooms)
data.startPosition && scene.camera.move(data.startPosition)
- if (! data.isNew) {
+ if (data.isNew) {
+ this.$name.val( "Room " + moment().format("DD/MM/YYYY ha") )
+ }
+ else {
// console.log(data)
+ this.thumbnailIsStale()
this.$id.val( data._id )
this.$name.val( data.name )
this.$description.val( data.description )
- data.privacy && this.$privacy.find("[value=" + data.privacy + "]").prop('checked', "checked")
+ data.privacy && this.$privacy.find("[value=" + data.privacy + "]").prop("checked", "checked")
data.media && Scenery.deserialize(data.media)
}
@@ -121,15 +125,32 @@ var EditorSettings = FormView.extend({
fd.append( "walls", JSON.stringify( Rooms.serializeWalls() ) )
fd.append( "media", JSON.stringify( Scenery.serialize() ) )
fd.append( "startPosition", JSON.stringify( app.position(scene.camera) ) )
- fd.append( "thumbnail", dataUriToBlob(map.canvas.toDataURL()) )
+
+ if (this.thumbnailIsStale()) {
+ fd.append( "thumbnail", dataUriToBlob(map.canvas.toDataURL()) )
+ }
return fd
},
+ thumbnailState: null,
+ thumbnailIsStale: function(){
+ var newState = JSON.stringify( Rooms.serialize() )
+
+ if (newState !== this.thumbnailState) {
+ this.thumbnailState = newState
+ return true
+ }
+ return false
+ },
+
success: function(data){
this.$id.val(data._id)
this.$name.val(data.name)
this.action = this.updateAction
+ Minotaur.unwatch(this)
+ Minotaur.hide()
+
window.history.pushState(null, document.title, "/project/" + data.slug + "/edit")
},
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js
index cd8fb63..cc924da 100644
--- a/public/assets/javascripts/ui/editor/MediaEditor.js
+++ b/public/assets/javascripts/ui/editor/MediaEditor.js
@@ -4,6 +4,7 @@ var MediaEditor = FormView.extend({
events: {
"keydown": 'stopPropagation',
+ "focus [name]": "clearMinotaur",
"click [data-role=play-media]": "togglePaused",
"mousedown [name=keyframe]": "stopPropagation",
"mousedown": "stopPropagation",
@@ -11,6 +12,9 @@ var MediaEditor = FormView.extend({
"change [name=autoplay]": "setAutoplay",
"change [name=loop]": "setLoop",
"change [name=mute]": "setMute",
+ "change [name=width]": 'changeWidth',
+ "change [name=height]": 'changeHeight',
+ "change [name=units]": 'changeUnits',
"click [data-role=destroy-media]": "destroy",
},
@@ -22,8 +26,8 @@ var MediaEditor = FormView.extend({
this.$description = this.$("[name=description]")
// image fields
- this.$widthDimension = this.$("[name=width]")
- this.$heightDimension = this.$("[name=height]")
+ this.$width = this.$("[name=width]")
+ this.$height = this.$("[name=height]")
this.$units = this.$("[name=units]")
// video fields
@@ -55,16 +59,14 @@ var MediaEditor = FormView.extend({
this.$name.val(media.title)
this.$description.val(media.description)
+ this.setDimensions()
+ this.$units.val( "ft" )
switch (media.type) {
case "image":
this.$(".image").show()
this.$(".video").hide()
-
- this.$widthDimension.val( Number(media.widthDimension) || "" )
- this.$heightDimension.val( Number(media.heightDimension) || "" )
- this.$units.val( media.units || "cm" )
-
+
break
case "youtube":
@@ -113,18 +115,39 @@ var MediaEditor = FormView.extend({
this.scenery.mute(checked)
},
+ setDimensions: function(){
+ this.$width.unitVal( Number(this.scenery.dimensions.a * this.scenery.scale) || "" )
+ this.$height.unitVal( Number(this.scenery.dimensions.b * this.scenery.scale) || "" )
+ },
+ changeWidth: function(e){
+ e.stopPropagation()
+ this.scenery.set_scale( this.$width.unitVal() / this.scenery.dimensions.a )
+ this.setDimensions()
+ },
+ changeHeight: function(e){
+ e.stopPropagation()
+ this.scenery.set_scale( this.$height.unitVal() / this.scenery.dimensions.b )
+ this.setDimensions()
+ },
+ changeUnits: function(){
+ app.units = this.$units.val()
+ this.$('.units').resetUnitVal()
+ },
+
bind: function(scenery){
this.scenery = scenery
this.scenery.mx.bound = true
},
unbind: function(){
- this.scenery.mx.bound = false
- this.scenery = null
+ if (this.scenery && this.scenery.mx) {
+ this.scenery.mx.bound = false
+ }
+ this.scenery = null
},
destroy: function(){
- ConfirmModal.confirm("Are you sure you want to this media?", function(){
+ ConfirmModal.confirm("Are you sure you want delete to this media?", function(){
var scenery = this.scenery
this.hide()
Scenery.remove(scenery.id)