From 0e1a276f19ea70009c5a649e9667861d7c346a7e Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 6 Jun 2012 00:25:27 -0700 Subject: first iteration of adding serializable to ninja plus other changes to run the latest montage Signed-off-by: Valerio Virgillito --- js/panels/properties.reel/properties.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'js/panels/properties.reel/properties.js') diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 934a3851..0017b54f 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -43,15 +43,28 @@ exports.Properties = Montage.create(Component, { }, elementName: { - value: null + value: null, + serializable: true }, elementId: { - value: null + value: null, + serializable: true }, elementClass: { - value: null + value: null, + serializable: true + }, + + positionSize: { + value: null, + serializable: true + }, + + threeD: { + value: null, + serializable: true }, customSections: { -- cgit v1.2.3 From 509092ff335f74517a413cfb2deeb9d2de20f8e3 Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Tue, 12 Jun 2012 15:13:09 -0700 Subject: Fixing properties panel to support px and % for body and other elements. Signed-off-by: Nivesh Rajbhandari --- js/panels/properties.reel/properties.js | 70 ++++++++++++++++++++++++++------- 1 file changed, 56 insertions(+), 14 deletions(-) (limited to 'js/panels/properties.reel/properties.js') diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index cc99ca6c..33e66515 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -143,6 +143,7 @@ exports.Properties = Montage.create(Component, { handleElementChange: { value: function(event) { + var l, t, h, w, lvu, tvu, hvu, wvu; // console.log("Element Change PI ", event.detail.source); // If the event comes from the pi don't need to update if(event.detail.source && event.detail.source !== "pi") { var el = this.application.ninja.currentDocument.model.documentRoot; @@ -151,10 +152,24 @@ exports.Properties = Montage.create(Component, { } // TODO - This should only update the properties that were changed. - this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); - this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); - this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); - this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); + l = ElementsMediator.getProperty(el, "left"); + t = ElementsMediator.getProperty(el, "top"); + lvu = document.application.njUtils.getValueAndUnits(l); + tvu = document.application.njUtils.getValueAndUnits(t); + this.positionSize.leftUnits = lvu[1]; + this.positionSize.leftPosition = lvu[0]; + this.positionSize.topUnits = tvu[1]; + this.positionSize.topPosition = tvu[0]; + + h = ElementsMediator.getProperty(el, "height"); + w = ElementsMediator.getProperty(el, "width"); + hvu = document.application.njUtils.getValueAndUnits(h); + wvu = document.application.njUtils.getValueAndUnits(w); + + this.positionSize.heightUnits = hvu[1] || "px"; // canvas (and shapes) don't have units. + this.positionSize.heightSize = hvu[0]; + this.positionSize.widthUnits = wvu[1] || "px"; + this.positionSize.widthSize = wvu[0]; if(this.threeD.inGlobalMode) { this.threeD.x3D = ElementsMediator.get3DProperty(el, "x3D"); @@ -209,7 +224,8 @@ exports.Properties = Montage.create(Component, { displayElementProperties: { value: function (el) { - var customPI, currentValue, isRoot = this.application.ninja.selectionController.isDocument; + var customPI, currentValue, isRoot = this.application.ninja.selectionController.isDocument, + l, t, h, w, lvu, tvu, hvu, wvu; this.elementName.value = el.elementModel.selection; this.elementId.value = el.getAttribute("id") || ""; @@ -219,11 +235,24 @@ exports.Properties = Montage.create(Component, { this.threeD.disableTranslation = isRoot; this.threeD.flatten = ElementsMediator.getProperty(el, "-webkit-transform-style") !== "preserve-3d"; - this.positionSize.leftPosition = parseFloat(ElementsMediator.getProperty(el, "left")); - this.positionSize.topPosition = parseFloat(ElementsMediator.getProperty(el, "top")); - this.positionSize.heightSize = parseFloat(ElementsMediator.getProperty(el, "height")); - this.positionSize.widthSize = parseFloat(ElementsMediator.getProperty(el, "width")); -// this.positionSize.widthSize = ElementsMediator.getProperty(el, "width"); + l = ElementsMediator.getProperty(el, "left"); + t = ElementsMediator.getProperty(el, "top"); + lvu = document.application.njUtils.getValueAndUnits(l); + tvu = document.application.njUtils.getValueAndUnits(t); + this.positionSize.leftUnits = lvu[1]; + this.positionSize.leftPosition = lvu[0]; + this.positionSize.topUnits = tvu[1]; + this.positionSize.topPosition = tvu[0]; + + h = ElementsMediator.getProperty(el, "height"); + w = ElementsMediator.getProperty(el, "width"); + hvu = document.application.njUtils.getValueAndUnits(h); + wvu = document.application.njUtils.getValueAndUnits(w); + + this.positionSize.heightUnits = hvu[1] || "px"; // canvas (and shapes) don't have units. + this.positionSize.heightSize = hvu[0]; + this.positionSize.widthUnits = wvu[1] || "px"; + this.positionSize.widthSize = wvu[0]; if(this.threeD.inGlobalMode) { @@ -277,10 +306,19 @@ exports.Properties = Montage.create(Component, { if(control.type !== "color") { currentValue = ElementsMediator.getProperty(el, control.prop, control.valueMutator); - if(currentValue === null) { - currentValue = control.defaultValue; + if(control.type === "hottext") { + if(currentValue == null) { + currentValue = control.defaultValue; + } + currentValue = document.application.njUtils.getValueAndUnits(currentValue); + this.customSections[i].content.controls[control.id + "Units"] = currentValue[1] || "px"; + this.customSections[i].content.controls[control.id] = currentValue[0]; + } else { + if(currentValue === null) { + currentValue = control.defaultValue; + } + this.customSections[i].content.controls[control.id] = currentValue; } - this.customSections[i].content.controls[control.id] = currentValue; } else { if(control.prop === "border") { // TODO - For now, always return the top border if multiple border sides @@ -402,7 +440,11 @@ exports.Properties = Montage.create(Component, { value: function(e) { if(e.wasSetByCode) return; - ElementsMediator.setProperty(this.application.ninja.selectedElements, e.prop, [e.value + "px"], "Changing", "pi"); + var newValue; + + e.units ? newValue = e.value + e.units : newValue = e.value; + + ElementsMediator.setProperty(this.application.ninja.selectedElements, e.prop, [newValue], "Changing", "pi"); } } -- cgit v1.2.3 From 1bb2778224982aea7b9781c6559bb659983a400f Mon Sep 17 00:00:00 2001 From: Nivesh Rajbhandari Date: Wed, 13 Jun 2012 11:25:20 -0700 Subject: We need to guard against cases where some PI controls are using HottextUnit but don't actually allow uses to change those units. Signed-off-by: Nivesh Rajbhandari --- js/panels/properties.reel/properties.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'js/panels/properties.reel/properties.js') diff --git a/js/panels/properties.reel/properties.js b/js/panels/properties.reel/properties.js index 33e66515..97dc017d 100755 --- a/js/panels/properties.reel/properties.js +++ b/js/panels/properties.reel/properties.js @@ -310,9 +310,13 @@ exports.Properties = Montage.create(Component, { if(currentValue == null) { currentValue = control.defaultValue; } - currentValue = document.application.njUtils.getValueAndUnits(currentValue); - this.customSections[i].content.controls[control.id + "Units"] = currentValue[1] || "px"; - this.customSections[i].content.controls[control.id] = currentValue[0]; + if(typeof(currentValue) === "string") { + currentValue = document.application.njUtils.getValueAndUnits(currentValue); + this.customSections[i].content.controls[control.id + "Units"] = currentValue[1] || "px"; + this.customSections[i].content.controls[control.id] = currentValue[0]; + } else { + this.customSections[i].content.controls[control.id] = currentValue; + } } else { if(currentValue === null) { currentValue = control.defaultValue; -- cgit v1.2.3