mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
added support for .walk(..)'ing custom lists of elements...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
904d00d16d
commit
a3bfda9a29
@ -1791,9 +1791,6 @@ var BaseBrowserPrototype = {
|
|||||||
// opts)
|
// opts)
|
||||||
// : opts)
|
// : opts)
|
||||||
// XXX revise if stage 2 is applicable to sections other than .items
|
// XXX revise if stage 2 is applicable to sections other than .items
|
||||||
// XXX INLINED_ID: generate id's for inlined items (inlined arrays)...
|
|
||||||
// ...where do we store .id for arrays???
|
|
||||||
// ...should the id be human-readable, something like inlined<date> ???
|
|
||||||
make: function(options){
|
make: function(options){
|
||||||
var that = this
|
var that = this
|
||||||
options = Object.assign(
|
options = Object.assign(
|
||||||
@ -2031,11 +2028,25 @@ var BaseBrowserPrototype = {
|
|||||||
// .walk(null[, options])
|
// .walk(null[, options])
|
||||||
// -> list
|
// -> list
|
||||||
//
|
//
|
||||||
|
//
|
||||||
// Walk the tree passing each elem to func(..)
|
// Walk the tree passing each elem to func(..)
|
||||||
|
// .walk(func(..))
|
||||||
// .walk(func(..)[, options])
|
// .walk(func(..)[, options])
|
||||||
// -> list
|
// -> list
|
||||||
// -> res
|
// -> res
|
||||||
//
|
//
|
||||||
|
// Walk a list of items matching query (compatible with .search(..))...
|
||||||
|
// .walk(query, func(..))
|
||||||
|
// .walk(query, func(..), options)
|
||||||
|
// -> list
|
||||||
|
// -> res
|
||||||
|
//
|
||||||
|
// Walk a custom list of items...
|
||||||
|
// .walk([item, ...], func(..))
|
||||||
|
// .walk([item, ...], func(..), options)
|
||||||
|
// -> list
|
||||||
|
// -> res
|
||||||
|
//
|
||||||
//
|
//
|
||||||
// Handle elem...
|
// Handle elem...
|
||||||
// func(elem, index, path, next(..), stop(..))
|
// func(elem, index, path, next(..), stop(..))
|
||||||
@ -2139,10 +2150,14 @@ var BaseBrowserPrototype = {
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// XXX might be good to be able to return the partial result via stop(..)
|
// XXX might be good to be able to return the partial result via stop(..)
|
||||||
// XXX INLINED_ID: need to handle inlined item id correctly...
|
|
||||||
walk: function(func, options){
|
walk: function(func, options){
|
||||||
var that = this
|
var that = this
|
||||||
var [func=null, options={}, path=[], context={}] = [...arguments]
|
|
||||||
|
var args = [...arguments]
|
||||||
|
var list = !(args[0] instanceof Function || args[0] == null) ?
|
||||||
|
args.shift()
|
||||||
|
: false
|
||||||
|
var [func=null, options={}, path=[], context={}] = args
|
||||||
|
|
||||||
// context...
|
// context...
|
||||||
context.root = context.root || this
|
context.root = context.root || this
|
||||||
@ -2290,7 +2305,11 @@ var BaseBrowserPrototype = {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return handleReverse(
|
return handleReverse(
|
||||||
sections
|
list ?
|
||||||
|
(list instanceof Array ?
|
||||||
|
list
|
||||||
|
: this.search(list, options))
|
||||||
|
: sections
|
||||||
.map(function(section){
|
.map(function(section){
|
||||||
return that[section] || [] })
|
return that[section] || [] })
|
||||||
.flat())
|
.flat())
|
||||||
@ -3207,12 +3226,12 @@ var BaseBrowserPrototype = {
|
|||||||
|
|
||||||
// XXX EXPERIMENTAL....
|
// XXX EXPERIMENTAL....
|
||||||
//
|
//
|
||||||
// XXX add support for headless nested blocks...
|
|
||||||
__renderer__: TextRenderer,
|
__renderer__: TextRenderer,
|
||||||
// XXX need:
|
// XXX need:
|
||||||
// - section rendering... (DONE)
|
// - section rendering... (DONE)
|
||||||
// - from/to/around/count support...
|
// - from/to/around/count support...
|
||||||
// - ability to render separate items/sub-trees or lists of items...
|
// - ability to render separate items/sub-trees or lists of items...
|
||||||
|
// ...pass the list to .walk(..), i.e. .walk(list/query, ...)
|
||||||
render2: function(options, renderer){
|
render2: function(options, renderer){
|
||||||
var that = this
|
var that = this
|
||||||
|
|
||||||
@ -4165,6 +4184,7 @@ module.HTMLRenderer = {
|
|||||||
},
|
},
|
||||||
inline: function(elem, lst, index, path, options){
|
inline: function(elem, lst, index, path, options){
|
||||||
},
|
},
|
||||||
|
// XXX add support for headless nested blocks...
|
||||||
nest: function(header, lst, index, path, options){
|
nest: function(header, lst, index, path, options){
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user