mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	added 'live' state options for toggle actions, essentially built automatic setup mechanics, still not sure if this is not an overkill...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									05e0a7d1b7
								
							
						
					
					
						commit
						f94c14ca13
					
				| @ -22,8 +22,11 @@ var ImageGrid = { | |||||||
| 	// 		call	- callable
 | 	// 		call	- callable
 | ||||||
| 	// XXX revise...
 | 	// XXX revise...
 | ||||||
| 	ACTION: function(obj){ | 	ACTION: function(obj){ | ||||||
| 		var call = obj.call |  | ||||||
| 		// add all the attrs to the function...
 | 		// add all the attrs to the function...
 | ||||||
|  | 		if(this._type_handler[obj.type] != null){ | ||||||
|  | 			this._type_handler[obj.type](obj) | ||||||
|  | 		} | ||||||
|  | 		var call = obj.call | ||||||
| 		for(i in obj){ | 		for(i in obj){ | ||||||
| 			if(i == 'doc' && call.doc != null){ | 			if(i == 'doc' && call.doc != null){ | ||||||
| 				call.func_doc = call.doc  | 				call.func_doc = call.doc  | ||||||
| @ -31,9 +34,6 @@ var ImageGrid = { | |||||||
| 			call[i] = obj[i] | 			call[i] = obj[i] | ||||||
| 		} | 		} | ||||||
| 		this[obj.title] = call | 		this[obj.title] = call | ||||||
| 		if(this._type_handler[obj.type] != null){ |  | ||||||
| 			this._type_handler[obj.type](obj) |  | ||||||
| 		} |  | ||||||
| 		return call | 		return call | ||||||
| 	}, | 	}, | ||||||
| 	// define an option...
 | 	// define an option...
 | ||||||
| @ -41,20 +41,10 @@ var ImageGrid = { | |||||||
| 		this.option[obj.name] = obj.value | 		this.option[obj.name] = obj.value | ||||||
| 		this.option_props[obj.name] = obj | 		this.option_props[obj.name] = obj | ||||||
| 	}, | 	}, | ||||||
| 	_type_handler: { | 	TYPE: function(name, handler){ | ||||||
| 		/* XXX also need to make the action change the option... | 		this._type_handler[name] = handler | ||||||
| 		toggle: function(obj){ |  | ||||||
| 			// XXX add an option to store the state...
 |  | ||||||
| 			ImageGrid.OPTION({ |  | ||||||
| 				name: obj.title, |  | ||||||
| 				doc: 'Stores the state of '+obj.title+' action.', |  | ||||||
| 				value: ImageGrid[obj.title]('?'), |  | ||||||
| 				callback: function(){ |  | ||||||
| 					ImageGrid[obj.title](ImageGrid.option[obj.title]) |  | ||||||
| 				} |  | ||||||
| 			}) |  | ||||||
| 	}, | 	}, | ||||||
| 		*/ | 	_type_handler: { | ||||||
| 	}, | 	}, | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -66,9 +56,10 @@ ImageGrid.ACTION({ | |||||||
| 		for(var n in obj){ | 		for(var n in obj){ | ||||||
| 			this.option[n] = obj[n] | 			this.option[n] = obj[n] | ||||||
| 		} | 		} | ||||||
| 		// NOTE: this seporate so as to remove the posibility of race 
 | 		// NOTE: this is separate so as to exclude the posibility of race 
 | ||||||
| 		// 		 conditions...
 | 		// 		 conditions...
 | ||||||
| 		// 		 ...thogh there is still a posibility of conflicting modes
 | 		// 		 ...thogh there is still a posibility of conflicting 
 | ||||||
|  | 		// 		 modes, especially if one mode sets more modes...
 | ||||||
| 		for(var n in obj){ | 		for(var n in obj){ | ||||||
| 			// call the callback if it exists...
 | 			// call the callback if it exists...
 | ||||||
| 			if(this.option_props[n].callback != null){ | 			if(this.option_props[n].callback != null){ | ||||||
| @ -89,6 +80,24 @@ ImageGrid.ACTION({ | |||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| }) | }) | ||||||
|  | ImageGrid.TYPE('toggle', function(obj){ | ||||||
|  | 	var call = obj.call | ||||||
|  | 	// wrap the call to set the option...
 | ||||||
|  | 	obj.call = function(action){ | ||||||
|  | 		var res = call(action) | ||||||
|  | 		ImageGrid.option[obj.title] = call('?') | ||||||
|  | 		return res | ||||||
|  | 	} | ||||||
|  | 	// add an option to store the state...
 | ||||||
|  | 	ImageGrid.OPTION({ | ||||||
|  | 		name: obj.title, | ||||||
|  | 		doc: 'Stores the state of '+obj.title+' action.', | ||||||
|  | 		value: obj.call('?'), | ||||||
|  | 		callback: function(){ | ||||||
|  | 			ImageGrid[obj.title](ImageGrid.option[obj.title]) | ||||||
|  | 		} | ||||||
|  | 	}) | ||||||
|  | }) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user