From b9cf4175a3882415824f707a5431222e352658b2 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 10 Nov 2014 16:42:30 -0500 Subject: cancel scenery for text --- public/assets/javascripts/ui/editor/TextEditor.js | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'public/assets/javascripts/ui/editor/TextEditor.js') diff --git a/public/assets/javascripts/ui/editor/TextEditor.js b/public/assets/javascripts/ui/editor/TextEditor.js index 51077af..33b5386 100644 --- a/public/assets/javascripts/ui/editor/TextEditor.js +++ b/public/assets/javascripts/ui/editor/TextEditor.js @@ -25,6 +25,11 @@ var TextEditor = FormView.extend({ this.$fontSize = this.$("[name=font-size]") this.$textBody = this.$("[name=text-body]") this.$textAlign = this.$("[name=text-align]") + + app.on("cancel-scenery", function(){ + this.createMode(true) + $("body").toggleClass("addText", false) + }.bind(this)) }, toggle: function(state){ -- cgit v1.2.3-70-g09d2 From 3ab0c6c24b95552feb111b647205cc92c3ca170c Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 13 Nov 2014 11:46:43 -0500 Subject: delete text object if no text --- public/assets/javascripts/rectangles/engine/scenery/types/_object.js | 3 +++ public/assets/javascripts/ui/editor/TextEditor.js | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui/editor/TextEditor.js') diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js index 51d1b88..cd3f981 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js @@ -116,6 +116,9 @@ Scenery.types.base = Fiber.extend(function(base){ }, remove: function(){ + if (this.removed) return + this.removed = true + UndoStack.push({ type: 'destroy-scenery', undo: this.serialize(), diff --git a/public/assets/javascripts/ui/editor/TextEditor.js b/public/assets/javascripts/ui/editor/TextEditor.js index 33b5386..2949943 100644 --- a/public/assets/javascripts/ui/editor/TextEditor.js +++ b/public/assets/javascripts/ui/editor/TextEditor.js @@ -75,11 +75,13 @@ var TextEditor = FormView.extend({ if (this.tainted) { Minotaur.watch( app.router.editorView.settings ) } - if (this.scenery.mx) { this.scenery.mx.bound = false this.scenery.mx.el.classList.remove("picked") } + if (! this.scenery.media || ! this.scenery.media.description || this.scenery.media.description == "") { + this.scenery.remove() + } } this.tainted = false this.scenery = null @@ -143,6 +145,7 @@ var TextEditor = FormView.extend({ destroy: function(){ this.tainted = false this.scenery.remove() + this.hide() }, }) -- cgit v1.2.3-70-g09d2