From e1fba03b340fd5999f792e9311189a7ef8df83fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Thu, 2 Oct 2014 17:02:26 +0200 Subject: [PATCH] Make Component#enabled work for row type. --- src/ui/Component.js | 10 +++++++++- src/ui/Pane.js | 13 ++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/ui/Component.js b/src/ui/Component.js index 94711260..d4f9ff24 100644 --- a/src/ui/Component.js +++ b/src/ui/Component.js @@ -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; }, diff --git a/src/ui/Pane.js b/src/ui/Pane.js index 07b6d14f..a6908aa0 100644 --- a/src/ui/Pane.js +++ b/src/ui/Pane.js @@ -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