mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Implement object literal constructor for Palette.
This commit is contained in:
parent
d6481bcb5b
commit
139adc72de
1 changed files with 13 additions and 1 deletions
|
@ -20,12 +20,20 @@
|
|||
// Defaults for internals
|
||||
_enabled: true,
|
||||
|
||||
// DOCS: Palette#initialize
|
||||
// DOCS: Palette#initialize(props)
|
||||
// DOCS: Palette#initialize(title, components, values)
|
||||
// DOCS: Palette#components
|
||||
// DOCS: Palette#values
|
||||
// DOCS: Palette#remove()
|
||||
|
||||
initialize: function Palette(title, components, values) {
|
||||
// Support object literal constructor
|
||||
var props = Base.isPlainObject(title) && title;
|
||||
if (props) {
|
||||
title = props.title;
|
||||
components = props.components;
|
||||
values = props.values;
|
||||
}
|
||||
var parent = DomElement.find('.palettejs-panel')
|
||||
|| DomElement.find('body').appendChild(
|
||||
DomElement.create('div', { class: 'palettejs-panel' }));
|
||||
|
@ -67,6 +75,10 @@
|
|||
});
|
||||
}
|
||||
});
|
||||
if (props) {
|
||||
Base.set(this, props,
|
||||
{ title: true, components: true, values: true });
|
||||
}
|
||||
if (window.paper)
|
||||
paper.palettes.push(this);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue