split the base make/update/render API and DOM stuff...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2019-01-24 05:56:37 +03:00
parent 893d6a731f
commit 3ae2014338

View File

@ -112,17 +112,27 @@ Items.ListTitle = function(){}
//--------------------------------------------------------------------- //---------------------------------------------------------------------
var BrowserClassPrototype = { var BaseBrowserClassPrototype = {
} }
// XXX move the DOM to a subclass and rename this to BaseBrowser var BaseBrowserPrototype = {
var BrowserPrototype = { // XXX should we mix item/list options or separate them into sub-objects???
options: { options: null,
// XXX
},
dom: null,
// Format:
// [
// <item> | <browser>,
// ...
// ]
//
// <item> format:
// {
// item: ...,
//
// // options...
// ...
// }
//
// XXX format doc... // XXX format doc...
items: null, items: null,
@ -131,13 +141,16 @@ var BrowserPrototype = {
// //
// XXX is this the right name??? // XXX is this the right name???
// XXX do we care about the return value??? // XXX do we care about the return value???
list: null, // XXX not sure how to handle options in here -- see .make(..) and its notes...
list: function(make, options){
throw new Error('.list(..): Not implemented.') },
// Make .items... // Make .items...
// //
// .make() // .make()
// -> this // -> this
// //
// XXX revise options handling for .list(..)
make: function(options){ make: function(options){
var items = this.items = [] var items = this.items = []
@ -152,7 +165,14 @@ var BrowserPrototype = {
make.__proto__ = Items make.__proto__ = Items
make.dialog = this make.dialog = this
this.list(make) // XXX not sure about this...
//this.list(make)
this.list(make,
options ?
Object.assign(
Object.create(this.options || {}),
options || {})
: null)
return this return this
}, },
@ -209,6 +229,56 @@ var BrowserPrototype = {
.render(this, options) }, .render(this, options) },
__init__: function(func, options){
this.list = func
this.options = Object.assign(
{},
this.options || {},
options || {})
this.update()
},
}
var BaseBrowser =
module.BaseBrowser =
object.makeConstructor('BaseBrowser',
BaseBrowserClassPrototype,
BaseBrowserPrototype)
//---------------------------------------------------------------------
var BrowserClassPrototype = {
__proto__: BaseBrowser,
}
var BrowserPrototype = {
__proto__: BaseBrowser.prototype,
options: {
},
dom: null,
// Render main list...
// XXX update dom...
renderList: function(items, options){
// XXX save link to dom...
this.dom = null
return items },
// Render nested list...
renderSubList: function(items, options){
// XXX save link to dom...
return items },
// Render list item...
renderItem: function(item, options){
// XXX save link to dom...
return item },
filter: function(){}, filter: function(){},
get: function(){}, get: function(){},
@ -227,18 +297,10 @@ var BrowserPrototype = {
// XXX scroll... // XXX scroll...
__init__: function(func, options){
this.list = func
this.options = Object.assign(
{},
this.options,
options || {})
this.update()
},
} }
// XXX should this be a Widget too???
var Browser = var Browser =
module.Browser = module.Browser =
object.makeConstructor('Browser', object.makeConstructor('Browser',