diff options
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x | js/controllers/elements/element-controller.js | 15 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 5 |
2 files changed, 12 insertions, 8 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index b35251ad..efb33292 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -5,22 +5,27 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | NJComponent = require("js/lib/nj-base").NJComponent; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | var ElementController = exports.ElementController = Montage.create(NJComponent, { | 10 | exports.ElementController = Montage.create(Component, { |
11 | 11 | ||
12 | addElement: { | 12 | addElement: { |
13 | value: function(el, styles) { | 13 | value: function(el, styles) { |
14 | this.application.ninja.currentDocument.documentRoot.appendChild(el); | 14 | this.application.ninja.currentDocument.documentRoot.appendChild(el); |
15 | // Nested elements - | 15 | // Nested elements - TODO make sure the CSS is correct before nesting elements |
16 | // TODO make sure the CSS is correct before nesting elements | ||
17 | // this.application.ninja.currentSelectedContainer.appendChild(el); | 16 | // this.application.ninja.currentSelectedContainer.appendChild(el); |
18 | this.application.ninja.stylesController.setElementStyles(el, styles); | 17 | if(styles) { |
18 | this.application.ninja.stylesController.setElementStyles(el, styles); | ||
19 | } | ||
19 | } | 20 | } |
20 | }, | 21 | }, |
21 | 22 | ||
23 | // Remove the element from the DOM and clear the GLWord. | ||
22 | removeElement: { | 24 | removeElement: { |
23 | value: function(el) { | 25 | value: function(el) { |
26 | if(el.elementModel && el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { | ||
27 | el.elementModel.shapeModel.GLWorld.clearTree(); | ||
28 | } | ||
24 | el.parentNode.removeChild(el); | 29 | el.parentNode.removeChild(el); |
25 | } | 30 | } |
26 | }, | 31 | }, |
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 236e9caa..f9b63942 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -122,10 +122,9 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
122 | canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); | 122 | canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); |
123 | canvas.width = el.width; | 123 | canvas.width = el.width; |
124 | canvas.height = el.height; | 124 | canvas.height = el.height; |
125 | this.application.ninja.elementMediator.replaceElement(el, canvas); | 125 | canvas.elementModel = el.elementModel; |
126 | NJevent("elementDeleted", el); | ||
127 | this.toggleWebGlMode(canvas, value); | 126 | this.toggleWebGlMode(canvas, value); |
128 | NJevent("elementAdded", canvas); | 127 | this.application.ninja.elementMediator.replaceElement(canvas, el); |
129 | break; | 128 | break; |
130 | case "strokeMaterial": | 129 | case "strokeMaterial": |
131 | m = Object.create(MaterialsModel.getMaterial(value)); | 130 | m = Object.create(MaterialsModel.getMaterial(value)); |