aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/style-declaration.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/css-panel/style-declaration.reel')
-rw-r--r--js/panels/css-panel/style-declaration.reel/style-declaration.html5
-rw-r--r--js/panels/css-panel/style-declaration.reel/style-declaration.js38
2 files changed, 35 insertions, 8 deletions
diff --git a/js/panels/css-panel/style-declaration.reel/style-declaration.html b/js/panels/css-panel/style-declaration.reel/style-declaration.html
index 5724ffc3..b1381bc6 100644
--- a/js/panels/css-panel/style-declaration.reel/style-declaration.html
+++ b/js/panels/css-panel/style-declaration.reel/style-declaration.html
@@ -44,6 +44,11 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
44 "declaration": {"@": "owner"} 44 "declaration": {"@": "owner"}
45 }, 45 },
46 "bindings": { 46 "bindings": {
47 "source" : {
48 "boundObject": {"@": "repetition"},
49 "boundObjectPropertyPath": "objectAtCurrentIteration",
50 "oneway": true
51 },
47 "propertyText" : { 52 "propertyText" : {
48 "boundObject": {"@": "repetition"}, 53 "boundObject": {"@": "repetition"},
49 "boundObjectPropertyPath": "objectAtCurrentIteration.name" 54 "boundObjectPropertyPath": "objectAtCurrentIteration.name"
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 75ea18cf..8e364d0d 100644
--- a/js/panels/css-panel/style-declaration.reel/style-declaration.js
+++ b/js/panels/css-panel/style-declaration.reel/style-declaration.js
@@ -154,13 +154,13 @@ exports.StyleDeclaration = Montage.create(Component, {
154 styleToIndexMap = this._getStyleToIndexMap(); 154 styleToIndexMap = this._getStyleToIndexMap();
155 155
156 Array.prototype.slice.call(this.declaration).forEach(function(prop, index) { 156 Array.prototype.slice.call(this.declaration).forEach(function(prop, index) {
157 var i = styleToIndexMap[prop]; 157 var styleObjectIndex = styleToIndexMap[prop];
158 158
159 ///// Style component exists for property 159 ///// Style component exists for property
160 ///// Update its value 160 ///// Update its value
161 if(i !== undefined) { 161 if(styleObjectIndex !== undefined) {
162 this.styles[i].value = this.declaration.getPropertyValue(prop); 162 this.styles[styleObjectIndex].value = this.declaration.getPropertyValue(prop);
163 usedIndices.push(i); 163 usedIndices.push(styleObjectIndex);
164 } else { 164 } else {
165 //// styles doesn't exist, does shorthand? 165 //// styles doesn't exist, does shorthand?
166 var shorthands = ShorthandProps.CSS_SHORTHAND_MAP[prop], 166 var shorthands = ShorthandProps.CSS_SHORTHAND_MAP[prop],
@@ -179,15 +179,26 @@ exports.StyleDeclaration = Montage.create(Component, {
179 } 179 }
180 180
181 if(!shorthandUpdated) { 181 if(!shorthandUpdated) {
182 //// push to usedIndices so we don't remove styles we just added
183 usedIndices.push(this.styles.length);
182 this.addStyle(prop, this.declaration.getPropertyValue(prop)); 184 this.addStyle(prop, this.declaration.getPropertyValue(prop));
183 } 185 }
184 } 186 }
185 }, this); 187 }, this);
186 188
189 for(var i = this.styles.length-1; i>=0; i--) {
190 if(usedIndices.indexOf(i) === -1) {
191 if(!this.styles[i].isEmpty) {
192 ///// index not used, remove style
193 this.removeStyle(this.styles[i]);
194 }
195 }
196 }
197
187 ///// Keep copy of cssText to know when we need to 198 ///// Keep copy of cssText to know when we need to
188 ///// update the view 199 ///// update the view
189 this.cssText = this.declaration.cssText; 200 this.cssText = this.declaration.cssText;
190 this.needsDraw = true; 201 this.needsDraw = this.needsSort = true;
191 } 202 }
192 } 203 }
193 }, 204 },
@@ -221,7 +232,18 @@ exports.StyleDeclaration = Montage.create(Component, {
221 } 232 }
222 233
223 this.styles.push(styleDescriptor); 234 this.styles.push(styleDescriptor);
224 this.arrayController.organizeObjects(); 235
236 this.needsSort = this.needsDraw = true;
237 }
238 },
239 removeStyle : {
240 value: function(styleDescriptor) {
241 var styleDescriptorIndex = this.styles.indexOf(styleDescriptor);
242
243 this.styles.splice(styleDescriptorIndex, 1);
244 //this.arrayController.removeObjects(styleDescriptor);
245
246 //this.needsDraw = true;
225 } 247 }
226 }, 248 },
227 249
@@ -259,7 +281,7 @@ exports.StyleDeclaration = Montage.create(Component, {
259 if(this.focusDelegate) { 281 if(this.focusDelegate) {
260 this.styleComponent.delegate = this.focusDelegate; 282 this.styleComponent.delegate = this.focusDelegate;
261 } 283 }
262 this.arrayController.sortFunction = this._styleSortFunction; 284 //this.arrayController.sortFunction = this._styleSortFunction;
263 } 285 }
264 }, 286 },
265 287
@@ -274,7 +296,7 @@ exports.StyleDeclaration = Montage.create(Component, {
274 willDraw : { 296 willDraw : {
275 value: function() { 297 value: function() {
276 if(this.needsSort) { 298 if(this.needsSort) {
277 this.arrayController.organizeObjects(); 299 //this.arrayController.organizeObjects();
278 this.needsSort = false; 300 this.needsSort = false;
279 } 301 }
280 } 302 }