mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	refactoring...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									ebf92c5acf
								
							
						
					
					
						commit
						ec490e56e9
					
				| @ -80,7 +80,6 @@ function(attr, states, callback){ | ||||
| /*********************************************************************/ | ||||
| 
 | ||||
| // XXX split this into read and write actions...
 | ||||
| // XXX check if align by position is relevant here...
 | ||||
| var BaseActions =  | ||||
| module.BaseActions =  | ||||
| actions.Actions({ | ||||
| @ -239,12 +238,7 @@ actions.Actions({ | ||||
| 		function(mode){ | ||||
| 			var res = {} | ||||
| 			for(var k in this){ | ||||
| 				// dump the base crop state...
 | ||||
| 				if(k == 'data' && this.crop_stack && this.crop_stack.length > 0){ | ||||
| 					res[k] = this.crop_stack[0].dumpJSON() | ||||
| 
 | ||||
| 				// dump current state...
 | ||||
| 				} else if(this[k] != null && this[k].dumpJSON != null){ | ||||
| 				if(this[k] != null && this[k].dumpJSON != null){ | ||||
| 					res[k] = this[k].dumpJSON() | ||||
| 				} | ||||
| 			} | ||||
| @ -551,8 +545,25 @@ actions.Actions({ | ||||
| 		function(target){  | ||||
| 			this.images | ||||
| 				&& this.images.flipImage(this.data.getImage(target), 'horizontal') }], | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| var Base = | ||||
| module.Base = core.ImageGridFeatures.Feature({ | ||||
| 	title: 'ImageGrid base', | ||||
| 
 | ||||
| 	tag: 'base', | ||||
| 
 | ||||
| 	actions: BaseActions, | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| //---------------------------------------------------------------------
 | ||||
| // Tags...
 | ||||
| 
 | ||||
| var TagsActions =  | ||||
| module.TagsActions = actions.Actions({ | ||||
| 	// tags...
 | ||||
| 	//
 | ||||
| 	// XXX mark updated...
 | ||||
| @ -651,8 +662,68 @@ actions.Actions({ | ||||
| 				this.data.tagsFromImages(images, mode) | ||||
| 			} | ||||
| 		}], | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| var Tags = | ||||
| module.Tags = core.ImageGridFeatures.Feature({ | ||||
| 	title: '', | ||||
| 
 | ||||
| 	tag: 'tags', | ||||
| 	depends: [ | ||||
| 		'base', | ||||
| 	], | ||||
| 
 | ||||
| 	actions: TagsActions, | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| //---------------------------------------------------------------------
 | ||||
| // Crop...
 | ||||
| 
 | ||||
| var CropActions = | ||||
| module.CropActions = actions.Actions({ | ||||
| 
 | ||||
| 	crop_stack: null, | ||||
| 
 | ||||
| 	// load the crop stack if present...
 | ||||
| 	load: [function(data){ | ||||
| 		if(data.crop_stack){ | ||||
| 			this.crop_stack = data.crop_stack.map(function(j){ | ||||
| 				return data.Data(j) | ||||
| 			}) | ||||
| 		} | ||||
| 	}], | ||||
| 
 | ||||
| 	// store the root crop state instead of the current view...
 | ||||
| 	//
 | ||||
| 	// modes supported:
 | ||||
| 	// 	- current	- store the current state/view
 | ||||
| 	// 	- base		- store the base state/view
 | ||||
| 	// 	- full		- store the crop stack
 | ||||
| 	//
 | ||||
| 	// XXX might need to revise the mode approach...
 | ||||
| 	// XXX add support to loading the states...
 | ||||
| 	json: [function(mode){ | ||||
| 		mode = mode || 'current' | ||||
| 
 | ||||
| 		return function(res){ | ||||
| 			if(mode == 'base'  | ||||
| 					&& this.crop_stack  | ||||
| 					&& this.crop_stack.length > 0){ | ||||
| 				res.data = this.crop_stack[0].dumpJSON() | ||||
| 			} | ||||
| 			if(mode == 'full'  | ||||
| 					&& this.crop_stack  | ||||
| 					&& this.crop_stack.length > 0){ | ||||
| 				res.crop_stack = this.crop_stack.map(function(c){ | ||||
| 					return c.dumpJSON() | ||||
| 				}) | ||||
| 			} | ||||
| 		} | ||||
| 	}], | ||||
| 
 | ||||
| 	// crop...
 | ||||
| 	//
 | ||||
| 	crop: ['- Crop/Crop image list', | ||||
| @ -762,8 +833,28 @@ actions.Actions({ | ||||
| 			var selector = mode == 'any' ? 'getTaggedByAny' : 'getTaggedByAll' | ||||
| 			this.crop(this.data[selector](tags), flatten) | ||||
| 		}], | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| var Crop = | ||||
| module.Crop = core.ImageGridFeatures.Feature({ | ||||
| 	title: '', | ||||
| 
 | ||||
| 	tag: 'crop', | ||||
| 	depends: [ | ||||
| 		'base', | ||||
| 	], | ||||
| 
 | ||||
| 	actions: CropActions, | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| //---------------------------------------------------------------------
 | ||||
| // Image Group...
 | ||||
| 
 | ||||
| var ImageGroupActions = | ||||
| module.ImageGroupActions = actions.Actions({ | ||||
| 	// grouping...
 | ||||
| 	// XXX need to tell .images about this...
 | ||||
| 	group: ['- Group|Edit/Group images',  | ||||
| @ -813,17 +904,32 @@ actions.Actions({ | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| var Base = | ||||
| module.Base = core.ImageGridFeatures.Feature({ | ||||
| 	title: 'ImageGrid base', | ||||
| var ImageGroup = | ||||
| module.ImageGroup = core.ImageGridFeatures.Feature({ | ||||
| 	title: '', | ||||
| 
 | ||||
| 	tag: 'base', | ||||
| 	tag: 'image-group', | ||||
| 	depends: [ | ||||
| 		'base', | ||||
| 	], | ||||
| 
 | ||||
| 	actions: BaseActions, | ||||
| 	actions: ImageGroupActions, | ||||
| }) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| //---------------------------------------------------------------------
 | ||||
| // Meta base features...
 | ||||
| 
 | ||||
| // full features base...
 | ||||
| core.ImageGridFeatures.Feature('base-full', [ | ||||
| 	'base', | ||||
| 	'tags', | ||||
| 	'crop', | ||||
| 	'image-group', | ||||
| ]) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| /********************************************************************** | ||||
| * vim:set ts=4 sw=4 :                                                */ | ||||
|  | ||||
| @ -27,7 +27,7 @@ var core = require('features/core') | ||||
| 
 | ||||
| core.ImageGridFeatures.Feature('viewer-testing', [ | ||||
| 	'lifecycle', | ||||
| 	'base', | ||||
| 	'base-full', | ||||
| 	'ui', | ||||
| 
 | ||||
| 	// features...
 | ||||
|  | ||||
| @ -101,6 +101,7 @@ module.FeatureProto = { | ||||
| 
 | ||||
| 		// merge config...
 | ||||
| 		// XXX should this use inheritance???
 | ||||
| 		// XXX do we need to clone .config?
 | ||||
| 		if(this.config != null  | ||||
| 				|| (this.actions != null  | ||||
| 					&& this.actions.config != null)){ | ||||
| @ -110,12 +111,6 @@ module.FeatureProto = { | ||||
| 				actions.config = {} | ||||
| 			} | ||||
| 			Object.keys(config).forEach(function(n){ | ||||
| 				/* | ||||
| 				// keep existing keys...
 | ||||
| 				if(actions.config[n] === undefined){ | ||||
| 					actions.config[n] = config[n] | ||||
| 				} | ||||
| 				*/ | ||||
| 				// NOTE: this will overwrite existing values...
 | ||||
| 				actions.config[n] = config[n] | ||||
| 			}) | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user