diff options
Diffstat (limited to 'js/controllers/elements')
-rwxr-xr-x | js/controllers/elements/element-controller.js.orig | 393 |
1 files changed, 0 insertions, 393 deletions
diff --git a/js/controllers/elements/element-controller.js.orig b/js/controllers/elements/element-controller.js.orig deleted file mode 100755 index bf631d61..00000000 --- a/js/controllers/elements/element-controller.js.orig +++ /dev/null | |||
@@ -1,393 +0,0 @@ | |||
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"); | ||
163 | this.setProperty(el, "background-color", "none"); | ||
164 | el.elementModel.fill = null; | ||
165 | return; | ||
166 | case 'gradient': | ||
167 | this.setProperty(el, "background-image", color.color.css); | ||
168 | this.setProperty(el, "background-color", "none"); | ||
169 | break; | ||
170 | default: | ||
171 | this.setProperty(el, "background-image", "none"); | ||
172 | this.setProperty(el, "background-color", color.color.css); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | el.elementModel.fill = color; | ||
177 | } else { | ||
178 | if(mode) { | ||
179 | switch (mode) { | ||
180 | case 'nocolor': | ||
181 | this.setProperty(el, "border-image", "none"); | ||
182 | this.setProperty(el, "border-color", "none"); | ||
183 | el.elementModel.stroke = null; | ||
184 | return; | ||
185 | case 'gradient': | ||
186 | this.setGradientBorder(el, color.color.gradientMode, color.color.css); | ||
187 | break; | ||
188 | default: | ||
189 | <<<<<<< HEAD | ||
190 | if(borderSide){ | ||
191 | this.setProperty(el,"border-"+borderSide+"-color",color.color.css); | ||
192 | }else{ | ||
193 | this.setProperty(el, "border-image", "none"); | ||
194 | this.setProperty(el, "border-color", color.color.css); | ||
195 | } | ||
196 | if(color.borderInfo) { | ||
197 | if(color.borderInfo.borderWidth) { | ||
198 | this.setProperty(el, "border-width", color.borderInfo.borderWidth + color.borderInfo.borderUnits); | ||
199 | } | ||
200 | if(color.borderInfo.borderStyle) { | ||
201 | this.setProperty(el, "border-style", color.borderInfo.borderStyle); | ||
202 | } | ||
203 | } | ||
204 | ======= | ||
205 | this.setProperty(el, "border-image", "none"); | ||
206 | this.setProperty(el, "border-image-slice", ""); | ||
207 | this.setProperty(el, "border-color", color.color.css); | ||
208 | >>>>>>> refs/heads/TimelineUberjd | ||
209 | } | ||
210 | } | ||
211 | el.elementModel.stroke = color; | ||
212 | } | ||
213 | } | ||
214 | }, | ||
215 | |||
216 | setGradientBorder: { | ||
217 | value: function(el, gradientMode, css) { | ||