mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-11-03 04:40:10 +00:00 
			
		
		
		
	added tag sync + some experimental stuff...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									beb960ac3a
								
							
						
					
					
						commit
						1fe3301123
					
				@ -2324,7 +2324,7 @@ var DataWithTagsPrototype = {
 | 
			
		||||
	// 		-> data
 | 
			
		||||
	//
 | 
			
		||||
	// 	Reset image tags from data...
 | 
			
		||||
	// 	.tagsToImages(images, 'rest')
 | 
			
		||||
	// 	.tagsToImages(images, 'reset')
 | 
			
		||||
	// 		-> data
 | 
			
		||||
	//
 | 
			
		||||
	// XXX should this be here???
 | 
			
		||||
 | 
			
		||||
@ -205,6 +205,8 @@ $(function(){
 | 
			
		||||
			viewer: $('.viewer')
 | 
			
		||||
		})
 | 
			
		||||
 | 
			
		||||
	// used switch experimental actions on (set to true) or off (unset or false)...
 | 
			
		||||
	//a.experimental = true
 | 
			
		||||
 | 
			
		||||
	// XXX for some reason this is not visible when loading...
 | 
			
		||||
	a.setEmptyMsg('Loading...')
 | 
			
		||||
@ -234,6 +236,9 @@ $(function(){
 | 
			
		||||
 | 
			
		||||
		// experimental and optional features...
 | 
			
		||||
		//'auto-single-image',
 | 
			
		||||
 | 
			
		||||
		// XXX this is not for production...
 | 
			
		||||
		'experiments',
 | 
			
		||||
	])
 | 
			
		||||
	
 | 
			
		||||
	// this publishes all the actions...
 | 
			
		||||
@ -241,11 +246,17 @@ $(function(){
 | 
			
		||||
 | 
			
		||||
	// load some testing data...
 | 
			
		||||
	// NOTE: we can load this in parts...
 | 
			
		||||
	a.load({
 | 
			
		||||
	a
 | 
			
		||||
		.load({
 | 
			
		||||
			//viewer: $('.viewer'),
 | 
			
		||||
			data: data.Data(testing.mock_data),
 | 
			
		||||
			images: testing.makeTestImages(),
 | 
			
		||||
		})
 | 
			
		||||
		// this is needed when loading legacy sources that do not have tags
 | 
			
		||||
		// synced...
 | 
			
		||||
		// do not do for actual data...
 | 
			
		||||
		//.syncTags()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	a.setEmptyMsg(
 | 
			
		||||
 | 
			
		||||
@ -215,8 +215,7 @@ actions.Actions({
 | 
			
		||||
 | 
			
		||||
	// basic life-cycle actions...
 | 
			
		||||
	//
 | 
			
		||||
	// XXX sync tags between data and images...
 | 
			
		||||
	// 		...but which takes priority???
 | 
			
		||||
	// XXX do we need to call .syncTags(..) here???
 | 
			
		||||
	load: [
 | 
			
		||||
		function(d){
 | 
			
		||||
			this.images = images.Images(d.images)
 | 
			
		||||
@ -225,7 +224,7 @@ actions.Actions({
 | 
			
		||||
	clear: [
 | 
			
		||||
		function(){
 | 
			
		||||
			delete this.data
 | 
			
		||||
			delete this.Images
 | 
			
		||||
			delete this.images
 | 
			
		||||
		}],
 | 
			
		||||
 | 
			
		||||
	// XXX should this be here???
 | 
			
		||||
@ -543,6 +542,49 @@ actions.Actions({
 | 
			
		||||
				// XXX mark updated...
 | 
			
		||||
			})
 | 
			
		||||
		}],
 | 
			
		||||
	// Sync tags...
 | 
			
		||||
	//
 | 
			
		||||
	// 	Sync both ways...
 | 
			
		||||
	//	.syncTags()
 | 
			
		||||
	//	.syncTags('both')
 | 
			
		||||
	//
 | 
			
		||||
	//	Sync from .data
 | 
			
		||||
	//	.syncTags('data')
 | 
			
		||||
	//
 | 
			
		||||
	//	Sync from .images
 | 
			
		||||
	//	.syncTags('images')
 | 
			
		||||
	//
 | 
			
		||||
	//	Sync from <images> object
 | 
			
		||||
	//	.syncTags(<images>)
 | 
			
		||||
	//
 | 
			
		||||
	// NOTE: mode is data.tagsToImages(..) / data.tagsFromImages(..) 
 | 
			
		||||
	// 		compatible...
 | 
			
		||||
	// NOTE: setting source to 'both' and mode to 'reset' is the same as
 | 
			
		||||
	// 		'images' and 'reset' as all .data tags will be lost on first 
 | 
			
		||||
	// 		pass...
 | 
			
		||||
	syncTags: ['Synchoronize tags between data and images',
 | 
			
		||||
		function(source, mode){
 | 
			
		||||
			// can't do anything if either .data or .images are not 
 | 
			
		||||
			// defined...
 | 
			
		||||
			if(this.data == null || this.images == null){
 | 
			
		||||
				return
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			source = source || 'both'
 | 
			
		||||
			mode = mode || 'merge'
 | 
			
		||||
			images = this.images
 | 
			
		||||
			if(typeof(source) != typeof('str')){
 | 
			
		||||
				images = source
 | 
			
		||||
				source = 'images'
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			if(source == 'data' || source == 'both'){
 | 
			
		||||
				this.data.tagsToImages(images, mode)
 | 
			
		||||
			}
 | 
			
		||||
			if(source == 'images' || source == 'both'){
 | 
			
		||||
				this.data.tagsFromImages(images, mode)
 | 
			
		||||
			}
 | 
			
		||||
		}],
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// crop...
 | 
			
		||||
@ -2316,6 +2358,45 @@ module.FileSystemLoader = features.Feature(ImageGridFeatures, {
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
//---------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
var ExperimentActions = actions.Actions({
 | 
			
		||||
	/* trying an argument mutation method... (FAILED: arguments is mutable)
 | 
			
		||||
	argumentMutation: [
 | 
			
		||||
		function(a, b){
 | 
			
		||||
			console.log('ACTIONS ARGS:', a, b)
 | 
			
		||||
		}],
 | 
			
		||||
	*/
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
var ExperimentFeature = 
 | 
			
		||||
module.ExperimentFeature = features.Feature(ImageGridFeatures, {
 | 
			
		||||
	title: '',
 | 
			
		||||
	doc: '',
 | 
			
		||||
 | 
			
		||||
	tag: 'experiments',
 | 
			
		||||
 | 
			
		||||
	isApplicable: function(actions){
 | 
			
		||||
		return actions.experimental
 | 
			
		||||
	},
 | 
			
		||||
 | 
			
		||||
	actions: ExperimentActions,
 | 
			
		||||
 | 
			
		||||
	handlers: [
 | 
			
		||||
		/* trying an argument mutation method... (FAILED: arguments is mutable)
 | 
			
		||||
		['argumentMutation.pre', 
 | 
			
		||||
			function(a, b){
 | 
			
		||||
				console.log('EVENT ARGS:', a, b)
 | 
			
		||||
				arguments[0] += 1
 | 
			
		||||
				arguments[1] += 1
 | 
			
		||||
			}],
 | 
			
		||||
		*/
 | 
			
		||||
	],
 | 
			
		||||
})
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**********************************************************************
 | 
			
		||||
* vim:set ts=4 sw=4 :                                                */
 | 
			
		||||
return module })
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user