now actions.on(..) support event arrays...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2014-10-25 12:01:08 +04:00
parent 6c9c0c779b
commit ac03e40193

View File

@ -363,8 +363,10 @@ module.MetaActions = {
var handler = typeof(c) == 'function' ? c : b var handler = typeof(c) == 'function' ? c : b
var tag = typeof(c) == 'function' ? b : c var tag = typeof(c) == 'function' ? b : c
actions = typeof(actions) == 'string' ? actions.split(' ') : actions
var that = this var that = this
actions.split(' ').forEach(function(action){ actions.forEach(function(action){
// prepare the handler... // prepare the handler...
var mode = action.split('.') var mode = action.split('.')
action = mode[0] action = mode[0]
@ -406,13 +408,13 @@ module.MetaActions = {
// Remove an action callback... // Remove an action callback...
// //
// XXX needs more testing... // XXX needs more testing...
off: function(action, handler){ off: function(actions, handler){
if(this.hasOwnProperty('_action_handlers')){ if(this.hasOwnProperty('_action_handlers')){
if(action == '*'){
var actions = Object.keys(this._action_handlers) actions = actions == '*' ? Object.keys(this._action_handlers)
} else { : typeof(actions) == 'string' ? action.split(' ')
var actions = action.split(' ') : actions
}
var that = this var that = this
actions.forEach(function(action){ actions.forEach(function(action){
var mode = action.split('.') var mode = action.split('.')
@ -455,6 +457,16 @@ module.MetaActions = {
} }
return this return this
}, },
// NOTE: if 'all' is set them mixin all the actions available,
// otherwise only mixin local actions...
mixin: function(from, all){
// XXX link actions from 'from' into this...
},
mixinto: function(to, all){
return this.mixin.call(to, this, all)
},
} }