summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2014-09-30 12:36:42 -0400
committerJules Laplace <jules@okfoc.us>2014-09-30 12:36:42 -0400
commit742f4cc410bb04421800d7462f81fc64c59aa0bc (patch)
tree73eb5a73042e8064fc20868a69ae351116a0964d
parentc0c11162c5124f5452fe162b31d708be5ec40fcc (diff)
tracing menu appearing/disappearing logic ; set title from filename
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/move.js2
-rw-r--r--public/assets/javascripts/rectangles/engine/scenery/resize.js1
-rw-r--r--public/assets/javascripts/rectangles/models/wall.js5
-rw-r--r--public/assets/javascripts/ui/editor/EditorToolbar.js5
-rw-r--r--public/assets/javascripts/ui/editor/MediaEditor.js23
-rw-r--r--public/assets/javascripts/util.js4
6 files changed, 33 insertions, 7 deletions
diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js
index 93bccb0..55d6ef1 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/move.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/move.js
@@ -142,7 +142,7 @@ Scenery.move = function(base){
if (editor.permissions.resize) {
Scenery.resize.rotate_dots()
-// Scenery.resize.move_dots()
+ Scenery.resize.move_dots()
}
cursor.x.a = cursor.x.b
diff --git a/public/assets/javascripts/rectangles/engine/scenery/resize.js b/public/assets/javascripts/rectangles/engine/scenery/resize.js
index 532ca4e..dc1a39a 100644
--- a/public/assets/javascripts/rectangles/engine/scenery/resize.js
+++ b/public/assets/javascripts/rectangles/engine/scenery/resize.js
@@ -195,6 +195,7 @@ Scenery.resize = new function(){
}
function up (e, cursor){
+ if (! dragging) return
dragging = false
selected_dot = null
if (! editor.permissions.resize) { return }
diff --git a/public/assets/javascripts/rectangles/models/wall.js b/public/assets/javascripts/rectangles/models/wall.js
index 1a3ef7c..5513a9b 100644
--- a/public/assets/javascripts/rectangles/models/wall.js
+++ b/public/assets/javascripts/rectangles/models/wall.js
@@ -64,7 +64,10 @@
e.stopPropagation()
return
}
-
+
+ Scenery.resize.show(scenery)
+ Scenery.hovering = true
+
UndoStack.push({
type: 'create-scenery',
undo: { id: scenery.id },
diff --git a/public/assets/javascripts/ui/editor/EditorToolbar.js b/public/assets/javascripts/ui/editor/EditorToolbar.js
index bc56d88..9c74c7c 100644
--- a/public/assets/javascripts/ui/editor/EditorToolbar.js
+++ b/public/assets/javascripts/ui/editor/EditorToolbar.js
@@ -37,15 +37,18 @@ var EditorToolbar = View.extend({
this.resetMode()
this.resetControls()
},
-
+
resetMode: function(){
this.resizeMedia(true)
this.destroyMedia(false)
+ app.controller.hideExtras()
},
resetControls: function(){
+ $(".inuse").removeClass("inuse")
this.parent.wallpaperPicker.hide()
this.parent.lightControl.hide()
+ this.parent.settings.hide()
},
resizeMedia: function(e, state){
diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js
index cb57b69..eaa3134 100644
--- a/public/assets/javascripts/ui/editor/MediaEditor.js
+++ b/public/assets/javascripts/ui/editor/MediaEditor.js
@@ -3,7 +3,7 @@ var MediaEditor = FormView.extend({
el: "#mediaEditor",
events: {
- "keydown": 'stopPropagation',
+ "keydown": 'taint',
"focus [name]": "clearMinotaur",
"click [data-role=play-media]": "togglePaused",
"mousedown [name=keyframe]": "stopPropagation",
@@ -58,12 +58,16 @@ var MediaEditor = FormView.extend({
this.bind(scenery)
this.$el.addClass("active")
+// app.controller.toolbar.resetMode()
+ app.controller.toolbar.resetControls()
Scenery.resize.show(scenery)
Scenery.hovering = true
var media = scenery.media
- this.$name.val(media.title)
+ console.log(media)
+
+ this.$name.val(media.title || filenameFromUrl(media.url) )
this.$description.val(media.description)
this.setDimensions()
this.$units.val( "ft" )
@@ -101,12 +105,14 @@ var MediaEditor = FormView.extend({
seek: function(){
var n = parseFloat( this.$keyframe.val() )
this.scenery.seek(n)
+ this.tainted = true
this.scenery.media.keyframe = n
},
setAutoplay: function(){
var checked = this.$autoplay.prop('checked')
this.scenery.media.autoplay = checked
+ this.tainted = true
if (checked && this.scenery.paused()) {
this.togglePaused()
}
@@ -114,17 +120,20 @@ var MediaEditor = FormView.extend({
setLoop: function(){
var checked = this.$loop.prop('checked')
this.scenery.setLoop(checked)
+ this.tainted = true
},
setMute: function(){
var checked = this.$mute.prop('checked')
this.scenery.media.mute = checked
this.scenery.mute(checked)
+ this.tainted = true
},
setDimensions: function(){
if (! this.scenery) return
this.$width.unitVal( Number(this.scenery.naturalDimensions.a * this.scenery.scale) || "" )
this.$height.unitVal( Number(this.scenery.naturalDimensions.b * this.scenery.scale) || "" )
+ this.tainted = true
},
changeWidth: function(e){
e.stopPropagation()
@@ -140,6 +149,11 @@ var MediaEditor = FormView.extend({
app.units = this.$units.val()
this.$('.units').resetUnitVal()
},
+
+ taint: function(e){
+ e.stopPropagation()
+ this.tainted = true
+ },
bind: function(scenery){
this.scenery = scenery
@@ -148,7 +162,7 @@ var MediaEditor = FormView.extend({
},
unbind: function(){
- if (this.scenery) {
+ if (this.scenery && this.tainted) {
this.scenery.media.title = this.$name.val()
this.scenery.media.description = this.$description.val()
Minotaur.watch( app.router.editorView.settings )
@@ -158,11 +172,12 @@ var MediaEditor = FormView.extend({
this.scenery.mx.el.classList.remove("picked")
}
}
+ this.tainted = false
this.scenery = null
},
destroy: function(){
- ConfirmModal.confirm("Are you sure you want delete to this media?", function(){
+ ConfirmModal.confirm("Are you sure you want delete this object?", function(){
var scenery = this.scenery
this.hide()
Scenery.remove(scenery.id)
diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js
index 7812a4d..5a89c48 100644
--- a/public/assets/javascripts/util.js
+++ b/public/assets/javascripts/util.js
@@ -173,6 +173,10 @@ function invert_hash (h) {
for (var i in h) { if (h.hasOwnProperty(i)) k[h[i]] = i }
return k
}
+function filenameFromUrl (url) {
+ var partz = url.split( "/" )
+ return partz[partz.length-1].split(".")[0]
+}
function bitcount(v) {
v = v - ((v >>> 1) & 0x55555555);