mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	a bit more work on workspaces...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									35077407c1
								
							
						
					
					
						commit
						01797476e4
					
				| @ -213,12 +213,57 @@ module.LifeCycle = ImageGridFeatures.Feature({ | |||||||
| //
 | //
 | ||||||
| //
 | //
 | ||||||
| 
 | 
 | ||||||
|  | 
 | ||||||
|  | // Helpers...
 | ||||||
|  | var makeWorkspaceConfigWriter = | ||||||
|  | module.makeWorkspaceConfigWriter = function(keys, callback){ | ||||||
|  | 	return function(workspace){ | ||||||
|  | 		var that = this | ||||||
|  | 
 | ||||||
|  | 		keys = typeof(keys) == typeof(function(){}) ? keys() : keys | ||||||
|  | 
 | ||||||
|  | 		// store statusbar data...
 | ||||||
|  | 		keys.forEach(function(key){ | ||||||
|  | 			workspace[key] = JSON.parse(JSON.stringify(that.config[key])) | ||||||
|  | 		}) | ||||||
|  | 
 | ||||||
|  | 		callback && callback.call(this, workspace) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | // XXX should this delete a prop if it's not in the loading workspace???
 | ||||||
|  | var makeWorkspaceConfigLoader = | ||||||
|  | module.makeWorkspaceConfigLoader = function(keys, callback){ | ||||||
|  | 	return function(workspace){ | ||||||
|  | 		var that = this | ||||||
|  | 
 | ||||||
|  | 		keys = typeof(keys) == typeof(function(){}) ? keys() : keys | ||||||
|  | 
 | ||||||
|  | 		// load statusbar data...
 | ||||||
|  | 		keys.forEach(function(key){ | ||||||
|  | 			// the key exists...
 | ||||||
|  | 			if(key in workspace){ | ||||||
|  | 				that.config[key] = JSON.parse(JSON.stringify(workspace[key])) | ||||||
|  | 
 | ||||||
|  | 			// no key set...
 | ||||||
|  | 			// XXX is this the right way to go???
 | ||||||
|  | 			} else { | ||||||
|  | 				delete that.config[key] | ||||||
|  | 			} | ||||||
|  | 		}) | ||||||
|  | 
 | ||||||
|  | 		callback && callback.call(this, workspace) | ||||||
|  | 	} | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 | ||||||
|  | 
 | ||||||
| var WorkspaceActions = actions.Actions({ | var WorkspaceActions = actions.Actions({ | ||||||
| 	config: { | 	config: { | ||||||
| 		'workspace': 'default', | 		'workspace': 'default', | ||||||
| 		'chrome-visible': 'on', | 		'workspaces': {}, | ||||||
| 
 |  | ||||||
| 		'saved-workspaces': {}, |  | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	get workspace(){ | 	get workspace(){ | ||||||
| @ -228,6 +273,11 @@ var WorkspaceActions = actions.Actions({ | |||||||
| 		this.loadWorkspace(value) | 		this.loadWorkspace(value) | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
|  | 	get workspaces(){ | ||||||
|  | 		return this.config.workspaces | ||||||
|  | 	}, | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 	getWorkspace: ['- Workspace/', | 	getWorkspace: ['- Workspace/', | ||||||
| 		function(){ return this.saveWorkspace(null) }], | 		function(){ return this.saveWorkspace(null) }], | ||||||
| 
 | 
 | ||||||
| @ -242,12 +292,12 @@ var WorkspaceActions = actions.Actions({ | |||||||
| 	// XXX for some reason this does not trigger a .config save...
 | 	// XXX for some reason this does not trigger a .config save...
 | ||||||
| 	saveWorkspace: ['Workspace/Save Workspace', | 	saveWorkspace: ['Workspace/Save Workspace', | ||||||
| 		function(name){ | 		function(name){ | ||||||
| 			this.config['saved-workspaces'] = this.config['saved-workspaces'] | 			this.config['workspaces'] = this.config['workspaces'] | ||||||
| 
 | 
 | ||||||
| 			var res = {} | 			var res = {} | ||||||
| 
 | 
 | ||||||
| 			if(name !== null){ | 			if(name !== null){ | ||||||
| 				this.config['saved-workspaces'][name || this.config.workspace] = res | 				this.config['workspaces'][name || this.config.workspace] = res | ||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			return res | 			return res | ||||||
| @ -257,14 +307,21 @@ var WorkspaceActions = actions.Actions({ | |||||||
| 	// 		specific way to do stuff...
 | 	// 		specific way to do stuff...
 | ||||||
| 	loadWorkspace: ['Workspace/Load Workspace', | 	loadWorkspace: ['Workspace/Load Workspace', | ||||||
| 		function(name){ | 		function(name){ | ||||||
|  | 			// get a workspace by name and load it...
 | ||||||
|  | 			if(typeof(name) == typeof('str')){ | ||||||
| 				this.config.workspace = name | 				this.config.workspace = name | ||||||
| 
 | 
 | ||||||
| 			return this.config['saved-workspaces'][name] || {} | 				return this.config['workspaces'][name || this.config.workspace] || {} | ||||||
|  | 
 | ||||||
|  | 			// we got the workspace object...
 | ||||||
|  | 			} else { | ||||||
|  | 				return name | ||||||
|  | 			} | ||||||
| 		}], | 		}], | ||||||
| 
 | 
 | ||||||
| 	toggleWorkspace: ['Workspace/Toggle Workspace', | 	toggleWorkspace: ['Workspace/Toggle Workspace', | ||||||
| 		makeConfigToggler('workspace', | 		makeConfigToggler('workspace', | ||||||
| 			function(){ return Object.keys(this.config['saved-workspaces']) }, | 			function(){ return Object.keys(this.config['workspaces']) }, | ||||||
| 			function(state){ this.loadWorkspace(state) })], | 			function(state){ this.loadWorkspace(state) })], | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -71,7 +71,8 @@ var SlideshowActions = actions.Actions({ | |||||||
| 		core.makeConfigToggler('ui-slideshow-direction', ['forward', 'reverse'])], | 		core.makeConfigToggler('ui-slideshow-direction', ['forward', 'reverse'])], | ||||||
| 	toggleSlideshowLooping: ['Slideshow/Looping', | 	toggleSlideshowLooping: ['Slideshow/Looping', | ||||||
| 		core.makeConfigToggler('ui-slideshow-looping', ['on', 'off'])], | 		core.makeConfigToggler('ui-slideshow-looping', ['on', 'off'])], | ||||||
| 	// XXX need to save/load state...
 | 
 | ||||||
|  | 	// XXX should this save/load a tmp workspace or a dedicated slideshow workspace???
 | ||||||
| 	toggleSlideshow: ['Slideshow/Start', | 	toggleSlideshow: ['Slideshow/Start', | ||||||
| 		toggler.CSSClassToggler( | 		toggler.CSSClassToggler( | ||||||
| 			function(){ return this.ribbons.viewer },  | 			function(){ return this.ribbons.viewer },  | ||||||
| @ -90,14 +91,22 @@ var SlideshowActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 					// prepare for the slideshow...
 | 					// prepare for the slideshow...
 | ||||||
| 					} else { | 					} else { | ||||||
| 						// XXX get state before setting/hiding things...
 | 						// save current workspace...
 | ||||||
| 						// XXX
 | 						this.__pre_slideshow_workspace = this.workspace | ||||||
|  | 						this.saveWorkspace()  | ||||||
|  | 
 | ||||||
|  | 						// construct the slideshow workspace if it does not exist...
 | ||||||
|  | 						if(this.workspaces['slideshow'] == null){ | ||||||
|  | 							this.toggleChrome('off') | ||||||
|  | 							this.saveWorkspace('slideshow')  | ||||||
|  | 
 | ||||||
|  | 						// load the slideshow workspace...
 | ||||||
|  | 						} else { | ||||||
|  | 							this.loadWorkspace('slideshow') | ||||||
|  | 						} | ||||||
| 				 | 				 | ||||||
| 						// single image mode...
 | 						// single image mode...
 | ||||||
| 						this.toggleSingleImage('on') | 						this.toggleSingleImage('on') | ||||||
| 
 |  | ||||||
| 						// XXX hide all marks...
 |  | ||||||
| 						// XXX
 |  | ||||||
| 					} | 					} | ||||||
| 
 | 
 | ||||||
| 					// start the timer... 
 | 					// start the timer... 
 | ||||||
| @ -122,12 +131,14 @@ var SlideshowActions = actions.Actions({ | |||||||
| 				// stop...
 | 				// stop...
 | ||||||
| 				} else { | 				} else { | ||||||
| 					// stop timer...
 | 					// stop timer...
 | ||||||
| 					clearTimeout(this.__slideshouw_timer) | 					this.__slideshouw_timer | ||||||
|  | 						&& clearTimeout(this.__slideshouw_timer) | ||||||
| 					delete this.__slideshouw_timer | 					delete this.__slideshouw_timer | ||||||
| 
 | 
 | ||||||
| 					// XXX restore state...
 | 					// XXX should this be a dedicated slideshow workspace??
 | ||||||
| 					// XXX
 | 					this.__pre_slideshow_workspace && | ||||||
| 
 | 						this.loadWorkspace(this.__pre_slideshow_workspace) | ||||||
|  | 					delete this.__pre_slideshow_workspace | ||||||
| 				} | 				} | ||||||
| 			})], | 			})], | ||||||
| 	resetSlideshowTimer: ['- Slideshow/Restart slideshow timer', | 	resetSlideshowTimer: ['- Slideshow/Restart slideshow timer', | ||||||
| @ -144,11 +155,17 @@ module.Slideshow = core.ImageGridFeatures.Feature({ | |||||||
| 
 | 
 | ||||||
| 	tag: 'ui-slideshow', | 	tag: 'ui-slideshow', | ||||||
| 	depends: [ | 	depends: [ | ||||||
|  | 		'workspace', | ||||||
| 		'ui', | 		'ui', | ||||||
| 		'ui-single-image-view', | 		'ui-single-image-view', | ||||||
| 	], | 	], | ||||||
| 
 | 
 | ||||||
| 	actions: SlideshowActions, | 	actions: SlideshowActions, | ||||||
|  | 
 | ||||||
|  | 	handlers: [ | ||||||
|  | 		['stop', | ||||||
|  | 			function(){ this.toggleSlideshow('off') }] | ||||||
|  | 	], | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -419,6 +419,7 @@ module.StatusBar = core.ImageGridFeatures.Feature({ | |||||||
| 
 | 
 | ||||||
| 	tag: 'ui-status-bar', | 	tag: 'ui-status-bar', | ||||||
| 	depends: [ | 	depends: [ | ||||||
|  | 		'workspace', | ||||||
| 		'ui', | 		'ui', | ||||||
| 
 | 
 | ||||||
| 		// XXX this is here to enable context menu 
 | 		// XXX this is here to enable context menu 
 | ||||||
| @ -450,6 +451,19 @@ module.StatusBar = core.ImageGridFeatures.Feature({ | |||||||
| 					this.updateStatusBar() | 					this.updateStatusBar() | ||||||
| 				} | 				} | ||||||
| 			}], | 			}], | ||||||
|  | 
 | ||||||
|  | 		// Workspace...
 | ||||||
|  | 		// XXX is storing all the config a bit too much???
 | ||||||
|  | 		['saveWorkspace', | ||||||
|  | 			core.makeWorkspaceConfigWriter( | ||||||
|  | 				function(){ return Object.keys(StatusBar.config) })], | ||||||
|  | 		['loadWorkspace', | ||||||
|  | 			core.makeWorkspaceConfigLoader( | ||||||
|  | 				function(){ return Object.keys(StatusBar.config) }, | ||||||
|  | 				function(workspace){ | ||||||
|  | 					'status-bar-mode' in workspace  | ||||||
|  | 						&& this.toggleStatusBar(workspace['status-bar-mode']) | ||||||
|  | 				})], | ||||||
| 	], | 	], | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -162,6 +162,9 @@ module.ViewerActions = actions.Actions({ | |||||||
| 			'last',		// select last image
 | 			'last',		// select last image
 | ||||||
| 		], | 		], | ||||||
| 		'ribbon-focus-mode': 'visual', | 		'ribbon-focus-mode': 'visual', | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		'chrome-visible': 'on', | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	// Images...
 | 	// Images...
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user