Move Item#toString() functionality to Base#toString().

For objects that define #_id and/or #_name.
This commit is contained in:
Jürg Lehni 2013-03-01 11:47:49 -08:00
parent bec61c6829
commit 5501f48570
2 changed files with 13 additions and 15 deletions

View file

@ -35,7 +35,11 @@ this.Base = Base.inject(/** @lends Base# */{
* Renders base objects to strings in object literal notation.
*/
toString: function() {
return '{ ' + Base.each(this, function(value, key) {
return this._id != null
? (this.constructor._name || 'Object') + (this._name
? " '" + this._name + "'"
: ' @' + this._id)
: '{ ' + Base.each(this, function(value, key) {
// Hide internal properties even if they are enumerable
if (!/^_/.test(key)) {
var type = typeof value;

View file

@ -2058,12 +2058,6 @@ var Item = this.Item = Base.extend(Callback, {
this.setBounds(newBounds);
},
toString: function() {
return (this.constructor._name || 'Item') + (this._name
? " '" + this._name + "'"
: ' @' + this._id);
},
// DOCS: document exportJson (documented in @private Base)
// DOCS: document importJson
// DOCS: Figure out a way to group these together with importSvg / exportSvg