aboutsummaryrefslogtreecommitdiff
path: root/js/models
diff options
context:
space:
mode:
authorJohn Mayhew2012-05-07 16:30:19 -0700
committerJohn Mayhew2012-05-07 16:30:19 -0700
commitdb4ba95f50148198759dde503ec1c778184d9dbe (patch)
tree8b79ad58108af2f17d15abc8cdc33d35229ab20d /js/models
parent843d8ea8ee58a54bcb71d7b28dbf78fae153b491 (diff)
parent526e423e4a2734c2b139af23911e912452a4443f (diff)
downloadninja-db4ba95f50148198759dde503ec1c778184d9dbe.tar.gz
Merge branch 'master' of github.com:Motorola-Mobility/ninja-internal into WorkingBranch
Conflicts: js/components/layout/tools-list.reel/tools-list.html js/components/layout/tools-properties.reel/tools-properties.html js/components/tools-properties/brush-properties.reel/brush-properties.html js/components/tools-properties/fill-properties.reel/fill-properties.html js/components/tools-properties/pen-properties.reel/pen-properties.html js/components/tools-properties/pencil-properties.reel/pencil-properties.html js/components/tools-properties/selection-properties.reel/selection-properties.html js/components/tools-properties/shape-properties.reel/shape-properties.html js/components/tools-properties/tag-properties.reel/tag-properties.html js/components/tools-properties/text-properties.reel/text-properties.html
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