mirror of
https://github.com/flynx/ImageGrid.git
synced 2025-10-29 10:20:08 +00:00
cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
05a86cf36a
commit
afcdea9feb
@ -54,77 +54,6 @@ var toggler = require('lib/toggler')
|
|||||||
|
|
||||||
/*********************************************************************/
|
/*********************************************************************/
|
||||||
|
|
||||||
// Make a chained action...
|
|
||||||
//
|
|
||||||
// // basic chained action...
|
|
||||||
// basicAction: ['Group/Basic action',
|
|
||||||
// core.chain('working',
|
|
||||||
// // action...
|
|
||||||
// function(){
|
|
||||||
// ...
|
|
||||||
// })],
|
|
||||||
//
|
|
||||||
// // conditional chained action...
|
|
||||||
// conditionalAction: ['Group/Conditional action',
|
|
||||||
// core.chain('working',
|
|
||||||
// // action predicate...
|
|
||||||
// function(){
|
|
||||||
// return ...
|
|
||||||
// },
|
|
||||||
// // action...
|
|
||||||
// function(){
|
|
||||||
// ...
|
|
||||||
// })],
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// For more docs see: docs for actions.js and .chainApply(..)
|
|
||||||
//
|
|
||||||
// XXX might be good to move this to actions.js
|
|
||||||
// XXX might also be a good idea to mark the actual protocol definition
|
|
||||||
// and not just the implementation...
|
|
||||||
// XXX is this actually simpler?
|
|
||||||
// conditionalActionNew: ['Group/Conditional action',
|
|
||||||
// core.chain('working',
|
|
||||||
// function(){
|
|
||||||
// return this.condition == true
|
|
||||||
// },
|
|
||||||
// function(){
|
|
||||||
// ...
|
|
||||||
// })],
|
|
||||||
//
|
|
||||||
// conditionalActionOld: ['Group/Conditional action',
|
|
||||||
// function(){
|
|
||||||
// if(this.condition != true){
|
|
||||||
// return
|
|
||||||
// }
|
|
||||||
// this.working.chainApply(this, function(){
|
|
||||||
// ...
|
|
||||||
// })
|
|
||||||
// }],
|
|
||||||
//
|
|
||||||
// Advantages:
|
|
||||||
// - documentable/groupable automatically...
|
|
||||||
//
|
|
||||||
// Disadvantages:
|
|
||||||
// - extra entity/abstraction to remember...
|
|
||||||
// - covers only one simple case..
|
|
||||||
var chain =
|
|
||||||
module.chain = function(action, a, b){
|
|
||||||
if(arguments.length == 3){
|
|
||||||
var func = b
|
|
||||||
var cond = a
|
|
||||||
} else {
|
|
||||||
var func = a
|
|
||||||
var cond = true
|
|
||||||
}
|
|
||||||
return function(){
|
|
||||||
if(cond === true || cond.apply(this, arguments)){
|
|
||||||
return this[action].chainApply(this, func, arguments)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// NOTE: if no toggler state is set this assumes that the first state
|
// NOTE: if no toggler state is set this assumes that the first state
|
||||||
// is the default...
|
// is the default...
|
||||||
// NOTE: default states is [false, true]
|
// NOTE: default states is [false, true]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user