diff --git a/ui (gen4)/experiments/browse-dialog.html b/ui (gen4)/experiments/browse-dialog.html index 100436fc..2dfcad4d 100755 --- a/ui (gen4)/experiments/browse-dialog.html +++ b/ui (gen4)/experiments/browse-dialog.html @@ -191,7 +191,7 @@ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, b) .focus() - // Flat list demo... + // Custom flat list demo... f = browser.Browser($('.container.flat'), { data: [ 'option 1', @@ -226,7 +226,9 @@ requirejs(['../lib/keyboard', '../object', './browse-dialog'], function(k, o, b) }, }) - f = browser.makeList($('.container.flat2'), { + + // Default flat list demo... + f2 = browser.makeList($('.container.flat2'), { 'option 1': function(_, p){ console.log('option:', p) }, 'option 2': function(_, p){ console.log('option:', p) }, 'option 3': function(_, p){ console.log('option:', p) }, diff --git a/ui (gen4)/experiments/browse-dialog.js b/ui (gen4)/experiments/browse-dialog.js index af46a397..85152a71 100755 --- a/ui (gen4)/experiments/browse-dialog.js +++ b/ui (gen4)/experiments/browse-dialog.js @@ -920,42 +920,47 @@ object.makeConstructor('Browser', BrowserPrototype) -// Construct a flat list selector... +// Flat list... // -// makeList(, ) -// -> browser -// -// -// format: -// { -// : , -// ... -// } -// -// -// XXX should this be an object??? +// This expects a data option set with the following format: +// { +// : , +// ... +// } +// +// NOTE: this essentially a different default configuration of Browser... +var ListPrototype = Object.create(BrowserPrototype) +ListPrototype.options = { + + traversable: false, + flat: true, + + list: function(path, make){ + var that = this + return Object.keys(this.options.data) + .map(function(k){ + var e = make(k) + .on('open', function(){ + return that.options.data[k].apply(this, arguments) + }) + + return k + }) + }, +} +ListPrototype.options.__proto__ = BrowserPrototype.options + +var List = +module.List = +object.makeConstructor('List', + BrowserClassPrototype, + ListPrototype) + + +// This is a shorthand for: new List(, { data: }) var makeList = module.makeList = function(elem, list){ - return browser.Browser(elem, { - data: list, - - traversable: false, - flat: true, - - list: function(path, make){ - var that = this - return Object.keys(this.options.data) - .map(function(k){ - // make the element... - var e = make(k) - .on('open', function(){ - return that.options.data[k].apply(this, arguments) - }) - - return k - }) - }, - }) + return List(elem, { data: list }) }