From 6e4c2ebc64a735651e0a9b46006c6a2d160e4e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrg=20Lehni?= Date: Sun, 5 Oct 2014 00:23:16 +0200 Subject: [PATCH] Use an injection loop to produce all methods that simply forward from Palette to root Component. --- src/ui/Palette.js | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/ui/Palette.js b/src/ui/Palette.js index 6612ca81..4cebb23c 100644 --- a/src/ui/Palette.js +++ b/src/ui/Palette.js @@ -73,29 +73,13 @@ return this._values; }, - getTitle: function() { - return this._root.getTitle(); - }, - - setTitle: function(title) { - return this._root.setTitle(title); - }, - - getEnabled: function() { - return this._root.getEnabled(); - }, - - setEnabled: function(enabled) { - return this._root.setEnabled(enabled); - }, - /** + * @name Palette#reset() + * @function + * * Resets the values of the components to their * {@link Component#defaultValue}. */ - reset: function() { - this._root.reset(); - }, remove: function() { DomElement.remove(this._element); @@ -106,4 +90,11 @@ palettes.splice(index, 1); return remove; } -}); +}, Base.each(['getTitle', 'setTitle', 'getEnabled', 'setEnabled', 'reset'], + function(name) { + this[name] = function() { + var root = this._root; + return root[name].apply(root, arguments); + } + }, {}) +);