Make Component#enabled work for row type.

This commit is contained in:
Jürg Lehni 2014-10-02 17:02:26 +02:00
parent f4c4522c18
commit e1fba03b34
2 changed files with 17 additions and 6 deletions

View file

@ -98,6 +98,8 @@ var Component = Base.extend(Callback, /** @lends Component# */{
this._row = row;
this._parent = parent; // The parent component, if any.
this._nested = !!parent;
if (!parent)
DomElement.set(row, 'id', 'palettejs-row-' + name);
var type = this._type = props.type in this._types
? props.type
: 'options' in props
@ -260,7 +262,13 @@ var Component = Base.extend(Callback, /** @lends Component# */{
this._previousEnabled = enabled ? undefined : prev; // clear
enabled = enabled && prev;
}
DomElement.set(this._input, 'disabled', !enabled);
if (this._input) {
DomElement.set(this._input, 'disabled', !enabled);
} else if (this._components) {
for (var i = 0; i < this._components.length; i++) {
this._components[i].setEnabled(enabled, _fromPalette);
}
}
this._enabled = !!enabled;
},

View file

@ -39,11 +39,14 @@ var Pane = Base.extend(Callback, /** @lends Pane# */{
this._values = values;
this._numCells = 2; // 2 cells per row is the default (label / item).
for (var name in components) {
var row = DomElement.create('tr', { class: 'palettejs-row' }),
component = new Component(this, name, components[name],
values[name], row);
DomElement.set(row, 'id', 'palettejs-row-' + component._name);
this._table.appendChild(row);
var component = components[name];
if (Base.isPlainObject(component)) {
var row = DomElement.addChildren(this._table,
['tr', { class: 'palettejs-row' }])[0];
new Component(this, name, components[name], values[name], row);
} else {
delete components[name];
}
}
if (this._numCells > 2) {
// Update colspan in all components that are not nested in another