mirror of
				https://github.com/flynx/actions.js.git
				synced 2025-10-31 11:20:10 +00:00 
			
		
		
		
	action aliases done (testing)...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									7b900cf6c6
								
							
						
					
					
						commit
						56cc7afeb9
					
				
							
								
								
									
										48
									
								
								actions.js
									
									
									
									
									
								
							
							
						
						
									
										48
									
								
								actions.js
									
									
									
									
									
								
							| @ -286,6 +286,39 @@ function(func){ | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| // XXX this is the same as ImageGrid's keyboard.parseActionCall(..), reuse	
 | ||||
| // 		in a logical manner...
 | ||||
| var parseStringAction = | ||||
| module.parseStringAction = | ||||
| function(txt){ | ||||
| 	// split off the doc...
 | ||||
| 	var c = txt.split('--') | ||||
| 	var doc = (c[1] || '').trim() | ||||
| 	// the actual code...
 | ||||
| 	c = c[0].split(':') | ||||
| 
 | ||||
| 	// action and no default flag...
 | ||||
| 	var action = c[0].trim() | ||||
| 	var no_default = action.slice(-1) == '!' | ||||
| 	action = no_default ? action.slice(0, -1) : action | ||||
| 
 | ||||
| 	// parse arguments...
 | ||||
| 	var args = JSON.parse('['+( | ||||
| 		((c[1] || '') | ||||
| 			.match(/"[^"]*"|'[^']*'|\{[^\}]*\}|\[[^\]]*\]|\d+|\d+\.\d*|null/gm)  | ||||
| 		|| []) | ||||
| 		.join(','))+']') | ||||
| 
 | ||||
| 	return { | ||||
| 		action: action, | ||||
| 		arguments: args, | ||||
| 		doc: doc, | ||||
| 		no_default: no_default, | ||||
| 		stop_propagation: false, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| 
 | ||||
| @ -595,6 +628,8 @@ Action.prototype.chainCall = function(context, inner){ | ||||
| //---------------------------------------------------------------------
 | ||||
| 
 | ||||
| // XXX handle alias args and pass them to the target...
 | ||||
| // XXX who's parsing and what syntax???
 | ||||
| // 		- args syntax???
 | ||||
| var Alias = | ||||
| module.Alias = | ||||
| function Alias(alias, target){ | ||||
| @ -606,17 +641,19 @@ function Alias(alias, target){ | ||||
| 		return new Alias(alias, target) | ||||
| 	} | ||||
| 
 | ||||
| 	// parse the target...
 | ||||
| 	var action = this.parseStringAction(target) | ||||
| 
 | ||||
| 	var meth = Action(alias, doc, null,  | ||||
| 		{ alias: target },  | ||||
| 		function(){ | ||||
| 			// XXX parse the target...
 | ||||
| 			// XXX
 | ||||
| 			var args = action.arguments.slice() | ||||
| 
 | ||||
| 			// XXX merge args...
 | ||||
| 			// XXX
 | ||||
| 
 | ||||
| 			// XXX call the alias...
 | ||||
| 			// XXX
 | ||||
| 			// call the alias...
 | ||||
| 			return this[action.action].apply(this, args) | ||||
| 		}) | ||||
| 	meth.__proto__ = this.__proto__ | ||||
| 
 | ||||
| @ -672,6 +709,9 @@ module.MetaActions = { | ||||
| 		return this.actions | ||||
| 			.filter(function(n){ return that[name] instanceof Alias }) }, | ||||
| 
 | ||||
| 	// XXX move this to the right spot...
 | ||||
| 	parseStringAction: parseStringAction, | ||||
| 
 | ||||
| 
 | ||||
| 	// Get action attribute...
 | ||||
| 	//
 | ||||
|  | ||||
| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "ig-actions", | ||||
|   "version": "3.2.5", | ||||
|   "version": "3.3.0", | ||||
|   "description": "", | ||||
|   "main": "actions.js", | ||||
|   "scripts": { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user