mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 18:30:09 +00:00
fixed an issue with makeItemEventMethod(..)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
94e2537891
commit
fd078cbac0
@ -198,7 +198,6 @@ Items.ListTitle = function(){}
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// XXX should this be simply a shorthand to .trigger(..) ???
|
// XXX should this be simply a shorthand to .trigger(..) ???
|
||||||
// XXX ASAP: should call the handlers with actual items and not the arguments...
|
|
||||||
var makeEventMethod = function(event, handler){
|
var makeEventMethod = function(event, handler){
|
||||||
return function(item){
|
return function(item){
|
||||||
// register handler...
|
// register handler...
|
||||||
@ -237,26 +236,34 @@ var callItemEventHandlers = function(item, event, ...args){
|
|||||||
handler.call(item, evt, item, ...args) }) }
|
handler.call(item, evt, item, ...args) }) }
|
||||||
|
|
||||||
var makeItemEventMethod = function(event, handler, options){
|
var makeItemEventMethod = function(event, handler, options){
|
||||||
return makeEventMethod(event, function(evt, item, ...args){
|
// NOTE: this is not returned directly as we need to query the items
|
||||||
|
// and pass those on to the handlers rather than the arguments
|
||||||
|
// as-is...
|
||||||
|
var method = makeEventMethod(event,
|
||||||
|
function(evt, item, ...args){
|
||||||
|
handler
|
||||||
|
&& handler.call(this, evt, item, ...args)
|
||||||
|
item.forEach(function(item){
|
||||||
|
callItemEventHandlers(item, event) })
|
||||||
|
})
|
||||||
|
return function(item, ...args){
|
||||||
var that = this
|
var that = this
|
||||||
|
return method.call(this,
|
||||||
item =
|
// event handler...
|
||||||
item instanceof Array ?
|
item instanceof Function ?
|
||||||
|
item
|
||||||
|
// array of queries...
|
||||||
|
: item instanceof Array ?
|
||||||
item
|
item
|
||||||
.map(function(e){
|
.map(function(e){
|
||||||
return that.search(e, options) })
|
return that.search(e, options) })
|
||||||
.flat()
|
.flat()
|
||||||
.unique()
|
.unique()
|
||||||
|
// query...
|
||||||
: item != null ?
|
: item != null ?
|
||||||
this.search(item, options)
|
this.search(item, options)
|
||||||
: []
|
: [],
|
||||||
|
...args) } }
|
||||||
handler
|
|
||||||
&& handler.call(this, evt, item, ...args)
|
|
||||||
|
|
||||||
item.forEach(function(item){
|
|
||||||
callItemEventHandlers(item, event) })
|
|
||||||
}) }
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user