Fix wrong default fillColor on TextItems.

This commit is contained in:
Jürg Lehni 2013-06-12 17:30:35 -07:00
parent cb0dcf1719
commit 34ad9045cc
2 changed files with 16 additions and 11 deletions

View file

@ -72,8 +72,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
else else
this._setProject(project); this._setProject(project);
} }
this._style = new Style(this._project._currentStyle); this._style = new Style(this._project._currentStyle, this);
this._style._item = this;
this._matrix = new Matrix(); this._matrix = new Matrix();
if (point) if (point)
this._matrix.translate(point); this._matrix.translate(point);
@ -382,7 +381,7 @@ var Item = Base.extend(Callback, /** @lends Item# */{
}, },
setStyle: function(style) { setStyle: function(style) {
this._style.initialize(style); this._style.set(style);
}, },
hasFill: function() { hasFill: function() {

View file

@ -202,17 +202,23 @@ var Style = Base.extend(new function() {
Item.inject(item); Item.inject(item);
return fields; return fields;
}, /** @lends Style# */{ }, /** @lends Style# */{
initialize: function Style(style) { initialize: function Style(style, _item) {
// We keep values in a separate object that we can iterate over. // We keep values in a separate object that we can iterate over.
this._values = {}; this._values = {};
if (this._item instanceof TextItem) this._item = _item;
if (_item instanceof TextItem)
this._defaults = this._textDefaults; this._defaults = this._textDefaults;
if (style) { if (style)
// If the passed style object is also a Style, clone its clonable this.set(style);
// fields rather than simply copying them. },
var isStyle = style instanceof Style,
// Use the other stlyle's _values object for iteration set: function(style) {
values = isStyle ? style._values : style; // If the passed style object is also a Style, clone its clonable
// fields rather than simply copying them.
var isStyle = style instanceof Style,
// Use the other stlyle's _values object for iteration
values = isStyle ? style._values : style;
if (values) {
for (var key in values) { for (var key in values) {
if (key in this._defaults) { if (key in this._defaults) {
var value = values[key]; var value = values[key];