mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	added more control and persistance to status bar index...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									d32de4b81c
								
							
						
					
					
						commit
						b25c4093f5
					
				| @ -20,6 +20,14 @@ var overlay = require('lib/widget/overlay') | |||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | /*********************************************************************/ | ||||||
|  | 
 | ||||||
|  | var _cmpTimes = function(a, b){ | ||||||
|  | 	return Date.str2ms(a) - Date.str2ms(b) | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| /*********************************************************************/ | /*********************************************************************/ | ||||||
| 
 | 
 | ||||||
| // XXX would be a good idea to add provision for a timer to indicate 
 | // XXX would be a good idea to add provision for a timer to indicate 
 | ||||||
| @ -65,6 +73,7 @@ var SlideshowActions = actions.Actions({ | |||||||
| 				browse.makeList( | 				browse.makeList( | ||||||
| 					null, | 					null, | ||||||
| 					[ | 					[ | ||||||
|  | 						// XXX make this editable...
 | ||||||
| 						['Interval: ',  | 						['Interval: ',  | ||||||
| 							function(){ return that.config['slideshow-interval'] }], | 							function(){ return that.config['slideshow-interval'] }], | ||||||
| 						['Direction: ',  | 						['Direction: ',  | ||||||
| @ -90,7 +99,12 @@ var SlideshowActions = actions.Actions({ | |||||||
| 							var to_remove = [] | 							var to_remove = [] | ||||||
| 							var oo = overlay.Overlay(that.ribbons.viewer,  | 							var oo = overlay.Overlay(that.ribbons.viewer,  | ||||||
| 								browse.makeList( null,  | 								browse.makeList( null,  | ||||||
| 									that.config['slideshow-intervals'],  | 									that.config['slideshow-intervals'] | ||||||
|  | 										.concat([ | ||||||
|  | 											// XXX do we add a new item here???
 | ||||||
|  | 											//'---', 
 | ||||||
|  | 											//'New'
 | ||||||
|  | 										]),  | ||||||
| 									{itemButtons: [ | 									{itemButtons: [ | ||||||
| 										// mark for removal...
 | 										// mark for removal...
 | ||||||
| 										['×',  | 										['×',  | ||||||
| @ -111,12 +125,18 @@ var SlideshowActions = actions.Actions({ | |||||||
| 											}], | 											}], | ||||||
| 									]}) | 									]}) | ||||||
| 									.open(function(evt, time){ | 									.open(function(evt, time){ | ||||||
| 										that.config['slideshow-interval'] = time | 										if(/new/i.test(time)){ | ||||||
|  | 											// XXX edit...
 | ||||||
|  | 											// XXX
 | ||||||
| 
 | 
 | ||||||
| 										// XXX this is ugly...
 | 										} else { | ||||||
| 										oo.close() | 											that.config['slideshow-interval'] = time | ||||||
| 										o.client.update() | 
 | ||||||
| 										o.client.select(path.split(':')[0]) | 											// XXX this is ugly...
 | ||||||
|  | 											oo.close() | ||||||
|  | 											o.client.update() | ||||||
|  | 											o.client.select(path.split(':')[0]) | ||||||
|  | 										} | ||||||
| 									})) | 									})) | ||||||
| 								.close(function(){ | 								.close(function(){ | ||||||
| 									// remove striked items...
 | 									// remove striked items...
 | ||||||
| @ -127,6 +147,17 @@ var SlideshowActions = actions.Actions({ | |||||||
| 										that.config['slideshow-intervals'] = lst | 										that.config['slideshow-intervals'] = lst | ||||||
| 									}) | 									}) | ||||||
| 
 | 
 | ||||||
|  | 									// XXX add new items...
 | ||||||
|  | 									// XXX
 | ||||||
|  | 
 | ||||||
|  | 									// sort the times...
 | ||||||
|  | 									that.config['slideshow-intervals'] = | ||||||
|  | 										that.config['slideshow-intervals'] | ||||||
|  | 											.sort(function(a, b){ | ||||||
|  | 												return Date.str2ms(a) - Date.str2ms(b) | ||||||
|  | 											}) | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 									// XXX this is ugly...
 | 									// XXX this is ugly...
 | ||||||
| 									o.focus() | 									o.focus() | ||||||
| 
 | 
 | ||||||
| @ -282,7 +313,6 @@ module.Slideshow = core.ImageGridFeatures.Feature({ | |||||||
| 
 | 
 | ||||||
| 	tag: 'ui-slideshow', | 	tag: 'ui-slideshow', | ||||||
| 	depends: [ | 	depends: [ | ||||||
| 		'workspace', |  | ||||||
| 		'ui', | 		'ui', | ||||||
| 		'ui-single-image-view', | 		'ui-single-image-view', | ||||||
| 	], | 	], | ||||||
|  | |||||||
| @ -45,7 +45,6 @@ var makeStateIndicatorItem = function(container, type, text){ | |||||||
| // XXX revise how/where info is displayed...
 | // XXX revise how/where info is displayed...
 | ||||||
| var StatusBarActions = actions.Actions({ | var StatusBarActions = actions.Actions({ | ||||||
| 	config: { | 	config: { | ||||||
| 		// XXX for some reason this does not load as default...
 |  | ||||||
| 		'status-bar-mode': 'minimal', | 		'status-bar-mode': 'minimal', | ||||||
| 		'status-bar-modes': [ | 		'status-bar-modes': [ | ||||||
| 			'none', | 			'none', | ||||||
| @ -71,6 +70,8 @@ var StatusBarActions = actions.Actions({ | |||||||
| 		], | 		], | ||||||
| 
 | 
 | ||||||
| 		'status-bar-index': { | 		'status-bar-index': { | ||||||
|  | 			'mode': 'normal', | ||||||
|  | 
 | ||||||
| 			// NOTE: this would need to reconstruct the status bar for 
 | 			// NOTE: this would need to reconstruct the status bar for 
 | ||||||
| 			// 		changes to take effect, i.e. call .resetStatusBar()
 | 			// 		changes to take effect, i.e. call .resetStatusBar()
 | ||||||
| 			// XXX might be a good idea to run an editor on click on
 | 			// XXX might be a good idea to run an editor on click on
 | ||||||
| @ -79,6 +80,7 @@ var StatusBarActions = actions.Actions({ | |||||||
| 
 | 
 | ||||||
| 			'live-update-on-edit': false, | 			'live-update-on-edit': false, | ||||||
| 		}, | 		}, | ||||||
|  | 
 | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	__statusbar_elements__: { | 	__statusbar_elements__: { | ||||||
| @ -98,8 +100,7 @@ var StatusBarActions = actions.Actions({ | |||||||
| 							.attr('info', 'Image position (click to toggle ribbon/global)') | 							.attr('info', 'Image position (click to toggle ribbon/global)') | ||||||
| 							// toggle index state...
 | 							// toggle index state...
 | ||||||
| 							.click(function(){ | 							.click(function(){ | ||||||
| 								$(this).parent() | 								that.toggleStatusBarIndexMode() | ||||||
| 									.toggleClass('global') |  | ||||||
| 								that.updateStatusBar() | 								that.updateStatusBar() | ||||||
| 							}) | 							}) | ||||||
| 						// editable...
 | 						// editable...
 | ||||||
| @ -141,7 +142,7 @@ var StatusBarActions = actions.Actions({ | |||||||
| 							.keyup(function(){ | 							.keyup(function(){ | ||||||
| 								event.stopPropagation() | 								event.stopPropagation() | ||||||
| 
 | 
 | ||||||
| 								that.config['status-bar-index']['live-update-on-edit'] | 								(that.config['status-bar-index'] || {})['live-update-on-edit'] | ||||||
| 									&& that.focusImage(i, | 									&& that.focusImage(i, | ||||||
| 										item.hasClass('global') ? 'global' : undefined) | 										item.hasClass('global') ? 'global' : undefined) | ||||||
| 							}) | 							}) | ||||||
| @ -160,8 +161,7 @@ var StatusBarActions = actions.Actions({ | |||||||
| 						.attr('info', 'Image position (click to toggle ribbon/global)') | 						.attr('info', 'Image position (click to toggle ribbon/global)') | ||||||
| 						// toggle index state...
 | 						// toggle index state...
 | ||||||
| 						.click(function(){ | 						.click(function(){ | ||||||
| 							$(this).parent() | 							that.toggleStatusBarIndexMode() | ||||||
| 								.toggleClass('global') |  | ||||||
| 							that.updateStatusBar() | 							that.updateStatusBar() | ||||||
| 						})) | 						})) | ||||||
| 
 | 
 | ||||||
| @ -170,8 +170,15 @@ var StatusBarActions = actions.Actions({ | |||||||
| 			} | 			} | ||||||
| 
 | 
 | ||||||
| 			// update...
 | 			// update...
 | ||||||
|  | 			// NOTE: using .toggleStatusBarIndexMode(..) here will fall
 | ||||||
|  | 			// 		into an infinite recursion...
 | ||||||
|  | 			var cls = (that.config['status-bar-index'] || {})['mode'] || 'normal' | ||||||
|  | 			item | ||||||
|  | 				.addClass(cls) | ||||||
|  | 				.removeClass(cls != 'normal' ? 'normal' : 'global') | ||||||
|  | 
 | ||||||
| 			// global index...
 | 			// global index...
 | ||||||
| 			if(item.hasClass('global')){ | 			if(cls == 'global'){ | ||||||
| 				item.find('.position:not(:focus)') | 				item.find('.position:not(:focus)') | ||||||
| 					.text(this.data.getImageOrder(gid)+1) | 					.text(this.data.getImageOrder(gid)+1) | ||||||
| 				item.find('.length') | 				item.find('.length') | ||||||
| @ -410,6 +417,29 @@ var StatusBarActions = actions.Actions({ | |||||||
| 			this.toggleStatusBar('none') | 			this.toggleStatusBar('none') | ||||||
| 			this.toggleStatusBar(mode) | 			this.toggleStatusBar(mode) | ||||||
| 		}], | 		}], | ||||||
|  | 
 | ||||||
|  | 	// XXX should these be here???
 | ||||||
|  | 	// XXX should this show a dialog???
 | ||||||
|  | 	editStatusBarIndex: ['- Interface/', | ||||||
|  | 		function(){ | ||||||
|  | 			this.toggleStatusBar('?') == 'none' && this.toggleStatusBar() | ||||||
|  | 
 | ||||||
|  | 			// XXX do this better...
 | ||||||
|  | 			this.ribbons.viewer.find('.global-info .index .position').focus().click() | ||||||
|  | 		}], | ||||||
|  | 	toggleStatusBarIndexMode: ['Interface/Status bar index mode', | ||||||
|  | 		toggler.CSSClassToggler( | ||||||
|  | 			function(){ return this.ribbons.viewer.find('.global-info .index') }, | ||||||
|  | 			['normal', 'global'], | ||||||
|  | 			function(state){ | ||||||
|  | 				this.toggleStatusBar('?') == 'none' && this.toggleStatusBar() | ||||||
|  | 
 | ||||||
|  | 				this.config['status-bar-index'] =  | ||||||
|  | 					JSON.parse(JSON.stringify(this.config['status-bar-index'])) | ||||||
|  | 				this.config['status-bar-index']['mode'] = state | ||||||
|  | 
 | ||||||
|  | 				this.updateStatusBar() | ||||||
|  | 			})], | ||||||
| }) | }) | ||||||
| 
 | 
 | ||||||
| var StatusBar =  | var StatusBar =  | ||||||
| @ -419,7 +449,6 @@ 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 
 | ||||||
|  | |||||||
| @ -711,6 +711,7 @@ module.Viewer = core.ImageGridFeatures.Feature({ | |||||||
| 	depends: [ | 	depends: [ | ||||||
| 		'lifecycle', | 		'lifecycle', | ||||||
| 		'base', | 		'base', | ||||||
|  | 		'workspace', | ||||||
| 	], | 	], | ||||||
| 
 | 
 | ||||||
| 	actions: ViewerActions, | 	actions: ViewerActions, | ||||||
| @ -1381,6 +1382,7 @@ module.ConfigLocalStorage = core.ImageGridFeatures.Feature({ | |||||||
| 	depends: [ | 	depends: [ | ||||||
| 		'ui', | 		'ui', | ||||||
| 	], | 	], | ||||||
|  | 	priority: 80, | ||||||
| 
 | 
 | ||||||
| 	isApplicable: function(){  | 	isApplicable: function(){  | ||||||
| 		return typeof(localStorage) != 'undefined'  | 		return typeof(localStorage) != 'undefined'  | ||||||
|  | |||||||
| @ -71,6 +71,7 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 		pattern: '.slideshow-running', | 		pattern: '.slideshow-running', | ||||||
| 		ignore: [ | 		ignore: [ | ||||||
| 			'Up', 'Down', 'Enter', | 			'Up', 'Down', 'Enter', | ||||||
|  | 			'R', 'L', | ||||||
| 		], | 		], | ||||||
| 
 | 
 | ||||||
| 		Esc: 'toggleSlideshow: "off"', | 		Esc: 'toggleSlideshow: "off"', | ||||||
| @ -80,6 +81,9 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 		Right: 'resetSlideshowTimer', | 		Right: 'resetSlideshowTimer', | ||||||
| 		Home: 'resetSlideshowTimer', | 		Home: 'resetSlideshowTimer', | ||||||
| 		End: 'resetSlideshowTimer', | 		End: 'resetSlideshowTimer', | ||||||
|  | 
 | ||||||
|  | 		R: 'toggleSlideshowDirection', | ||||||
|  | 		L: 'toggleSlideshowLooping', | ||||||
| 	}, | 	}, | ||||||
| 
 | 
 | ||||||
| 	'Global': { | 	'Global': { | ||||||
| @ -273,7 +277,11 @@ module.GLOBAL_KEYBOARD = { | |||||||
| 		}, | 		}, | ||||||
| 
 | 
 | ||||||
| 		// XXX for debug...
 | 		// XXX for debug...
 | ||||||
| 		G: function(){ $('.viewer').toggleClass('visible-gid') }, | 		G: { | ||||||
|  | 			default: 'editStatusBarIndex!', | ||||||
|  | 			shift: 'toggleStatusBarIndexMode!', | ||||||
|  | 			ctrl: function(){ $('.viewer').toggleClass('visible-gid') }, | ||||||
|  | 		}, | ||||||
| 	}, | 	}, | ||||||
| }	 | }	 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user