Simplify PathStyle further, by removing the _get/_setChildrenStyle methods and moving their functionality into the closure injection code.

This commit is contained in:
Jürg Lehni 2011-02-17 23:37:21 +00:00
parent 4e05faaa11
commit 2c06ec965c

View file

@ -15,25 +15,6 @@ PathStyle = Base.extend(new function() {
this[key] = style[key];
}
}
},
_setChildrenStyle: function(name, value) {
for (var i = 0, l = this.item.children.length; i < l; i++) {
this.item.children[i].style[name] = value;
}
},
_getChildrenStyle: function(name) {
var style;
for (var i = 0, l = this.item.children.length; i < l; i++) {
if(!style) {
style = this.item.children[i].style[name];
} else if(style != this.item.children[i].style[name]) {
// If there is another item with a different style:
return null;
}
}
return style;
}
}
@ -43,7 +24,9 @@ PathStyle = Base.extend(new function() {
fields['set' + key.capitalize()] = function(value) {
if(this.item && this.item.children) {
this._setChildrenStyle(key, value);
for (var i = 0, l = this.item.children.length; i < l; i++) {
this.item.children[i].style[key] = value;
}
} else {
this['_' + key] = value;
}
@ -51,7 +34,16 @@ PathStyle = Base.extend(new function() {
fields['get' + key.capitalize()] = function() {
if(this.item && this.item.children) {
return this._getChildrenStyle(key);
var style;
for (var i = 0, l = this.item.children.length; i < l; i++) {
if(!style) {
style = this.item.children[i].style[key];
} else if(style != this.item.children[i].style[key]) {
// If there is another item with a different style:
return null;
}
}
return style;
} else {
return this['_' + key];
}