mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	some refining and cleanup...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e4897d5c31
								
							
						
					
					
						commit
						a62e144570
					
				| @ -1111,6 +1111,15 @@ module.FileSystemWriter = core.ImageGridFeatures.Feature({ | |||||||
| // 		- save as.. (browser)
 | // 		- save as.. (browser)
 | ||||||
| // 		- save if not base path present (browser)
 | // 		- save if not base path present (browser)
 | ||||||
| var FileSystemWriterUIActions = actions.Actions({ | var FileSystemWriterUIActions = actions.Actions({ | ||||||
|  | 	config: { | ||||||
|  | 		'export-dialog-mode': 'Directories', | ||||||
|  | 
 | ||||||
|  | 		'export-dialog-modes': { | ||||||
|  | 			'Images only': 'exportDirs', | ||||||
|  | 			'Full index': 'exportIndex', | ||||||
|  | 		}, | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
| 	// XXX this needs feedback...
 | 	// XXX this needs feedback...
 | ||||||
| 	// XXX should this return a promise???
 | 	// XXX should this return a promise???
 | ||||||
| 	saveIndexHere: ['File/Save', | 	saveIndexHere: ['File/Save', | ||||||
| @ -1151,12 +1160,24 @@ var FileSystemWriterUIActions = actions.Actions({ | |||||||
| 	// 		- dirs
 | 	// 		- dirs
 | ||||||
| 	// 		- ...
 | 	// 		- ...
 | ||||||
| 	// XXX indicate export state: index, crop, image...
 | 	// XXX indicate export state: index, crop, image...
 | ||||||
| 	exportDirsDialog: ['File/Export/Images...', | 	exportDialog: ['File/Export/Images...', | ||||||
| 		function(){ | 		function(){ | ||||||
| 			var that = this | 			var that = this | ||||||
| 
 | 
 | ||||||
| 			var o = overlay.Overlay(this.ribbons.viewer,  | 			var o = overlay.Overlay(this.ribbons.viewer,  | ||||||
| 				browse.makeLister(null, function(path, make){ | 				browse.makeLister(null, function(path, make){ | ||||||
|  | 					// XXX disable 'x' buttons...
 | ||||||
|  | 					make(['Export mode: ',  | ||||||
|  | 							function(){ return that.config['export-dialog-mode'] || 'Directories' }]) | ||||||
|  | 						.on('open',  | ||||||
|  | 							widgets.makeNestedConfigListEditor(that, o, | ||||||
|  | 								'export-dialog-modes', | ||||||
|  | 								'export-dialog-mode', | ||||||
|  | 								{ | ||||||
|  | 									new_button: false, | ||||||
|  | 									itemButtons: [], | ||||||
|  | 								})) | ||||||
|  | 
 | ||||||
| 					make(['Filename pattern: ',  | 					make(['Filename pattern: ',  | ||||||
| 							function(){ return that.config['export-preview-name-pattern'] || '%f' }]) | 							function(){ return that.config['export-preview-name-pattern'] || '%f' }]) | ||||||
| 						.on('open',  | 						.on('open',  | ||||||
| @ -1182,8 +1203,10 @@ var FileSystemWriterUIActions = actions.Actions({ | |||||||
| 					make(['To: ',  | 					make(['To: ',  | ||||||
| 						function(){ return that.config['export-path'] || './' }],  | 						function(){ return that.config['export-path'] || './' }],  | ||||||
| 						{ buttons: [ | 						{ buttons: [ | ||||||
| 							['browse', function(){ | 							['browse', function(p){ | ||||||
| 								var path = $(this).find('.text').last().text() | 								var e = this.filter('"'+p+'"', false) | ||||||
|  | 								var path = e.find('.text').last().text() | ||||||
|  | 								var txt = e.find('.text').first().text() | ||||||
| 
 | 
 | ||||||
| 								// XXX add new dir global button...
 | 								// XXX add new dir global button...
 | ||||||
| 								return that.browsePath(path,  | 								return that.browsePath(path,  | ||||||
| @ -1191,6 +1214,9 @@ var FileSystemWriterUIActions = actions.Actions({ | |||||||
| 										that.config['export-path'] = path | 										that.config['export-path'] = path | ||||||
| 										that.config['export-paths'].splice(0, 0, path) | 										that.config['export-paths'].splice(0, 0, path) | ||||||
| 
 | 
 | ||||||
|  | 										o.client.update() | ||||||
|  | 										o.client.select(txt) | ||||||
|  | 
 | ||||||
| 										// XXX ugly...
 | 										// XXX ugly...
 | ||||||
| 										o.focus() | 										o.focus() | ||||||
| 									}) | 									}) | ||||||
| @ -1199,7 +1225,11 @@ var FileSystemWriterUIActions = actions.Actions({ | |||||||
| 						.on('open',  | 						.on('open',  | ||||||
| 							widgets.makeNestedConfigListEditor(that, o, | 							widgets.makeNestedConfigListEditor(that, o, | ||||||
| 								'export-paths', | 								'export-paths', | ||||||
| 								'export-path')) | 								'export-path', | ||||||
|  | 								{ | ||||||
|  | 									// XXX add 'edit' button...
 | ||||||
|  | 									//itemButtons: []
 | ||||||
|  | 								})) | ||||||
| 
 | 
 | ||||||
| 					// Start/stop...
 | 					// Start/stop...
 | ||||||
| 					make([function(){ | 					make([function(){ | ||||||
| @ -1208,7 +1238,7 @@ var FileSystemWriterUIActions = actions.Actions({ | |||||||
| 						.on('open', function(){ | 						.on('open', function(){ | ||||||
| 							// XXX is this correct???
 | 							// XXX is this correct???
 | ||||||
| 							// XXX handle relative paths!!!
 | 							// XXX handle relative paths!!!
 | ||||||
| 							that.exportDirs(that.config['export-path'] || that.location.path) | 							that[that.config['export-mode']](that.config['export-path'] || that.location.path) | ||||||
| 							o.close() | 							o.close() | ||||||
| 						}) | 						}) | ||||||
| 				})) | 				})) | ||||||
|  | |||||||
| @ -53,6 +53,9 @@ var browseWalk = require('lib/widget/browse-walk') | |||||||
| // 		// this is called when a new value is added via new_button but 
 | // 		// this is called when a new value is added via new_button but 
 | ||||||
| // 		// list length limit is reached...
 | // 		// list length limit is reached...
 | ||||||
| // 		callback: function(selected){ ... },
 | // 		callback: function(selected){ ... },
 | ||||||
|  | //
 | ||||||
|  | // 		// see: itemButtons doc in browse.js for more info...
 | ||||||
|  | // 		itemButtons: [..]
 | ||||||
| // 	}
 | // 	}
 | ||||||
| //
 | //
 | ||||||
| // XXX add sort buttons: up/down/top/bottom...
 | // XXX add sort buttons: up/down/top/bottom...
 | ||||||
| @ -92,13 +95,18 @@ function(actions, list_key, options){ | |||||||
| 
 | 
 | ||||||
| 					// list length limit
 | 					// list length limit
 | ||||||
| 					if(options.length_limit  | 					if(options.length_limit  | ||||||
| 						&& (actions.config[list_key].length >= options.length_limit)){ | 						&& (lst.length >= options.length_limit)){ | ||||||
| 
 | 
 | ||||||
| 						options.callback && options.callback.call(list, txt) | 						options.callback && options.callback.call(list, txt) | ||||||
| 
 | 
 | ||||||
| 						return | 						return | ||||||
| 					} | 					} | ||||||
| 
 | 
 | ||||||
|  | 					// prevent editing non-arrays...
 | ||||||
|  | 					if(!(actions.config[list_key] instanceof Array)){ | ||||||
|  | 						return | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
| 					// save the new version...
 | 					// save the new version...
 | ||||||
| 					actions.config[list_key] = actions.config[list_key].slice() | 					actions.config[list_key] = actions.config[list_key].slice() | ||||||
| 					// add new value and sort list...
 | 					// add new value and sort list...
 | ||||||
| @ -134,9 +142,12 @@ function(actions, list_key, options){ | |||||||
| 
 | 
 | ||||||
| 	var to_remove = [] | 	var to_remove = [] | ||||||
| 
 | 
 | ||||||
|  | 	var lst = actions.config[list_key] | ||||||
|  | 	lst = lst instanceof Array ? lst : Object.keys(lst) | ||||||
|  | 
 | ||||||
| 	var list = browse.makeList( null,  | 	var list = browse.makeList( null,  | ||||||
| 		actions.config[list_key].concat(new_button ? [ new_button ] : []),  | 		lst.concat(new_button ? [ new_button ] : []),  | ||||||
| 		{itemButtons: [ | 		{itemButtons: options.itemButtons || [ | ||||||
| 			// mark for removal...
 | 			// mark for removal...
 | ||||||
| 			['×',  | 			['×',  | ||||||
| 				function(p){ | 				function(p){ | ||||||
| @ -174,6 +185,11 @@ function(actions, list_key, options){ | |||||||
| 
 | 
 | ||||||
| 	var o = overlay.Overlay(actions.ribbons.viewer, list) | 	var o = overlay.Overlay(actions.ribbons.viewer, list) | ||||||
| 		.close(function(){ | 		.close(function(){ | ||||||
|  | 			// prevent editing non-arrays...
 | ||||||
|  | 			if(!(actions.config[list_key] instanceof Array)){ | ||||||
|  | 				return | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
| 			// remove striked items...
 | 			// remove striked items...
 | ||||||
| 			to_remove.forEach(function(e){ | 			to_remove.forEach(function(e){ | ||||||
| 				var lst = actions.config[list_key].slice() | 				var lst = actions.config[list_key].slice() | ||||||
| @ -198,7 +214,7 @@ function(actions, list_key, options){ | |||||||
| // XXX should this be more generic...
 | // XXX should this be more generic...
 | ||||||
| var makeNestedConfigListEditor =  | var makeNestedConfigListEditor =  | ||||||
| module.makeNestedConfigListEditor = | module.makeNestedConfigListEditor = | ||||||
| function(actions, parent, list_name, value_name, options){ | function(actions, parent, list_key, value_key, options){ | ||||||
| 	return function(){ | 	return function(){ | ||||||
| 		var txt = $(this).find('.text').first().text() | 		var txt = $(this).find('.text').first().text() | ||||||
| 
 | 
 | ||||||
| @ -209,14 +225,14 @@ function(actions, parent, list_name, value_name, options){ | |||||||
| 			// NOTE: this is called when adding a new value and 
 | 			// NOTE: this is called when adding a new value and 
 | ||||||
| 			// 		list maximum length is reached...
 | 			// 		list maximum length is reached...
 | ||||||
| 			callback: function(value){ | 			callback: function(value){ | ||||||
| 				actions.config[value_name] = value | 				actions.config[value_key] = value | ||||||
| 
 | 
 | ||||||
| 				o.close() | 				o.close() | ||||||
| 			}, | 			}, | ||||||
| 		} | 		} | ||||||
| 		options.__proto__ = dfl_options | 		options.__proto__ = dfl_options | ||||||
| 
 | 
 | ||||||
| 		var o = makeConfigListEditor(actions, list_name, options)  | 		var o = makeConfigListEditor(actions, list_key, options)  | ||||||
| 
 | 
 | ||||||
| 		// update slideshow menu...
 | 		// update slideshow menu...
 | ||||||
| 		o.client.open(function(){ | 		o.client.open(function(){ | ||||||
| @ -229,7 +245,7 @@ function(actions, parent, list_name, value_name, options){ | |||||||
| 			parent.focus() | 			parent.focus() | ||||||
| 		}) | 		}) | ||||||
| 
 | 
 | ||||||
| 		o.client.select(actions.config[value_name]) | 		o.client.select(actions.config[value_key]) | ||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user