From 2c06ec965c4bc19adf2d68d532ef368d4e529387 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 17 Feb 2011 23:37:21 +0000 Subject: [PATCH] Simplify PathStyle further, by removing the _get/_setChildrenStyle methods and moving their functionality into the closure injection code. --- src/item/PathStyle.js | 34 +++++++++++++--------------------- 1 file changed, 13 insertions(+), 21 deletions(-) diff --git a/src/item/PathStyle.js b/src/item/PathStyle.js index 2bbb925e..a0654897 100644 --- a/src/item/PathStyle.js +++ b/src/item/PathStyle.js @@ -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]; }