From a3e8872f9f805791e5cef02c16192b00cbb23a85 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Sun, 22 Mar 2020 03:13:57 +0300 Subject: [PATCH] refactoring.... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/widget/browse2.js | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/ui (gen4)/lib/widget/browse2.js b/ui (gen4)/lib/widget/browse2.js index c3ab0a51..b8398309 100755 --- a/ui (gen4)/lib/widget/browse2.js +++ b/ui (gen4)/lib/widget/browse2.js @@ -587,6 +587,14 @@ object.mixinFlat(function(){}, { }) + +// XXX do we need a custom handler here??? +// XXX do we add defaults to options??? +var makeFieldWrapper = function(name){ + return function(title, value, options){ + return this.__proto__[name]([title, value], options) } } + + // Sub-context: .field // // [ title value ... ] @@ -621,18 +629,11 @@ Items.makeSubContext('field', : options.value ], options) }, { + // Shorthands... + Text: makeFieldWrapper('Text'), // XXX would be nice to force the title to be on a separate line // from the text... - Text: function(title, value, options){ - return this.__proto__.Text([title, value], options) }, - - // Editable field value... - // - // NOTE: this is a shorthand to: - // make.Editable([title, value], ..) - Editable: function(title, value, options){ - return this.__proto__.Editable([title, value], options) }, - + Editable: makeFieldWrapper('Editable'), // Togglable field value... //