diff options
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x | js/controllers/elements/element-controller.js | 16 | ||||
-rwxr-xr-x | js/controllers/elements/element-controller.js.orig | 393 |
2 files changed, 401 insertions, 8 deletions
diff --git a/js/controllers/elements/element-controller.js b/js/controllers/elements/element-controller.js index 280090d1..3d71c52d 100755 --- a/js/controllers/elements/element-controller.js +++ b/js/controllers/elements/element-controller.js | |||
@@ -103,24 +103,24 @@ exports.ElementController = Montage.create(Component, { | |||
103 | 103 | ||
104 | // Return cached value if one exists | 104 | // Return cached value if one exists |
105 | if(isFill) { | 105 | if(isFill) { |
106 | if(el.elementModel.fill) { | 106 | // if(el.elementModel.fill) { |
107 | return el.elementModel.fill; | 107 | // return el.elementModel.fill; |
108 | } | 108 | // } |
109 | //TODO: Once logic for color and gradient is established, this needs to be revised | 109 | //TODO: Once logic for color and gradient is established, this needs to be revised |
110 | color = this.getProperty(el, "background-color"); | 110 | color = this.getProperty(el, "background-color"); |
111 | image = this.getProperty(el, "background-image"); | 111 | image = this.getProperty(el, "background-image"); |
112 | } else { | 112 | } else { |
113 | // Try getting border color from specific side first | 113 | // Try getting border color from specific side first |
114 | if(borderSide) { | 114 | if(borderSide) { |
115 | color = this.getProperty(el, "border-" + borderSide + "-color"); | 115 | color = this.getProperty(el, "border-" + borderSide + "-color",true); |
116 | image = this.getProperty(el, "border-" + borderSide + "-image"); | 116 | image = this.getProperty(el, "border-" + borderSide + "-image"); |
117 | } | 117 | } |
118 | 118 | ||
119 | // If no color was found, look up the shared border color | 119 | // If no color was found, look up the shared border color |
120 | if(!color && !image) { | 120 | if(!color && !image) { |
121 | if(el.elementModel.stroke) { | 121 | // if(el.elementModel.stroke) { |
122 | return el.elementModel.stroke; | 122 | // return el.elementModel.stroke; |
123 | } | 123 | // } |
124 | 124 | ||
125 | color = this.getProperty(el, "border-color"); | 125 | color = this.getProperty(el, "border-color"); |
126 | image = this.getProperty(el, "border-image"); | 126 | image = this.getProperty(el, "border-image"); |
@@ -152,7 +152,7 @@ exports.ElementController = Montage.create(Component, { | |||
152 | }, | 152 | }, |
153 | 153 | ||
154 | setColor: { | 154 | setColor: { |
155 | value: function(el, color, isFill) { | 155 | value: function(el, color, isFill,borderSide) { |
156 | var mode = color.mode; | 156 | var mode = color.mode; |
157 | 157 | ||
158 | if(isFill) { | 158 | if(isFill) { |
diff --git a/js/controllers/elements/element-controller.js.orig b/js/controllers/elements/element-controller.js.orig new file mode 100755 index 00000000..bf631d61 --- /dev/null +++ b/js/controllers/elements/element-controller.js.orig | |||
@@ -0,0 +1,393 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component, | ||
9 | njModule = require("js/lib/NJUtils"); | ||
10 | |||
11 | exports.ElementController = Montage.create(Component, { | ||
12 | |||
13 | addElement: { | ||
14 | value: function(el, styles) { | ||
15 | |||
16 | if (el.getAttribute) el.setAttribute('data-ninja-node', 'true'); | ||
17 | |||
18 | // Updated to use new methods in TimelinePanel. JR. | ||
19 | var insertionIndex = this.application.ninja.timeline.getInsertionIndex(); | ||
20 | if (insertionIndex === false) { | ||
21 | this.application.ninja.currentSelectedContainer.appendChild(el); | ||
22 | } else { | ||
23 | if (insertionIndex === 0) { | ||
24 | this.application.ninja.currentSelectedContainer.appendChild(el); | ||
25 | } else { | ||
26 | var element = this.application.ninja.timeline.arrLayers[insertionIndex].layerData.stageElement; | ||
27 | element.parentNode.insertBefore(el, element.nextSibling); | ||
28 | } | ||
29 | } | ||
30 | |||
31 | if(styles) { | ||
32 | this.application.ninja.stylesController.setElementStyles(el, styles); | ||
33 | } | ||
34 | |||
35 | /* | ||
36 | // Old methods. Kept for reference. Delete if not needed. JR. | ||
37 | if(this.application.ninja.timeline.currentLayerSelected) { | ||
38 | var selectedLayerIndex = this.application.ninja.timeline.getLayerIndexByID(this.application.ninja.timeline.currentLayerSelected.layerData.layerID); | ||
39 | |||
40 | if(selectedLayerIndex === 0) { | ||
41 | this.application.ninja.currentSelectedContainer.appendChild(el); | ||
42 | } else { | ||
43 | var element = this.application.ninja.timeline.arrLayers[selectedLayerIndex].layerData.stageElement; | ||
44 | element.parentNode.insertBefore(el, element.nextSibling); | ||
45 | } | ||
46 | } else { | ||
47 | this.application.ninja.currentSelectedContainer.appendChild(el); | ||
48 | } | ||
49 | |||
50 | if(styles) { | ||
51 | this.application.ninja.stylesController.setElementStyles(el, styles); | ||
52 | } | ||
53 | */ | ||
54 | } | ||
55 | }, | ||
56 | |||
57 | // Remove the element from the DOM and clear the GLWord. | ||
58 | removeElement: { | ||
59 | value: function(el) { | ||
60 | if(el.elementModel.shapeModel && el.elementModel.shapeModel.GLWorld) { | ||
61 | el.elementModel.shapeModel.GLWorld.clearTree(); | ||
62 | } | ||
63 | el.parentNode.removeChild(el); | ||
64 | } | ||
65 | }, | ||
66 | |||
67 | getProperty: { | ||
68 | value: function(el, prop, fallbackOnComputed, isStageElement) { | ||
69 | if(el.nodeType !== 3){ | ||
70 | return this.application.ninja.stylesController.getElementStyle(el, prop, fallbackOnComputed, isStageElement); | ||
71 | }else{ | ||
72 | return null; | ||
73 | } | ||
74 | } | ||
75 | }, | ||
76 | |||
77 | setProperty: { | ||
78 | value: function(el, p, value) { | ||
79 | this.application.ninja.stylesController.setElementStyle(el, p, value); | ||
80 | } | ||
81 | }, | ||
82 | |||
83 | setProperties: { | ||
84 | value: function(element, properties) { | ||
85 | for(var property in properties) { | ||
86 | this.application.ninja.stylesController.setElementStyle(element, property, properties[property]); | ||
87 | } | ||
88 | } | ||
89 | }, | ||
90 | |||
91 | setAttribute: { | ||
92 | value: function(el, att, value) { | ||
93 | el.setAttribute(att, value); | ||
94 | } | ||
95 | }, | ||
96 | |||
97 | //-------------------------------------------------------------------------------------------------------- | ||
98 | // Routines to get/set color properties | ||
99 | // borderSide : "top", "right", "bottom", or "left" | ||
100 | getColor: { | ||
101 | value: function(el, isFill, borderSide) { | ||
102 | var colorObj, color, image; | ||
103 | |||
104 | // Return cached value if one exists | ||
105 | if(isFill) { | ||
106 | // if(el.elementModel.fill) { | ||
107 | // return el.elementModel.fill; | ||
108 | // } | ||
109 | //TODO: Once logic for color and gradient is established, this needs to be revised | ||
110 | color = this.getProperty(el, "background-color"); | ||
111 | image = this.getProperty(el, "background-image"); | ||
112 | } else { | ||
113 | // Try getting border color from specific side first | ||
114 | if(borderSide) { | ||
115 | color = this.getProperty(el, "border-" + borderSide + "-color",true); | ||
116 | image = this.getProperty(el, "border-" + borderSide + "-image"); | ||
117 | } | ||
118 | |||
119 | // If no color was found, look up the shared border color | ||
120 | if(!color && !image) { | ||
121 | // if(el.elementModel.stroke) { | ||
122 | // return el.elementModel.stroke; | ||
123 | // } | ||
124 | |||
125 | color = this.getProperty(el, "border-color"); | ||
126 | image = this.getProperty(el, "border-image"); | ||
127 | } | ||
128 | } | ||
129 | |||
130 | if(color || image) { | ||
131 | if (image && image !== 'none' && image.indexOf('-webkit') >= 0) { | ||
132 | //Gradient | ||
133 | colorObj = this.application.ninja.colorController.getColorObjFromCss(image); | ||
134 | } else { | ||
135 | //Solid | ||
136 | colorObj = this.application.ninja.colorController.getColorObjFromCss(color); | ||
137 | } | ||
138 | } | ||
139 | |||
140 | // Update cache | ||
141 | if(isFill) { | ||
142 | el.elementModel.fill = colorObj; | ||
143 | } else if(!borderSide) { | ||
144 | // TODO - Need to update border style and width also | ||
145 | el.elementModel.stroke = colorObj; | ||
146 | } else { | ||
147 | // TODO - Should update specific border sides too | ||
148 | } | ||
149 | |||
150 | return colorObj; | ||
151 | } | ||
152 | }, | ||
153 | |||
154 | setColor: { | ||
155 | value: function(el, color, isFill,borderSide) { | ||
156 | var mode = color.mode; | ||
157 | |||
158 | if(isFill) { | ||
159 | if(mode) { | ||
160 | switch (mode) { | ||
161 | case 'nocolor': | ||
162 | this.setProperty(el, "background-image", "none"); | ||