mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-07 13:22:07 -05:00
Move Item#toString() functionality to Base#toString().
For objects that define #_id and/or #_name.
This commit is contained in:
parent
bec61c6829
commit
5501f48570
2 changed files with 13 additions and 15 deletions
|
@ -35,15 +35,19 @@ this.Base = Base.inject(/** @lends Base# */{
|
||||||
* Renders base objects to strings in object literal notation.
|
* Renders base objects to strings in object literal notation.
|
||||||
*/
|
*/
|
||||||
toString: function() {
|
toString: function() {
|
||||||
return '{ ' + Base.each(this, function(value, key) {
|
return this._id != null
|
||||||
// Hide internal properties even if they are enumerable
|
? (this.constructor._name || 'Object') + (this._name
|
||||||
if (!/^_/.test(key)) {
|
? " '" + this._name + "'"
|
||||||
var type = typeof value;
|
: ' @' + this._id)
|
||||||
this.push(key + ': ' + (type === 'number'
|
: '{ ' + Base.each(this, function(value, key) {
|
||||||
? Format.number(value)
|
// Hide internal properties even if they are enumerable
|
||||||
: type === 'string' ? "'" + value + "'" : value));
|
if (!/^_/.test(key)) {
|
||||||
}
|
var type = typeof value;
|
||||||
}, []).join(', ') + ' }';
|
this.push(key + ': ' + (type === 'number'
|
||||||
|
? Format.number(value)
|
||||||
|
: type === 'string' ? "'" + value + "'" : value));
|
||||||
|
}
|
||||||
|
}, []).join(', ') + ' }';
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2058,12 +2058,6 @@ var Item = this.Item = Base.extend(Callback, {
|
||||||
this.setBounds(newBounds);
|
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 exportJson (documented in @private Base)
|
||||||
// DOCS: document importJson
|
// DOCS: document importJson
|
||||||
// DOCS: Figure out a way to group these together with importSvg / exportSvg
|
// DOCS: Figure out a way to group these together with importSvg / exportSvg
|
||||||
|
|
Loading…
Reference in a new issue