aboutsummaryrefslogtreecommitdiff
path: root/js/models
diff options
context:
space:
mode:
authorValerio Virgillito2012-05-03 15:15:21 -0700
committerValerio Virgillito2012-05-03 15:15:21 -0700
commit2078bfa96afaef40acb4edac99848ba55e808ef1 (patch)
tree64e1443e15fa917e46a00bcea1dfaa5c5e982c93 /js/models
parent50831b3cdd905b372d405880e0c64f01c234f09e (diff)
downloadninja-2078bfa96afaef40acb4edac99848ba55e808ef1.tar.gz
Refactor creating elements. Removed makeNJElement and separated the model creation
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/models')
-rwxr-xr-xjs/models/element-model.js28
1 files changed, 21 insertions, 7 deletions
diff --git a/js/models/element-model.js b/js/models/element-model.js
index 72d61806..966158e4 100755
--- a/js/models/element-model.js
+++ b/js/models/element-model.js
@@ -32,24 +32,38 @@ exports.ElementModel = Montage.create(Montage, {
32 shapeModel: { value: null }, 32 shapeModel: { value: null },
33 isIn2DSnapCache : { value: false }, 33 isIn2DSnapCache : { value: false },
34 34
35 isComponent: { value: false },
36
35 fill: { value: null }, 37 fill: { value: null },
36 stroke: { value: null }, 38 stroke: { value: null },
37 39
38 initialize: { 40 initialize: {
39 value: function(el, isShape) { 41 value: function(el, isShape, selection, isComponent) {
40 var elementName, controller; 42 var elementName, controller;
41 43
42 elementName = el.nodeName.toLowerCase(); 44 elementName = el.nodeName.toLowerCase();
43 controller = this.elementNameToController(elementName);
44 45
45 this.type = el.nodeName; 46 this.type = el.nodeName;
46 this.selection = elementName; 47 this.selection = selection ? selection : elementName;
47 this.controller = ControllerFactory.getController(controller); 48
48 this.pi = this.elementNameToPi(elementName); 49 if(isComponent) {
50 controller = "component";
51 this.pi = this.elementNameToPi(selection.replace(/\s+/g, ''));
52 this.isComponent = true;
53 } else {
54 controller = this.elementNameToController(elementName);
55 this.pi = this.elementNameToPi(elementName);
56 }
57
49 this.props3D = Montage.create(Properties3D); 58 this.props3D = Montage.create(Properties3D);
50 59
51 //shapeModel: { value: shapeProps}, 60 if(isShape) {
52// isShape: { value: isShape} 61 this.controller = ControllerFactory.getController("shape");
62 this.shapeModel = Montage.create(ShapeModel);
63 this.isShape = true;
64 } else {
65 this.controller = ControllerFactory.getController(controller);
66 }
53 67
54 return this; 68 return this;
55 69