aboutsummaryrefslogtreecommitdiff
path: root/js/panels/properties.reel/properties.js
diff options
context:
space:
mode:
authorAnanya Sen2012-06-19 11:00:49 -0700
committerAnanya Sen2012-06-19 11:00:49 -0700
commitf1d8401aeb84e0eb0680caf72878dae26fd78a37 (patch)
tree31771ccaf3d1e2ddf01fa9605438d20be0d155d7 /js/panels/properties.reel/properties.js
parent9ea2610cec6569e7b7d5268b6c65bbf94c4753e5 (diff)
parent483ad57efcd6475776f580c3af5b60e6deeaf781 (diff)
downloadninja-f1d8401aeb84e0eb0680caf72878dae26fd78a37.tar.gz
Merge branch 'refs/heads/ninja-internal-master' into cut-copy-paste
Diffstat (limited to 'js/panels/properties.reel/properties.js')
-rwxr-xr-xjs/panels/properties.reel/properties.js97
1 files changed, 78 insertions, 19 deletions
diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js
index cc99ca6c..fcd0ab01 100755
--- a/js/panels/properties.reel/properties.js
+++ b/js/panels/properties.reel/properties.js
@@ -43,15 +43,28 @@ exports.Properties = Montage.create(Component, {
43 }, 43 },
44 44
45 elementName: { 45 elementName: {
46 value: null 46 value: null,
47 serializable: true
47 }, 48 },
48 49
49 elementId: { 50 elementId: {
50 value: null 51 value: null,
52 serializable: true
51 }, 53 },
52 54
53 elementClass: { 55 elementClass: {
54 value: null 56 value: null,
57 serializable: true
58 },
59
60 positionSize: {
61 value: null,
62 serializable: true
63 },
64
65 threeD: {
66 value: null,
67 serializable: true
55 }, 68 },
56 69
57 customSections: { 70 customSections: {
@@ -143,6 +156,7 @@ exports.Properties = Montage.create(Component, {
143 156
144 handleElementChange: { 157 handleElementChange: {
145 value: function(event) { 158 value: function(event) {
159 var l, t, h, w, lvu, tvu, hvu, wvu;
146// console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update 160// console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update
147 if(event.detail.source && event.detail.source !== "pi") { 161 if(event.detail.source && event.detail.source !== "pi") {
148 var el = this.application.ninja.currentDocument.model.documentRoot; 162 var el = this.application.ninja.currentDocument.model.documentRoot;
@@ -151,10 +165,24 @@ exports.Properties = Montage.create(Component, {
151 } 165 }
152 166
153 // TODO - This should only update the properties that were changed. 167 // TODO - This should only update the properties that were changed.
154 this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); 168 l = ElementsMediator.getProperty(el, "left");
155 this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); 169 t = ElementsMediator.getProperty(el, "top");
156 this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); 170 lvu = document.application.njUtils.getValueAndUnits(l);
157 this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); 171 tvu = document.application.njUtils.getValueAndUnits(t);
172 this.positionSize.leftUnits = lvu[1];
173 this.positionSize.leftPosition = lvu[0];
174 this.positionSize.topUnits = tvu[1];
175 this.positionSize.topPosition = tvu[0];
176
177 h = ElementsMediator.getProperty(el, "height");
178 w = ElementsMediator.getProperty(el, "width");
179 hvu = document.application.njUtils.getValueAndUnits(h);
180 wvu = document.application.njUtils.getValueAndUnits(w);
181
182 this.positionSize.heightUnits = hvu[1] || "px"; // canvas (and shapes) don't have units.
183 this.positionSize.heightSize = hvu[0];
184 this.positionSize.widthUnits = wvu[1] || "px";
185 this.positionSize.widthSize = wvu[0];
158 186
159 if(this.threeD.inGlobalMode) { 187 if(this.threeD.inGlobalMode) {
160 this.threeD.x3D = ElementsMediator.get3DProperty(el, "x3D"); 188 this.threeD.x3D = ElementsMediator.get3DProperty(el, "x3D");
@@ -209,7 +237,8 @@ exports.Properties = Montage.create(Component, {
209 237
210 displayElementProperties: { 238 displayElementProperties: {
211 value: function (el) { 239 value: function (el) {
212 var customPI, currentValue, isRoot = this.application.ninja.selectionController.isDocument; 240 var customPI, currentValue, isRoot = this.application.ninja.selectionController.isDocument,
241 l, t, h, w, lvu, tvu, hvu, wvu;
213 242
214 this.elementName.value = el.elementModel.selection; 243 this.elementName.value = el.elementModel.selection;
215 this.elementId.value = el.getAttribute("id") || ""; 244 this.elementId.value = el.getAttribute("id") || "";
@@ -219,11 +248,24 @@ exports.Properties = Montage.create(Component, {
219 this.threeD.disableTranslation = isRoot; 248 this.threeD.disableTranslation = isRoot;
220 this.threeD.flatten = ElementsMediator.getProperty(el, "-webkit-transform-style") !== "preserve-3d"; 249 this.threeD.flatten = ElementsMediator.getProperty(el, "-webkit-transform-style") !== "preserve-3d";
221 250
222 this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); 251 l = ElementsMediator.getProperty(el, "left");
223 this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); 252 t = ElementsMediator.getProperty(el, "top");
224 this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); 253 lvu = document.application.njUtils.getValueAndUnits(l);
225 this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); 254 tvu = document.application.njUtils.getValueAndUnits(t);
226// this.positionSize.widthSize = ElementsMediator.getProperty(el, "width"); 255 this.positionSize.leftUnits = lvu[1];
256 this.positionSize.leftPosition = lvu[0];
257 this.positionSize.topUnits = tvu[1];
258 this.positionSize.topPosition = tvu[0];
259
260 h = ElementsMediator.getProperty(el, "height");
261 w = ElementsMediator.getProperty(el, "width");
262 hvu = document.application.njUtils.getValueAndUnits(h);
263 wvu = document.application.njUtils.getValueAndUnits(w);
264
265 this.positionSize.heightUnits = hvu[1] || "px"; // canvas (and shapes) don't have units.
266 this.positionSize.heightSize = hvu[0];
267 this.positionSize.widthUnits = wvu[1] || "px";
268 this.positionSize.widthSize = wvu[0];
227 269
228 if(this.threeD.inGlobalMode) 270 if(this.threeD.inGlobalMode)
229 { 271 {
@@ -277,10 +319,23 @@ exports.Properties = Montage.create(Component, {
277 319
278 if(control.type !== "color") { 320 if(control.type !== "color") {
279 currentValue = ElementsMediator.getProperty(el, control.prop, control.valueMutator); 321 currentValue = ElementsMediator.getProperty(el, control.prop, control.valueMutator);
280 if(currentValue === null) { 322 if(control.type === "hottext") {
281 currentValue = control.defaultValue; 323 if(currentValue == null) {
324 currentValue = control.defaultValue;
325 }
326 if(typeof(currentValue) === "string") {
327 currentValue = document.application.njUtils.getValueAndUnits(currentValue);
328 this.customSections[i].content.controls[control.id + "Units"] = currentValue[1] || "px";
329 this.customSections[i].content.controls[control.id] = currentValue[0];
330 } else {
331 this.customSections[i].content.controls[control.id] = currentValue;
332 }
333 } else {
334 if(currentValue === null) {
335 currentValue = control.defaultValue;
336 }
337 this.customSections[i].content.controls[control.id] = currentValue;
282 } 338 }
283 this.customSections[i].content.controls[control.id] = currentValue;
284 } else { 339 } else {
285 if(control.prop === "border") { 340 if(control.prop === "border") {
286 // TODO - For now, always return the top border if multiple border sides 341 // TODO - For now, always return the top border if multiple border sides
@@ -312,7 +367,7 @@ exports.Properties = Montage.create(Component, {
312 } 367 }
313 } else { 368 } else {
314 this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: 'change'}; 369 this.application.ninja.colorController.colorModel.alpha = {value: 1, wasSetByCode: true, type: 'change'};
315 this.application.ninja.colorController.colorModel.applyNoColor(); 370 this.application.ninja.colorController.colorModel.applyNoColor(true);
316 } 371 }
317 } 372 }
318 } 373 }
@@ -342,7 +397,7 @@ exports.Properties = Montage.create(Component, {
342 this.application.ninja.colorController.colorModel.hsv = color.c; 397 this.application.ninja.colorController.colorModel.hsv = color.c;
343 break; 398 break;
344 default: 399 default:
345 this.application.ninja.colorController.colorModel.applyNoColor(); 400 this.application.ninja.colorController.colorModel.applyNoColor(true);
346 break; 401 break;
347 } 402 }
348 } 403 }
@@ -402,7 +457,11 @@ exports.Properties = Montage.create(Component, {
402 value: function(e) { 457 value: function(e) {
403 if(e.wasSetByCode) return; 458 if(e.wasSetByCode) return;
404 459
405 ElementsMediator.setProperty(this.application.ninja.selectedElements, e.prop, [e.value + "px"], "Changing", "pi"); 460 var newValue;
461
462 e.units ? newValue = e.value + e.units : newValue = e.value;
463
464 ElementsMediator.setProperty(this.application.ninja.selectedElements, e.prop, [newValue], "Changing", "pi");
406 } 465 }
407 } 466 }
408 467