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/components/hottext.reel/hottext.js | 13 +++++++++++-- js/components/hottextunit.reel/hottextunit.js | 9 ++++++--- 2 files changed, 17 insertions(+), 5 deletions(-) (limited to 'js/components') 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, { value: 2000 }, + // Flag used to dispatch a single change event if either or both of value and units are changed + _unitsModified: { + enumerable: false, + value: false + }, + value: { serializable: true, enumerable: true, get: function() { return this._value; }, - set: function(value, fromInput) { + set: function(value) { if (isNaN(value)) { this._valueSyncedWithInputField = false; this.needsDraw = true; @@ -149,6 +155,9 @@ var HotText = exports.HotText = Montage.create(SliderBase, { this._valueSyncedWithInputField = false; this.needsDraw = true; this._dispatchActionEvent(); + } else if(this._unitsModified) { + // Need to dispatch change event if units changed + this._dispatchActionEvent(); } } }, @@ -164,7 +173,7 @@ var HotText = exports.HotText = Montage.create(SliderBase, { enumerable: false, value: function() { this._setEventFlags("change", false); - Object.getPropertyDescriptor(this, "value").set.call(this, this.inputFunction(this.element.value), true); + this.value = this.inputFunction(this.element.value); } }, 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, { if(this._acceptableUnits.indexOf(value) !== -1) { this._units = value; + this._unitsModified = true; this.needsDraw = true; - this._setEventFlags("change", false); + this._setEventFlags("change", true); this._dispatchActionEvent(); } + } else { + this._unitsModified = false; } } }, @@ -89,13 +92,13 @@ var HotTextUnit = exports.HotTextUnit = Montage.create(HotText, { var match = (unitsString.replace(noSpaces, "$2")).toLowerCase(); if(match) { - Object.getPropertyDescriptor(this, "units").set.call(this, match); + this.units = match; } } this._setEventFlags("change", false); // Moving this call to after setting the value since value changes are dispatching events before units are set - Object.getPropertyDescriptor(this, "value").set.call(this, this.inputFunction(inputString), false); + this.value = this.inputFunction(inputString); } }, -- cgit v1.2.3