aboutsummaryrefslogtreecommitdiff
path: root/js/models/element-model.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-05-04 15:33:29 -0700
committerNivesh Rajbhandari2012-05-04 15:33:29 -0700
commitad94ec51c81badeba2b0f870cad8a0eec7878ebd (patch)
tree35c52d44d2c5399ea4019582af3fb55a53ee05c8 /js/models/element-model.js
parent3ad9024bcfce76e28816daa02bac14fc8985ca62 (diff)
parent3ebed34665fa73b0ce613b400f3029ebf4476439 (diff)
downloadninja-ad94ec51c81badeba2b0f870cad8a0eec7878ebd.tar.gz
Merge branch 'refs/heads/dom-architecture-master' into Dom-Architecture
Diffstat (limited to 'js/models/element-model.js')
-rwxr-xr-xjs/models/element-model.js75
1 files changed, 60 insertions, 15 deletions
diff --git a/js/models/element-model.js b/js/models/element-model.js
index 0e199a67..966158e4 100755
--- a/js/models/element-model.js
+++ b/js/models/element-model.js
@@ -4,10 +4,11 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Properties3D = require("js/models/properties-3d").Properties3D, 8 Properties3D = require("js/models/properties-3d").Properties3D,
9 ShapeModel = require("js/models/shape-model").ShapeModel, 9 ShapeModel = require("js/models/shape-model").ShapeModel,
10 ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory; 10 ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory,
11 PiData = require("js/data/pi/pi-data").PiData;
11 12
12exports.ElementModel = Montage.create(Montage, { 13exports.ElementModel = Montage.create(Montage, {
13 key: { value: "_model_"}, 14 key: { value: "_model_"},
@@ -31,21 +32,65 @@ exports.ElementModel = Montage.create(Montage, {
31 shapeModel: { value: null }, 32 shapeModel: { value: null },
32 isIn2DSnapCache : { value: false }, 33 isIn2DSnapCache : { value: false },
33 34
35 isComponent: { value: false },
36
34 fill: { value: null }, 37 fill: { value: null },
35 stroke: { value: null }, 38 stroke: { value: null },
36 39
37 initialize: { 40 initialize: {
38 value: function(type, selection, controller, isShape) { 41 value: function(el, isShape, selection, isComponent) {
39 /* 42 var elementName, controller;
40 this.type = type; 43
41 this.selection = selection; 44 elementName = el.nodeName.toLowerCase();
42 45
43 controller: { value: ControllerFactory.getController(controller)}, 46 this.type = el.nodeName;
44 pi: { value: pi}, 47 this.selection = selection ? selection : elementName;
45 props3D: { value: p3d}, 48
46 shapeModel: { value: shapeProps}, 49 if(isComponent) {
47 isShape: { value: isShape} 50 controller = "component";
48 */ 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
58 this.props3D = Montage.create(Properties3D);
59
60 if(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 }
67
68 return this;
69
70 }
71 },
72
73 elementNameToController: {
74 value: function(name) {
75 if(name === "div" || name === "custom") {
76 return "block";
77 } else if(name === "img") {
78 return "image";
79 } else {
80 return name;
81 }
82 }
83 },
84
85 elementNameToPi: {
86 value: function(name) {
87 var piString = name + "Pi";
88
89 if(!PiData.hasOwnProperty(piString)) {
90 piString = "blockPi";
91 }
92
93 return piString;
49 } 94 }
50 }, 95 },
51 96