aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-06-12 15:13:09 -0700
committerNivesh Rajbhandari2012-06-12 15:13:09 -0700
commit509092ff335f74517a413cfb2deeb9d2de20f8e3 (patch)
tree86dddcb4b74f04c965da52180cab3c49529148cf
parent6854a72504f57903bd5de003e377f2aefb02d0da (diff)
downloadninja-509092ff335f74517a413cfb2deeb9d2de20f8e3.tar.gz
Fixing properties panel to support px and % for body and other elements.
Signed-off-by: Nivesh Rajbhandari <mqg734@motorola.com>
-rwxr-xr-xjs/components/hottext.reel/hottext.js13
-rwxr-xr-xjs/components/hottextunit.reel/hottextunit.js9
-rwxr-xr-xjs/controllers/elements/body-controller.js2
-rwxr-xr-xjs/data/pi/pi-data.js60
-rwxr-xr-xjs/panels/properties.reel/properties.js70
-rwxr-xr-xjs/panels/properties.reel/sections/custom.reel/custom.js6
-rwxr-xr-xjs/panels/properties.reel/sections/position-size.reel/position-size.html16
-rwxr-xr-xjs/panels/properties.reel/sections/position-size.reel/position-size.js40
8 files changed, 151 insertions, 65 deletions
diff --git a/js/components/hottext.reel/hottext.js b/js/components/hottext.reel/hottext.js
index 0480597a..93e6e745 100755
--- a/js/components/hottext.reel/hottext.js
+++ b/js/components/hottext.reel/hottext.js
@@ -121,13 +121,19 @@ var HotText = exports.HotText = Montage.create(SliderBase, {
121 value: 2000 121 value: 2000
122 }, 122 },
123 123
124 // Flag used to dispatch a single change event if either or both of value and units are changed
125 _unitsModified: {
126 enumerable: false,
127 value: false
128 },
129
124 value: { 130 value: {
125 serializable: true, 131 serializable: true,
126 enumerable: true, 132 enumerable: true,
127 get: function() { 133 get: function() {
128 return this._value; 134 return this._value;
129 }, 135 },
130 set: function(value, fromInput) { 136 set: function(value) {
131 if (isNaN(value)) { 137 if (isNaN(value)) {
132 this._valueSyncedWithInputField = false; 138 this._valueSyncedWithInputField = false;
133 this.needsDraw = true; 139 this.needsDraw = true;
@@ -149,6 +155,9 @@ var HotText = exports.HotText = Montage.create(SliderBase, {
149 this._valueSyncedWithInputField = false; 155 this._valueSyncedWithInputField = false;
150 this.needsDraw = true; 156 this.needsDraw = true;
151 this._dispatchActionEvent(); 157 this._dispatchActionEvent();
158 } else if(this._unitsModified) {
159 // Need to dispatch change event if units changed
160 this._dispatchActionEvent();
152 } 161 }
153 } 162 }
154 }, 163 },
@@ -164,7 +173,7 @@ var HotText = exports.HotText = Montage.create(SliderBase, {
164 enumerable: false, 173 enumerable: false,
165 value: function() { 174 value: function() {
166 this._setEventFlags("change", false); 175 this._setEventFlags("change", false);
167 Object.getPropertyDescriptor(this, "value").set.call(this, this.inputFunction(this.element.value), true); 176 this.value = this.inputFunction(this.element.value);
168 } 177 }
169 }, 178 },
170 179
diff --git a/js/components/hottextunit.reel/hottextunit.js b/js/components/hottextunit.reel/hottextunit.js
index 448eb9d7..2a89db03 100755
--- a/js/components/hottextunit.reel/hottextunit.js
+++ b/js/components/hottextunit.reel/hottextunit.js
@@ -40,11 +40,14 @@ var HotTextUnit = exports.HotTextUnit = Montage.create(HotText, {
40 if(this._acceptableUnits.indexOf(value) !== -1) 40 if(this._acceptableUnits.indexOf(value) !== -1)
41 { 41 {
42 this._units = value; 42 this._units = value;
43 this._unitsModified = true;
43 this.needsDraw = true; 44 this.needsDraw = true;
44 45
45 this._setEventFlags("change", false); 46 this._setEventFlags("change", true);
46 this._dispatchActionEvent(); 47 this._dispatchActionEvent();
47 } 48 }
49 } else {
50 this._unitsModified = false;
48 } 51 }
49 } 52 }
50 }, 53 },
@@ -89,13 +92,13 @@ var HotTextUnit = exports.HotTextUnit = Montage.create(HotText, {
89 var match = (unitsString.replace(noSpaces, "$2")).toLowerCase(); 92 var match = (unitsString.replace(noSpaces, "$2")).toLowerCase();
90 if(match) 93 if(match)
91 { 94 {
92 Object.getPropertyDescriptor(this, "units").set.call(this, match); 95 this.units = match;
93 } 96 }
94 } 97 }
95 98
96 this._setEventFlags("change", false); 99 this._setEventFlags("change", false);
97 // Moving this call to after setting the value since value changes are dispatching events before units are set 100 // Moving this call to after setting the value since value changes are dispatching events before units are set
98 Object.getPropertyDescriptor(this, "value").set.call(this, this.inputFunction(inputString), false); 101 this.value = this.inputFunction(inputString);
99 } 102 }
100 }, 103 },
101 104
diff --git a/js/controllers/elements/body-controller.js b/js/controllers/elements/body-controller.js
index 0dc11b82..27989c65 100755
--- a/js/controllers/elements/body-controller.js
+++ b/js/controllers/elements/body-controller.js
@@ -37,7 +37,7 @@ exports.BodyController = Montage.create(ElementController, {
37 case "height": 37 case "height":
38 case "width": 38 case "width":
39 case "-webkit-transform-style": 39 case "-webkit-transform-style":
40 return this.application.ninja.stylesController.getElementStyle(el, p, true, true); 40 return this.application.ninja.stylesController.getElementStyle(el, p);
41 default: 41 default:
42 return ElementController.getProperty(el, p, true, true); 42 return ElementController.getProperty(el, p, true, true);
43 //console.log("Undefined Stage property ", p); 43 //console.log("Undefined Stage property ", p);
diff --git a/js/data/pi/pi-data.js b/js/data/pi/pi-data.js
index 92d70141..e3e1de15 100755
--- a/js/data/pi/pi-data.js
+++ b/js/data/pi/pi-data.js
@@ -52,8 +52,8 @@ exports.PiData = Montage.create( Montage, {
52 type : "hottext", 52 type : "hottext",
53 id : "borderWidth", 53 id : "borderWidth",
54 prop : "border-width", 54 prop : "border-width",
55 defaultValue: 0, 55 defaultValue: "0 px",
56 valueMutator: parseFloat, 56 inputFunction: parseFloat,
57 label : "Border", 57 label : "Border",
58 min : 0, 58 min : 0,
59 max : 100, 59 max : 100,
@@ -131,8 +131,8 @@ exports.PiData = Montage.create( Montage, {
131 type : "hottext", 131 type : "hottext",
132 id : "borderWidth", 132 id : "borderWidth",
133 prop : "border-width", 133 prop : "border-width",
134 defaultValue: 0, 134 defaultValue: "0 px",
135 valueMutator: parseFloat, 135 inputFunction: parseFloat,
136 label : "Border", 136 label : "Border",
137 min : 0, 137 min : 0,
138 max : 100, 138 max : 100,
@@ -254,8 +254,8 @@ exports.PiData = Montage.create( Montage, {
254 type : "hottext", 254 type : "hottext",
255 id : "borderWidth", 255 id : "borderWidth",
256 prop : "border-width", 256 prop : "border-width",
257 defaultValue: 0, 257 defaultValue: "0 px",
258 valueMutator: parseFloat, 258 inputFunction: parseFloat,
259 label : "Border", 259 label : "Border",
260 min : 0, 260 min : 0,
261 max : 100, 261 max : 100,
@@ -313,7 +313,7 @@ exports.PiData = Montage.create( Montage, {
313 id : "strokeSize", 313 id : "strokeSize",
314 prop : "strokeSize", 314 prop : "strokeSize",
315 label : "Stroke", 315 label : "Stroke",
316 valueMutator: parseFloat, 316 inputFunction: parseFloat,
317 min : 0, 317 min : 0,
318 max : 100, 318 max : 100,
319 value : 1, 319 value : 1,
@@ -333,23 +333,23 @@ exports.PiData = Montage.create( Montage, {
333 id: "tlRadius", 333 id: "tlRadius",
334 prop : "tlRadius", 334 prop : "tlRadius",
335 label: "TL", 335 label: "TL",
336 valueMutator: parseFloat, 336 inputFunction: parseFloat,
337 value : 0, 337 value : 0,
338 min : 0, 338 min : 0,
339 max : 100, 339 max : 1000,
340 unit : "px", 340 acceptableUnits: ["px", "pt", "%"],
341 acceptableUnits: ["px", "pt", "%"] 341 unit : "px"
342 }, 342 },
343 { 343 {
344 type : "hottext", 344 type : "hottext",
345 id : "trRadius", 345 id : "trRadius",
346 prop : "trRadius", 346 prop : "trRadius",
347 label : "TR", 347 label : "TR",
348 valueMutator: parseFloat, 348 inputFunction: parseFloat,
349 min : 0, 349 min : 0,
350 max : 100, 350 max : 1000,
351 unit : "px",
352 acceptableUnits: ["px", "pt", "%"], 351 acceptableUnits: ["px", "pt", "%"],
352 unit : "px",
353 divider: true 353 divider: true
354 } 354 }
355 ], 355 ],
@@ -359,22 +359,22 @@ exports.PiData = Montage.create( Montage, {
359 id : "blRadius", 359 id : "blRadius",
360 prop : "blRadius", 360 prop : "blRadius",
361 label : "BL", 361 label : "BL",
362 valueMutator: parseFloat, 362 inputFunction: parseFloat,
363 min : 0, 363 min : 0,
364 max : 100, 364 max : 1000,
365 unit : "px", 365 acceptableUnits: ["px", "pt", "%"],