From e28eb9158a50d7e6d97dbc68066e591ac600c241 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 5 Jun 2012 21:40:44 -0700 Subject: removing all model creators. The elementModel is now a getter that will create a new model when needed. Signed-off-by: Valerio Virgillito --- js/mediators/drag-drop-mediator.js | 2 -- js/mediators/element-mediator.js | 42 +++----------------------------------- 2 files changed, 3 insertions(+), 41 deletions(-) (limited to 'js/mediators') diff --git a/js/mediators/drag-drop-mediator.js b/js/mediators/drag-drop-mediator.js index 59086ef6..14bdb0eb 100755 --- a/js/mediators/drag-drop-mediator.js +++ b/js/mediators/drag-drop-mediator.js @@ -115,12 +115,10 @@ exports.DragDropMediator = Montage.create(Component, { // if (e.currentTarget.fileType.indexOf('svg') !== -1) { element = NJUtils.make('embed', null, this.application.ninja.currentDocument);//TODO: Verify this is proper - NJUtils.createModelWithSelection(element, "SVG"); element.type = 'image/svg+xml'; element.src = url+'/'+fileName; } else { element = NJUtils.make('image', null, this.application.ninja.currentDocument); - NJUtils.createModel(element); element.src = url+'/'+fileName; } //Adding element once it is loaded diff --git a/js/mediators/element-mediator.js b/js/mediators/element-mediator.js index 1d5e9ade..cecb4392 100755 --- a/js/mediators/element-mediator.js +++ b/js/mediators/element-mediator.js @@ -29,15 +29,12 @@ exports.ElementMediator = Montage.create(Component, { if(Array.isArray(elements)) { elements.forEach(function(element) { ElementController.addElement(element, rules); - if(element.elementModel && element.elementModel.props3D) { - element.elementModel.props3D.init(element, false); - } + element.elementModel.props3D.init(element, false); }); } else { ElementController.addElement(elements, rules); - if(elements.elementModel && elements.elementModel.props3D) { - elements.elementModel.props3D.init(elements, false); - } + elements.elementModel.props3D.init(elements, false); + } if(this.addDelegate && typeof (this.addDelegate['onAddElements']) === "function") { @@ -102,11 +99,6 @@ exports.ElementMediator = Montage.create(Component, { getProperty: { value: function(el, prop, valueMutator) { - if(!el.elementModel) { - console.log("Element has no Model -> One should have been created"); - NJUtils.makeElementModel(el, "Div", "block"); - } - if(valueMutator && typeof valueMutator === "function") { return valueMutator(el.elementModel.controller["getProperty"](el, prop)); } else { @@ -117,22 +109,12 @@ exports.ElementMediator = Montage.create(Component, { getShapeProperty: { value: function(el, prop) { - if(!el.elementModel) { - console.log("Element has no Model -> One should have been created"); - NJUtils.makeElementModel(el, "Canvas", "block", true); - } - return el.elementModel.controller["getShapeProperty"](el, prop); } }, setShapeProperty: { value: function(el, prop, value) { - if(!el.elementModel) { - console.log("Element has no Model -> One should have been created"); - NJUtils.makeElementModel(el, "Canvas", "block", true); - } - return el.elementModel.controller["setShapeProperty"](el, prop, value); } }, @@ -297,9 +279,6 @@ exports.ElementMediator = Montage.create(Component, { // Routines to get/set color getColor: { value: function(el, isFill, borderSide) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["getColor"](el, isFill, borderSide); } }, @@ -374,9 +353,6 @@ exports.ElementMediator = Montage.create(Component, { getStroke: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeElementModel(el, "Div", "block"); - } return el.elementModel.controller["getStroke"](el); } }, @@ -452,18 +428,12 @@ exports.ElementMediator = Montage.create(Component, { // Routines to get/set 3D properties get3DProperty: { value: function(el, prop) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["get3DProperty"](el, prop); } }, get3DProperties: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } // var mat = this.getMatrix(el); // var dist = this.getPerspectiveDist(el); var mat = el.elementModel.controller["getMatrix"](el); @@ -474,18 +444,12 @@ exports.ElementMediator = Montage.create(Component, { getMatrix: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["getMatrix"](el); } }, getPerspectiveDist: { value: function(el) { - if(!el.elementModel) { - NJUtils.makeModelFromElement(el); - } return el.elementModel.controller["getPerspectiveDist"](el); } }, -- cgit v1.2.3