aboutsummaryrefslogtreecommitdiff
path: root/js/models
diff options
context:
space:
mode:
Diffstat (limited to 'js/models')
-rwxr-xr-xjs/models/element-model.js80
-rwxr-xr-xjs/models/properties-3d.js3
2 files changed, 65 insertions, 18 deletions
diff --git a/js/models/element-model.js b/js/models/element-model.js
index fa02fd38..966158e4 100755
--- a/js/models/element-model.js
+++ b/js/models/element-model.js
@@ -4,7 +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,
9 ShapeModel = require("js/models/shape-model").ShapeModel,
10 ControllerFactory = require("js/controllers/elements/controller-factory").ControllerFactory,
11 PiData = require("js/data/pi/pi-data").PiData;
8 12
9exports.ElementModel = Montage.create(Montage, { 13exports.ElementModel = Montage.create(Montage, {
10 key: { value: "_model_"}, 14 key: { value: "_model_"},
@@ -16,36 +20,80 @@ exports.ElementModel = Montage.create(Montage, {
16 20
17 id: { value: "" }, 21 id: { value: "" },
18 classList: { value: null }, 22 classList: { value: null },
19
20 defaultRule: { value: null }, 23 defaultRule: { value: null },
21 24
22 top: { value: null }, 25 top: { value: null },
23 left: { value: null }, 26 left: { value: null },
24 width: { value: null }, 27 width: { value: null },
25 height: { value: null }, 28 height: { value: null },
26
27 /**
28 * Properties 3D
29 */
30 props3D: { value: null }, 29 props3D: { value: null },
31 30
32 /**
33 * Shape Info
34 */
35 isShape: { value: false }, 31 isShape: { value: false },
36 shapeModel: { value: null }, 32 shapeModel: { value: null },
37
38 /**
39 * SnapManager 2d Snap Cache Info
40 */
41 isIn2DSnapCache : { value: false }, 33 isIn2DSnapCache : { value: false },
42 34
43 /** 35 isComponent: { value: false },
44 * Color info 36
45 */
46 fill: { value: null }, 37 fill: { value: null },
47 stroke: { value: null }, 38 stroke: { value: null },
48 39
40 initialize: {
41 value: function(el, isShape, selection, isComponent) {
42 var elementName, controller;
43
44 elementName = el.nodeName.toLowerCase();
45
46 this.type = el.nodeName;
47 this.selection = selection ? selection : elementName;
48
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
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;
94 }
95 },
96
49 getProperty: { 97 getProperty: {
50 value: function(property) { 98 value: function(property) {
51 var key = this.key + property; 99 var key = this.key + property;
diff --git a/js/models/properties-3d.js b/js/models/properties-3d.js
index c1270c3b..e571e505 100755
--- a/js/models/properties-3d.js
+++ b/js/models/properties-3d.js
@@ -5,8 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
5</copyright> */ 5</copyright> */
6 6
7var Montage = require("montage/core/core").Montage, 7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component, 8 Component = require("montage/ui/component").Component;
9 NJUtils = require("js/lib/NJUtils").NJUtils;
10 9
11exports.Properties3D = Montage.create(Component, { 10exports.Properties3D = Montage.create(Component, {
12 11