mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-28 18:00:09 +00:00
added path to iterator...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
90afd124e9
commit
79dc989832
@ -744,27 +744,34 @@ var BaseBrowserPrototype = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
iter: function(func){
|
// XXX pass path to handlers...
|
||||||
|
iter: function(func, path){
|
||||||
var that = this
|
var that = this
|
||||||
|
path = path || []
|
||||||
var doElem = function(elem){
|
var doElem = function(elem){
|
||||||
return [func ?
|
return [func ?
|
||||||
func.call(that, elem)
|
func.call(that, elem, path.concat(elem.id))
|
||||||
: elem] }
|
: elem] }
|
||||||
return this.items
|
return this.items
|
||||||
.map(function(elem){
|
.map(function(elem){
|
||||||
return (
|
return (
|
||||||
// value is Browser (inline)...
|
// value is Browser (inline)...
|
||||||
elem.value instanceof Browser ?
|
elem.value instanceof Browser ?
|
||||||
elem.value.iter(func)
|
// XXX do we include the path of the parent elem
|
||||||
|
// in inlined browsers???
|
||||||
|
//elem.value.iter(func, path.concat(elem.id))
|
||||||
|
elem.value.iter(func, path.slice())
|
||||||
// .sublist is Browser (nested)...
|
// .sublist is Browser (nested)...
|
||||||
: elem.sublist instanceof Browser ?
|
: elem.sublist instanceof Browser ?
|
||||||
doElem(elem)
|
doElem(elem)
|
||||||
.concat(elem.sublist.iter(func))
|
.concat(elem.sublist.iter(func, path.concat(elem.id)))
|
||||||
// .sublist is Array (nested)...
|
// .sublist is Array (nested)...
|
||||||
: elem.sublist instanceof Array ?
|
: elem.sublist instanceof Array ?
|
||||||
doElem(elem)
|
doElem(elem)
|
||||||
.concat(func ?
|
.concat(func ?
|
||||||
elem.sublist.map(func.bind(that))
|
// XXX reuse doElem(..)
|
||||||
|
elem.sublist.map(function(e){
|
||||||
|
return func.call(that, e, path.concat(elem.id, e.id)) })
|
||||||
: elem.sublist.slice())
|
: elem.sublist.slice())
|
||||||
// normal item...
|
// normal item...
|
||||||
: doElem(elem) ) })
|
: doElem(elem) ) })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user