diff options
Diffstat (limited to 'js/panels/properties.reel/properties.js')
-rwxr-xr-x | js/panels/properties.reel/properties.js | 184 |
1 files changed, 46 insertions, 138 deletions
diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 8c2daa14..eb362796 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js | |||
@@ -46,7 +46,7 @@ exports.Properties = Montage.create(Component, { | |||
46 | 46 | ||
47 | prepareForDraw: { | 47 | prepareForDraw: { |
48 | value : function() { | 48 | value : function() { |
49 | 49 | this.eventManager.addEventListener("openDocument", this, false); | |
50 | this.eventManager.addEventListener("selectionChange", this, false); | 50 | this.eventManager.addEventListener("selectionChange", this, false); |
51 | 51 | ||
52 | // This will be a toggle option | 52 | // This will be a toggle option |
@@ -54,9 +54,6 @@ exports.Properties = Montage.create(Component, { | |||
54 | this.eventManager.addEventListener( "elementChanging", this, false); | 54 | this.eventManager.addEventListener( "elementChanging", this, false); |
55 | } | 55 | } |
56 | 56 | ||
57 | this.eventManager.addEventListener("openDocument", this, false); | ||
58 | this.eventManager.addEventListener("switchDocument", this, false); | ||
59 | |||
60 | this.elementId.element.addEventListener("blur", this, false); | 57 | this.elementId.element.addEventListener("blur", this, false); |
61 | this.elementId.element.addEventListener("focus", this, false); | 58 | this.elementId.element.addEventListener("focus", this, false); |
62 | this.elementId.element.addEventListener("keyup", this, false); | 59 | this.elementId.element.addEventListener("keyup", this, false); |
@@ -67,32 +64,15 @@ exports.Properties = Montage.create(Component, { | |||
67 | } | 64 | } |
68 | }, | 65 | }, |
69 | 66 | ||
70 | // Document is opened - Display the current selection | ||
71 | handleOpenDocument: { | 67 | handleOpenDocument: { |
72 | value: function() { | 68 | value: function() { |
73 | |||
74 | this.eventManager.addEventListener( "elementChange", this, false); | 69 | this.eventManager.addEventListener( "elementChange", this, false); |
75 | 70 | ||
76 | // For now always assume that the stage is selected by default when opening the old template | 71 | // Save a reference of the pi inside the document view to be able to clear |
77 | // TODO: Remove marker for old template: NINJA-STAGE-REWORK | 72 | this.application.ninja.currentDocument.model.views.design.propertiesPanel = this; |
78 | if(this.application.ninja.selectedElements.length === 0 && this.application.ninja.currentDocument.documentRoot.nodeName.toLowerCase() !== "body") { | ||
79 | this.displayStageProperties(); | ||
80 | } | ||
81 | } | ||
82 | }, | ||
83 | 73 | ||
84 | handleSwitchDocument: { | 74 | // Display the default document root PI |
85 | value: function(){ | 75 | this.displayElementProperties(this.application.ninja.currentDocument.documentRoot); |
86 | // For now always assume that the stage is selected by default | ||
87 | if(this.application.ninja.selectedElements.length === 0) { | ||
88 | this.displayStageProperties(); | ||
89 | } else { | ||
90 | if(this.application.ninja.selectedElements.length === 1) { | ||
91 | this.displayElementProperties(this.application.ninja.selectedElements[0]); | ||
92 | } else { | ||
93 | this.displayGroupProperties(this.application.ninja.selectedElements); | ||
94 | } | ||
95 | } | ||
96 | } | 76 | } |
97 | }, | 77 | }, |
98 | 78 | ||
@@ -174,8 +154,7 @@ exports.Properties = Montage.create(Component, { | |||
174 | handleSelectionChange: { | 154 | handleSelectionChange: { |
175 | value: function(event) { | 155 | value: function(event) { |
176 | if(event.detail.isDocument) { | 156 | if(event.detail.isDocument) { |
177 | if(this.application.ninja.currentDocument.documentRoot.nodeName.toLowerCase() === "body") return; | 157 | this.displayElementProperties(this.application.ninja.currentDocument.documentRoot); |
178 | this.displayStageProperties(); | ||
179 | } else { | 158 | } else { |
180 | if(this.application.ninja.selectedElements.length === 1) { | 159 | if(this.application.ninja.selectedElements.length === 1) { |
181 | this.displayElementProperties(this.application.ninja.selectedElements[0]); | 160 | this.displayElementProperties(this.application.ninja.selectedElements[0]); |
@@ -187,98 +166,32 @@ exports.Properties = Montage.create(Component, { | |||
187 | } | 166 | } |
188 | }, | 167 | }, |
189 | 168 | ||
190 | displayStageProperties: { | 169 | clear: { |
191 | value: function() { | 170 | value: function() { |
192 | var stage = this.application.ninja.currentDocument.documentRoot; | 171 | this.elementName.value = ""; |
193 | //this is test code please remove | 172 | this.elementId.value = ""; |
194 | this.elementName.value = "Stage"; | ||
195 | this.elementId.value = stage.elementModel.id; | ||
196 | this.elementClass.value = ""; | 173 | this.elementClass.value = ""; |
197 | 174 | this.customPi = null; | |
198 | this.positionSize.disablePosition = true; | ||
199 | this.threeD.disableTranslation = true; | ||
200 | |||
201 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(stage, "height")); | ||
202 | this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(stage, "width")); | ||
203 | |||
204 | if(this.threeD.inGlobalMode) | ||
205 | { | ||
206 | this.threeD.xAngle = ElementsMediator.get3DProperty(stage, "xAngle"); | ||
207 | this.threeD.yAngle = ElementsMediator.get3DProperty(stage, "yAngle"); | ||
208 | this.threeD.zAngle = ElementsMediator.get3DProperty(stage, "zAngle"); | ||
209 | } | ||
210 | |||
211 | this.threeD.flatten = ElementsMediator.getProperty(stage, "-webkit-transform-style") !== "preserve-3d"; | ||
212 | |||
213 | if(this.customPi !== stage.elementModel.pi) { | ||
214 | // We need to unregister color chips from the previous selection from the Color Model | ||
215 | var len = this.customSections.length; | ||
216 | for(var n = 0, controls; n < len; n++) { | ||
217 | controls = this.customSections[n].content.controls; | ||
218 | if(controls["colorSelect"]) { | ||
219 | controls["colorSelect"].destroy(); | ||
220 | } else if(controls["stageBackground"]) { | ||
221 | controls["stageBackground"].destroy(); | ||
222 | } | ||
223 | } | ||
224 | |||
225 | this.customPi = stage.elementModel.pi; | ||
226 | this.displayCustomProperties(stage, stage.elementModel.pi); | ||
227 | } | ||
228 | |||
229 | // For now hardcode the background since it is the only custom property | ||
230 | // No need to loop through all the properties. | ||
231 | var backgroundChip = this.customSections[0].content.controls["background"]; | ||
232 | backgroundChip.color = ElementsMediator.getProperty(stage, "background"); | ||
233 | |||
234 | /* | ||
235 | var customPI = PiData[this.customPi]; | ||
236 | // Get all the custom section for the custom PI | ||
237 | for(var i = 0, customSec; customSec = customPI[i]; i++) { | ||
238 | |||
239 | // Now set the Fields for the custom PI | ||
240 | for(var j = 0, fields; fields = customSec.Section[j]; j++) { | ||
241 | for(var k = 0, control; control = fields[k]; k++) { | ||
242 | |||
243 | var colorChipEl = this.customSections[i].content.controls[control.id]; | ||
244 | this.foo = colorChipEl; | ||
245 | colorChipEl.addEventListener("firstDraw", this, false); | ||
246 | |||
247 | } | ||
248 | } | ||
249 | } | ||
250 | */ | ||
251 | } | ||
252 | }, | ||
253 | |||
254 | handleFirstDraw: { | ||
255 | value: function() { | ||
256 | this.foo.chipBtn.color('rgb', {wasSetByCode: true, type: 'change', color: {r: 255, g: 0, b: 0}, css: 'rgb(255,0,0)'}); | ||
257 | } | 175 | } |
258 | }, | 176 | }, |
259 | 177 | ||
260 | displayElementProperties: { | 178 | displayElementProperties: { |
261 | value: function (el) { | 179 | value: function (el) { |
262 | var customPI, | 180 | var customPI, currentValue, isRoot = this.application.ninja.selectionController.isDocument; |
263 | currentValue; | ||
264 | 181 | ||
265 | this.elementName.value = el.elementModel.selection; | 182 | this.elementName.value = el.elementModel.selection; |
266 | this.elementId.value = el.getAttribute("id") || ""; | 183 | this.elementId.value = el.getAttribute("id") || ""; |
267 | this.elementClass.value = el.getAttribute("class"); | 184 | this.elementClass.value = el.getAttribute("class"); |
268 | 185 | ||
269 | this.positionSize.disablePosition = false; | 186 | this.positionSize.disablePosition = isRoot; |
270 | this.threeD.disableTranslation = false; | 187 | this.threeD.disableTranslation = isRoot; |
188 | this.threeD.flatten = ElementsMediator.getProperty(el, "-webkit-transform-style") !== "preserve-3d"; | ||
271 | 189 | ||
272 | this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); | 190 | this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); |
273 | this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); | 191 | this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); |
274 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); | 192 | this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); |
275 | this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); | 193 | this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); |
276 | 194 | // this.positionSize.widthSize = ElementsMediator.getProperty(el, "width"); | |
277 | if(ElementsMediator.getProperty(el, "-webkit-transform-style") === "preserve-3d") { | ||
278 | this.threeD.flatten = false; | ||
279 | } else { | ||
280 | this.threeD.flatten = true; | ||
281 | } | ||
282 | 195 | ||
283 | if(this.threeD.inGlobalMode) | 196 | if(this.threeD.inGlobalMode) |
284 | { | 197 | { |
@@ -306,6 +219,19 @@ exports.Properties = Montage.create(Component, { | |||
306 | this.customPi = el.elementModel.pi; | 219 | this.customPi = el.elementModel.pi; |
307 | this.displayCustomProperties(el, el.elementModel.pi); | 220 | this.displayCustomProperties(el, el.elementModel.pi); |
308 | } | 221 | } |
222 | |||
223 | // Root element color chip | ||
224 | if(isRoot) { | ||
225 | var backgroundChip = this.customSections[0].content.controls["background"]; | ||
226 | var rootBackgroundColor = ElementsMediator.getProperty(el, "background"); | ||
227 | |||
228 | if(rootBackgroundColor) { | ||
229 | backgroundChip.color = rootBackgroundColor; | ||
230 | } else { | ||
231 | backgroundChip.color = null; | ||
232 | } | ||
233 | } | ||
234 | |||
309 | var previousInput = this.application.ninja.colorController.colorModel.input; | 235 | var previousInput = this.application.ninja.colorController.colorModel.input; |
310 | customPI = PiData[this.customPi]; | 236 | customPI = PiData[this.customPi]; |
311 | // Get all the custom section for the custom PI | 237 | // Get all the custom section for the custom PI |