mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-30 10:50:08 +00:00
added compatibility for node.js events in actions...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
5c8de52214
commit
d29903f024
@ -9,6 +9,16 @@ console.log('>>> actions')
|
|||||||
|
|
||||||
//var DEBUG = DEBUG != null ? DEBUG : true
|
//var DEBUG = DEBUG != null ? DEBUG : true
|
||||||
|
|
||||||
|
// can be:
|
||||||
|
// 'jQuery'
|
||||||
|
// 'node'
|
||||||
|
//
|
||||||
|
var EVT_MODE =
|
||||||
|
module.EVT_MODE =
|
||||||
|
typeof(window) != null && window.jQuery ? 'jQuery'
|
||||||
|
: typeof(global) != null && global.jQuery ? 'jQuery'
|
||||||
|
: 'node'
|
||||||
|
|
||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
//
|
//
|
||||||
@ -26,14 +36,27 @@ console.log('>>> actions')
|
|||||||
//
|
//
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
|
var fireEvent =
|
||||||
|
module.fireEvent =
|
||||||
|
function(context, name, args){
|
||||||
|
if(EVT_MODE == 'jQuery'){
|
||||||
|
var c = $(context)
|
||||||
|
.trigger(name, args)
|
||||||
|
} else {
|
||||||
|
var c = context
|
||||||
|
.emit.apply(context, [name].concat(args))
|
||||||
|
}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// NOTE: context is dynamic.
|
// NOTE: context is dynamic.
|
||||||
var Action =
|
var Action =
|
||||||
module.Action =
|
module.Action =
|
||||||
function Action(context, name, doc, code){
|
function Action(context, name, doc, code){
|
||||||
var action = function(){
|
var action = function(){
|
||||||
var args = args2array(arguments)
|
var args = args2array(arguments)
|
||||||
var c = $(context)
|
var c = fireEvent(context, name + '.pre', args)
|
||||||
.trigger(name + '.pre', args)
|
|
||||||
|
|
||||||
// run compound action content...
|
// run compound action content...
|
||||||
if(code != null){
|
if(code != null){
|
||||||
@ -51,9 +74,9 @@ function Action(context, name, doc, code){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fireEvent(c, name, args)
|
||||||
|
fireEvent(c, name + '.post', args)
|
||||||
return c
|
return c
|
||||||
.trigger(name, args)
|
|
||||||
.trigger(name + '.post', args)
|
|
||||||
}
|
}
|
||||||
action.doc = doc == null ? name : doc
|
action.doc = doc == null ? name : doc
|
||||||
return action
|
return action
|
||||||
|
|||||||
@ -190,7 +190,7 @@ module.ImagesPrototype = {
|
|||||||
},
|
},
|
||||||
// XXX
|
// XXX
|
||||||
sortedImagesByFileNameSeqWithOverflow: function(gids, reverse){
|
sortedImagesByFileNameSeqWithOverflow: function(gids, reverse){
|
||||||
// XXX see ui/sort.js
|
// XXX see ../ui/sort.js
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user