From a49023a991c62595fc5c449729be4cc313ff66a7 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Mon, 3 Nov 2014 16:59:45 -0500 Subject: fix undo scenery create/destroy --- public/assets/javascripts/ui/editor/MediaEditor.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 9b81db1..9a3c355 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -161,7 +161,7 @@ var MediaEditor = FormView.extend({ unbind: function(){ if (this.scenery) { - if (this.tainted) { + if (this.tainted && this.scenery.media) { this.scenery.media.title = this.$name.val() this.scenery.media.description = this.$description.val() Minotaur.watch( app.router.editorView.settings ) @@ -178,8 +178,20 @@ var MediaEditor = FormView.extend({ destroy: function(){ var scenery = this.scenery this.hide() + + UndoStack.push({ + type: 'destroy-scenery', + undo: scenery.serialize(), + redo: { id: scenery.id }, + }) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + Scenery.remove(scenery.id) Scenery.resize.hide() + this.tainted = false + this.scenery = null }, }) -- cgit v1.2.3-70-g09d2 From 94f25dc59aa1066321a23a5c2f00521dea87fbc0 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 4 Nov 2014 14:05:10 -0500 Subject: backspace shortcut to delete scenery --- .../javascripts/mx/extensions/mx.movements.js | 11 +++++- .../javascripts/rectangles/engine/scenery/move.js | 12 +------ .../rectangles/engine/scenery/types/_object.js | 39 +++++++++++++++++----- public/assets/javascripts/ui/editor/MediaEditor.js | 13 ++------ public/assets/javascripts/ui/editor/TextEditor.js | 6 ++-- 5 files changed, 46 insertions(+), 35 deletions(-) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/mx/extensions/mx.movements.js b/public/assets/javascripts/mx/extensions/mx.movements.js index dc9660b..1ba33c9 100644 --- a/public/assets/javascripts/mx/extensions/mx.movements.js +++ b/public/assets/javascripts/mx/extensions/mx.movements.js @@ -62,7 +62,7 @@ MX.Movements = function (cam) { }, keydown: function (e) { - // console.log(e.keyCode) + console.log(e.keyCode) if (locked || e.altKey || e.metaKey || e.ctrlKey) { return } @@ -155,6 +155,15 @@ MX.Movements = function (cam) { app.controller.toolbar.toggleMap() } break + + case 8: // backspace + e.preventDefault() + if (app.controller.mediaEditor.scenery) { + app.controller.mediaEditor.scenery.remove() + } + else if (app.controller.textEditor.scenery) { + app.controller.textEditor.scenery.remove() + } } }, diff --git a/public/assets/javascripts/rectangles/engine/scenery/move.js b/public/assets/javascripts/rectangles/engine/scenery/move.js index 13580a8..12705d3 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/move.js +++ b/public/assets/javascripts/rectangles/engine/scenery/move.js @@ -22,19 +22,9 @@ Scenery.move = function(base){ } function down (e, cursor){ - console.log(e.target, base.mx.overlay) if (e.target != base.mx.el && (e.target != base.mx.overlay)) return; if (editor.permissions.destroy) { - UndoStack.push({ - type: 'destroy-scenery', - undo: base.serialize(), - redo: { id: base.id }, - }) - - // TODO: watch individual scenery object here - Minotaur.watch( app.router.editorView.settings ) - - Scenery.remove(base.id) + base.remove() return } diff --git a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js index 4e5e2c5..10ba2b0 100644 --- a/public/assets/javascripts/rectangles/engine/scenery/types/_object.js +++ b/public/assets/javascripts/rectangles/engine/scenery/types/_object.js @@ -62,20 +62,43 @@ Scenery.types.base = Fiber.extend(function(base){ bind: function(){ this.move.bind() - $(this.mx.el).bind({ - mouseenter: this.enter, - mouseleave: this.leave, - }) +// $(this.mx.el).bind({ +// mouseenter: this.enter, +// mouseleave: this.leave, +// }) }, unbind: function(){ this.move.unbind() - $(this.mx.el).unbind({ - mouseenter: this.enter, - mouseleave: this.leave, - }) +// $(this.mx.el).unbind({ +// mouseenter: this.enter, +// mouseleave: this.leave, +// }) }, + remove: function(){ + UndoStack.push({ + type: 'destroy-scenery', + undo: this.serialize(), + redo: { id: this.id }, + }) + + // TODO: watch individual scenery object here + Minotaur.watch( app.router.editorView.settings ) + + Scenery.remove(this.id) + + Scenery.resize.hide() + if (app.controller.mediaEditor) { + app.controller.mediaEditor.tainted = false + app.controller.mediaEditor.hide() + } + if (app.controller.textEditor) { + app.controller.textEditor.tainted = false + app.controller.textEditor.hide() + } + }, + destroy: function(){ this.unbind() scene.remove(this.mx) diff --git a/public/assets/javascripts/ui/editor/MediaEditor.js b/public/assets/javascripts/ui/editor/MediaEditor.js index 9a3c355..db5878f 100644 --- a/public/assets/javascripts/ui/editor/MediaEditor.js +++ b/public/assets/javascripts/ui/editor/MediaEditor.js @@ -179,17 +179,8 @@ var MediaEditor = FormView.extend({ var scenery = this.scenery this.hide() - UndoStack.push({ - type: 'destroy-scenery', - undo: scenery.serialize(), - redo: { id: scenery.id }, - }) - - // TODO: watch individual scenery object here - Minotaur.watch( app.router.editorView.settings ) - - Scenery.remove(scenery.id) - Scenery.resize.hide() + scenery.remove() + this.tainted = false this.scenery = null }, diff --git a/public/assets/javascripts/ui/editor/TextEditor.js b/public/assets/javascripts/ui/editor/TextEditor.js index b559ba5..51077af 100644 --- a/public/assets/javascripts/ui/editor/TextEditor.js +++ b/public/assets/javascripts/ui/editor/TextEditor.js @@ -136,10 +136,8 @@ var TextEditor = FormView.extend({ }, destroy: function(){ - var scenery = this.scenery - this.hide() - Scenery.remove(scenery.id) - Scenery.resize.hide() + this.tainted = false + this.scenery.remove() }, }) -- cgit v1.2.3-70-g09d2 From 43b211e416fb7154079586de7b75807bd1a5ac28 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 4 Nov 2014 15:00:00 -0500 Subject: use minotaur --- public/assets/javascripts/ui/editor/EditorSettings.js | 2 ++ public/assets/javascripts/ui/lib/FormView.js | 8 ++++++++ 2 files changed, 10 insertions(+) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index b96943e..de60b53 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -5,6 +5,8 @@ var EditorSettings = FormView.extend({ createAction: "/api/project/new", updateAction: "/api/project/edit", destroyAction: "/api/project/destroy", + + useMinotaur: true, events: { "mousedown": "stopPropagation", diff --git a/public/assets/javascripts/ui/lib/FormView.js b/public/assets/javascripts/ui/lib/FormView.js index 17b748a..b3a4c71 100644 --- a/public/assets/javascripts/ui/lib/FormView.js +++ b/public/assets/javascripts/ui/lib/FormView.js @@ -1,6 +1,7 @@ var FormView = View.extend({ method: "post", + useMinotaur: false, events: { "submit form": "save" @@ -88,8 +89,15 @@ var FormView = View.extend({ processData: false, contentType: false, }) + + if (this.useMinotaur) { + Minotaur.show() + } request.done($.proxy(function (response) { + if (this.useMinotaur) { + Minotaur.hide() + } if (response.error) { var errors = [] for (var key in response.error.errors) { -- cgit v1.2.3-70-g09d2 From 3d8490dacba1b3020b9e1dd926ce99edfee48375 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Tue, 4 Nov 2014 15:44:45 -0500 Subject: toggle map link in settings --- public/assets/javascripts/ui/editor/EditorSettings.js | 6 ++++++ views/controls/editor/settings.ejs | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) (limited to 'public/assets/javascripts/ui/editor') diff --git a/public/assets/javascripts/ui/editor/EditorSettings.js b/public/assets/javascripts/ui/editor/EditorSettings.js index de60b53..2b29961 100644 --- a/public/assets/javascripts/ui/editor/EditorSettings.js +++ b/public/assets/javascripts/ui/editor/EditorSettings.js @@ -17,6 +17,7 @@ var EditorSettings = FormView.extend({ "click [data-role='clone-project']": 'clone', "click [data-role='clear-project']": 'clear', "click [data-role='destroy-project']": 'destroy', + "click [data-role='toggle-map']": 'toggleMap', "click #startText": "setStartPosition", "click #moveText": "confirmStartPosition", "click #confirmText": "setStartPosition", @@ -83,6 +84,11 @@ var EditorSettings = FormView.extend({ this.parent.collaborators.show() }, + toggleMap: function(e){ + e.preventDefault() + app.controller.toolbar.toggleMap() + }, + clone: function(e){ e.preventDefault() diff --git a/views/controls/editor/settings.ejs b/views/controls/editor/settings.ejs index 8443abb..197ad43 100644 --- a/views/controls/editor/settings.ejs +++ b/views/controls/editor/settings.ejs @@ -14,13 +14,21 @@ (go there) + - + + +
-- cgit v1.2.3-70-g09d2