aboutsummaryrefslogtreecommitdiff
path: root/js/panels
diff options
context:
space:
mode:
authorEric Guzman2012-05-16 14:12:14 -0700
committerEric Guzman2012-05-16 14:12:14 -0700
commitac76f688b392f3c5959ec8d651ec35fe311c7a53 (patch)
treeacb44e5a047059d0343f02d7404bdb9f192901d5 /js/panels
parent5164c2415c8a0750c21299325bb1caa8a97fc5b5 (diff)
downloadninja-ac76f688b392f3c5959ec8d651ec35fe311c7a53.tar.gz
Style Declaration - Fix update/add/addNew methods
Diffstat (limited to 'js/panels')
-rw-r--r--js/panels/css-panel/style-declaration.reel/style-declaration.js48
1 files changed, 41 insertions, 7 deletions
diff --git a/js/panels/css-panel/style-declaration.reel/style-declaration.js b/js/panels/css-panel/style-declaration.reel/style-declaration.js
index 33e77297..7ba00cc7 100644
--- a/js/panels/css-panel/style-declaration.reel/style-declaration.js
+++ b/js/panels/css-panel/style-declaration.reel/style-declaration.js
@@ -86,9 +86,9 @@ exports.StyleDeclaration = Montage.create(Component, {
86 86
87 if(this.includeEmptyStyle) { 87 if(this.includeEmptyStyle) {
88 this.styles.push({ 88 this.styles.push({
89 "name": "property", 89 name : "property",
90 "value" : "value", 90 value : "value",
91 "isEmpty": true 91 isEmpty : true
92 }); 92 });
93 } 93 }
94 94
@@ -159,6 +159,26 @@ exports.StyleDeclaration = Montage.create(Component, {
159 if(i) { 159 if(i) {
160 this.styles[i].value = this.declaration.getPropertyValue(prop); 160 this.styles[i].value = this.declaration.getPropertyValue(prop);
161 usedIndices.push(i); 161 usedIndices.push(i);
162 } else {
163 //// styles doesn't exist, does shorthand?
164 var shorthands = ShorthandProps.CSS_SHORTHAND_MAP[prop],
165 shorthandUpdated = false;
166
167 if(shorthands) {
168 shorthands.forEach(function(shorthand) {
169 var shorthandIndex = styleToIndexMap[shorthand];
170 if(shorthandIndex) {
171 //// if shorthand exists in list of rendered styles
172 //// update it
173 this.styles[shorthandIndex].value = this.declaration.getPropertyValue(shorthand);
174 shorthandUpdated = true;
175 }
176 }, this);
177 }
178
179 if(!shorthandUpdated) {
180 this.addStyle(prop, this.declaration.getPropertyValue(prop));
181 }
162 } 182 }
163 }, this); 183 }, this);
164 184
@@ -179,13 +199,27 @@ exports.StyleDeclaration = Montage.create(Component, {
179 199
180 addNewStyle : { 200 addNewStyle : {
181 value: function() { 201 value: function() {
182 this.styles.push({ 202 this.addStyle('property', 'value', {
183 "name": "property", 203 isEmpty : true
184 "value" : "value",
185 "isEmpty": true
186 }); 204 });
187 } 205 }
188 }, 206 },
207 addStyle : {
208 value: function(property, value, data) {
209 var styleDescriptor = {
210 property : property,
211 value : value
212 }, prop;
213
214 for(prop in data) {
215 if(data.hasOwnProperty(prop)) {
216 styleDescriptor[prop] = data[prop];
217 }
218 }
219
220 this.arrayController.addObjects(styleDescriptor);
221 }
222 },
189 223
190 /* drag/drop events */ 224 /* drag/drop events */
191 handleDrop : { 225 handleDrop : {