mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 02:10:08 +00:00
refatoring and simplification...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
08d5d4bad9
commit
a6eebf4aae
@ -84,6 +84,7 @@ Items.group = function(...items){
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX add support for lists of items (a-la .group(..))
|
||||||
Items.nest = function(item, list, options){
|
Items.nest = function(item, list, options){
|
||||||
options = options || {}
|
options = options || {}
|
||||||
options.sublist = list
|
options.sublist = list
|
||||||
@ -280,10 +281,6 @@ var BaseBrowserPrototype = {
|
|||||||
sublist,
|
sublist,
|
||||||
])
|
])
|
||||||
: sublist },
|
: sublist },
|
||||||
// Render nested list header...
|
|
||||||
// XXX should this be a renderer or an option to .renderItem(..)???
|
|
||||||
renderNestedHeader: function(item, i, options){
|
|
||||||
return this.renderItem(...arguments) },
|
|
||||||
// Render list item...
|
// Render list item...
|
||||||
// NOTE: to skip rendering an item/list return null...
|
// NOTE: to skip rendering an item/list return null...
|
||||||
renderItem: function(item, i, options){
|
renderItem: function(item, i, options){
|
||||||
@ -353,19 +350,18 @@ var BaseBrowserPrototype = {
|
|||||||
// XXX should we always render the nested list here,
|
// XXX should we always render the nested list here,
|
||||||
// only rendering it empty if collapsed???
|
// only rendering it empty if collapsed???
|
||||||
: item.sublist ?
|
: item.sublist ?
|
||||||
(item.collapsed ?
|
that.renderNested(
|
||||||
// collapsed item...
|
that.renderItem(item, i, options),
|
||||||
that.renderNestedHeader(item, i, options)
|
// collapsed...
|
||||||
// expanded item (grouped)...
|
(item.collapsed ?
|
||||||
: that.renderNested(
|
null
|
||||||
that.renderNestedHeader(item, i, options),
|
// renderable...
|
||||||
item.sublist.render instanceof Function ?
|
:item.sublist.render instanceof Function ?
|
||||||
// renderable...
|
item.sublist.render(context)
|
||||||
item.sublist.render(context)
|
// list of items...
|
||||||
// list of items...
|
: item.sublist.map(_render)),
|
||||||
: item.sublist.map(_render),
|
item,
|
||||||
item,
|
options)
|
||||||
options))
|
|
||||||
// basic item...
|
// basic item...
|
||||||
: that.renderItem(item, i, options)) })
|
: that.renderItem(item, i, options)) })
|
||||||
.filter(function(e){
|
.filter(function(e){
|
||||||
@ -535,18 +531,27 @@ var TextBrowserPrototype = {
|
|||||||
: value },
|
: value },
|
||||||
renderNested: function(header, sublist, item, options){
|
renderNested: function(header, sublist, item, options){
|
||||||
var that = this
|
var that = this
|
||||||
var nested = sublist
|
var nested = sublist
|
||||||
.flat()
|
&& sublist
|
||||||
.map(function(e){
|
.flat()
|
||||||
return e instanceof Array ?
|
.map(function(e){
|
||||||
e.map(function(e){ return (that.options.renderIndent || ' ') + e })
|
return e instanceof Array ?
|
||||||
: e })
|
e.map(function(e){
|
||||||
.flat()
|
return (that.options.renderIndent || ' ') + e })
|
||||||
return header ?
|
: e })
|
||||||
[header, nested]
|
.flat()
|
||||||
: nested },
|
return (
|
||||||
renderNestedHeader: function(item, i, options){
|
// expanded...
|
||||||
return this.renderItem(...arguments) + (item.collapsed ? ' >' : ' v') },
|
header && nested ?
|
||||||
|
[
|
||||||
|
header + ' v',
|
||||||
|
nested,
|
||||||
|
]
|
||||||
|
// collapsed...
|
||||||
|
: header ?
|
||||||
|
[ header + ' >' ]
|
||||||
|
// headerless...
|
||||||
|
: nested )},
|
||||||
}
|
}
|
||||||
|
|
||||||
var TextBrowser =
|
var TextBrowser =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user