Add definition of Base.capitalize() and remove dependencies of String#capitalize().

This commit is contained in:
Jürg Lehni 2011-03-04 19:46:41 +00:00
parent 702899b382
commit 93c3920505
3 changed files with 12 additions and 6 deletions

View file

@ -79,10 +79,10 @@ var GrayColor = this.GrayColor = Color.extend({
};
Base.each(componentWeights, function(weight, key) {
fields['get' + key.capitalize()] = function() {
fields['get' + Base.capitalize(key)] = function() {
return 1 - this._gray;
};
fields['set' + key.capitalize()] = function(value) {
fields['set' + Base.capitalize(key)] = function(value) {
this._cssString = null;
this._gray = this._gray * (1 - weight) + weight * (1 - value);
};

View file

@ -21,7 +21,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
Item.inject(Base.each(keys, function(key) {
var isColor = !!(key.match(/Color$/));
fields['set' + key.capitalize()] = function(value) {
fields['set' + Base.capitalize(key)] = function(value) {
if (this.item && this.item.children) {
for (var i = 0, l = this.item.children.length; i < l; i++) {
this.item.children[i].style[key] = value;
@ -31,7 +31,7 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
}
};
fields['get' + key.capitalize()] = function() {
fields['get' + Base.capitalize(key)] = function() {
if (this.item && this.item.children) {
var style;
for (var i = 0, l = this.item.children.length; i < l; i++) {
@ -50,11 +50,11 @@ var PathStyle = this.PathStyle = Base.extend(new function() {
}
};
this['set' + key.capitalize()] = function(value) {
this['set' + Base.capitalize(key)] = function(value) {
this.style[key] = value;
};
this['get' + key.capitalize()] = function() {
this['get' + Base.capitalize(key)] = function() {
return this.style[key];
};
}, { beans: true }));

View file

@ -9,6 +9,12 @@ var paper = new function() {
}
};
Base.capitalize = function(str) {
return str.replace(/\b[a-z]/g, function(match) {
return match.toUpperCase();
});
};
//#include "basic/Point.js"
//#include "basic/Size.js"
//#include "basic/Rectangle.js"