aboutsummaryrefslogtreecommitdiff
path: root/js/models
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-05-07 10:38:04 -0700
committerJose Antonio Marquez2012-05-07 10:38:04 -0700
commit5293ede5f3493900df93da33197416d853f8d907 (patch)
tree3155deaea5616fa09fc96c84567419fec5f288a2 /js/models
parent9c0bda09a502472768f6dd5090a882d11be58d23 (diff)
parent30e837ade2da7cb20caf7c5a69faf0888736bb9a (diff)
downloadninja-5293ede5f3493900df93da33197416d853f8d907.tar.gz
Merge branch 'refs/heads/Ninja-DOM-Architecture' into Document
Diffstat (limited to 'js/models')
-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