mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-30 19:00:09 +00:00 
			
		
		
		
	made drawer ui more generic, added stub options (P) and help (F1/H) drawers...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									d48de6be00
								
							
						
					
					
						commit
						30e09dbec3
					
				| @ -50,21 +50,18 @@ var KEYBOARD_CONFIG = { | |||||||
| 	//
 | 	//
 | ||||||
| 	// NOTE: need to keep all info modes before the rest so as to give 
 | 	// NOTE: need to keep all info modes before the rest so as to give 
 | ||||||
| 	// 		their bindings priority...
 | 	// 		their bindings priority...
 | ||||||
| 	'.help-mode': { | 	'.drawer-mode': { | ||||||
| 		title: 'Help', | 		title: 'Drawer modes', | ||||||
| 		doc: 'To enter this mode press <b>H</b> or <b>?</b>.'+ | 		doc: 'NOTE: In this mode all other key bindings are disabled, '+ | ||||||
| 
 |  | ||||||
| 			'<p>NOTE: In this mode all other key bindings are disabled, '+ |  | ||||||
| 			'except the ones explicitly defined here.', | 			'except the ones explicitly defined here.', | ||||||
| 
 | 
 | ||||||
| 		ignore: '*', | 		ignore: '*', | ||||||
| 
 | 
 | ||||||
| 		Esc: doc('Close help', | 		Esc: doc('Close drawer', | ||||||
| 			function(){  | 			function(){  | ||||||
| 				toggleKeyboardHelp('off')  | 				toggleKeyboardHelp('off')  | ||||||
| 				return false | 				return false | ||||||
| 			}), | 			}), | ||||||
| 		H: 'Esc', |  | ||||||
| 		Q: 'Esc', | 		Q: 'Esc', | ||||||
| 		'?': 'Esc', | 		'?': 'Esc', | ||||||
| 	}, | 	}, | ||||||
| @ -438,8 +435,13 @@ var KEYBOARD_CONFIG = { | |||||||
| 
 | 
 | ||||||
| 		'?': doc('Show keyboard bindings', | 		'?': doc('Show keyboard bindings', | ||||||
| 			function(){ toggleKeyboardHelp() }), | 			function(){ toggleKeyboardHelp() }), | ||||||
| 		H: '?', |  | ||||||
| 
 | 
 | ||||||
|  | 		F1: doc('Show help', | ||||||
|  | 			function(){ toggleHelp() }), | ||||||
|  | 		H: 'F1', | ||||||
|  | 
 | ||||||
|  | 		P: doc('Show options', | ||||||
|  | 			function(){ toggleOptionsUI() }), | ||||||
| 
 | 
 | ||||||
| 		/* testing the shift-key feature... | 		/* testing the shift-key feature... | ||||||
| 		'~': { | 		'~': { | ||||||
|  | |||||||
| @ -511,7 +511,7 @@ body { | |||||||
| 
 | 
 | ||||||
| /************************************************************ Help ***/ | /************************************************************ Help ***/ | ||||||
| /* this is for sliding stuff */ | /* this is for sliding stuff */ | ||||||
| .viewer.help-mode { | .viewer.drawer-mode { | ||||||
| 	box-shadow: 0px 0px 50px 0px silver; | 	box-shadow: 0px 0px 50px 0px silver; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										132
									
								
								ui/modes.js
									
									
									
									
									
								
							
							
						
						
									
										132
									
								
								ui/modes.js
									
									
									
									
									
								
							| @ -7,7 +7,106 @@ | |||||||
| //var DEBUG = DEBUG != null ? DEBUG : true
 | //var DEBUG = DEBUG != null ? DEBUG : true
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| /*********************************************************************/ | 
 | ||||||
|  | 
 | ||||||
|  | /********************************************************************** | ||||||
|  | * Utils... | ||||||
|  | */ | ||||||
|  | 
 | ||||||
|  | // NOTE: this expects a certain structure, this it is not generic...
 | ||||||
|  | function makeDrawerToggler(contentRenderer, root, element_class, mode_class){ | ||||||
|  | 	var toggler = createCSSClassToggler(root, mode_class + ' drawer-mode overlay', | ||||||
|  | 			function(action){ | ||||||
|  | 				// XXX
 | ||||||
|  | 				var body = $(document.body) | ||||||
|  | 				var win = $(window) | ||||||
|  | 
 | ||||||
|  | 				// on...
 | ||||||
|  | 				if(action == 'on'){ | ||||||
|  | 					// remove helo when we scroll to the top...
 | ||||||
|  | 					var scroll_handler = function(){ | ||||||
|  | 						if(body.scrollTop() <= 0){ | ||||||
|  | 							toggler('off') | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
|  | 					// prepare and cleanup...
 | ||||||
|  | 					$(element_class).remove() | ||||||
|  | 					$(root).addClass('overlay') | ||||||
|  | 
 | ||||||
|  | 					// build the help...
 | ||||||
|  | 					var doc = contentRenderer() | ||||||
|  | 						.addClass(element_class.replace('.', ' ')) | ||||||
|  | 						.on('click', function(){ | ||||||
|  | 							event.stopImmediatePropagation() | ||||||
|  | 							return false | ||||||
|  | 						}) | ||||||
|  | 						.css({ | ||||||
|  | 							cursor: 'auto', | ||||||
|  | 						}) | ||||||
|  | 						// XXX depends on body...
 | ||||||
|  | 						.appendTo(body) | ||||||
|  | 
 | ||||||
|  | 					// add exit by click...
 | ||||||
|  | 					// XXX depends on body...
 | ||||||
|  | 					body | ||||||
|  | 						.one('click', function(){ | ||||||
|  | 							toggler('off') | ||||||
|  | 						}) | ||||||
|  | 						.css({ | ||||||
|  | 							cursor: 'hand', | ||||||
|  | 						}) | ||||||
|  | 
 | ||||||
|  | 					// scroll to the help...
 | ||||||
|  | 					// NOTE: need to set the scroll handler AFTER we 
 | ||||||
|  | 					// 		scroll down, or it will be more of a 
 | ||||||
|  | 					// 		tease than a help...
 | ||||||
|  | 					var t = getRelativeVisualPosition($(root), doc).top | ||||||
|  | 					body | ||||||
|  | 						.animate({ | ||||||
|  | 							scrollTop: Math.abs(t) - 40, | ||||||
|  | 						}, function(){ | ||||||
|  | 							// XXX depends on window...
 | ||||||
|  | 							win | ||||||
|  | 								.on('scroll', scroll_handler) | ||||||
|  | 						}) | ||||||
|  | 
 | ||||||
|  | 				// off...
 | ||||||
|  | 				} else { | ||||||
|  | 					// things to cleanup...
 | ||||||
|  | 					var _cleanup = function(){ | ||||||
|  | 						$(element_class).remove() | ||||||
|  | 						$(root).removeClass('overlay') | ||||||
|  | 						// XXX depends on body...
 | ||||||
|  | 						body.click() | ||||||
|  | 						win.off('scroll', scroll_handler) | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
|  | 					// animate things if we are not at the top...
 | ||||||
|  | 					if(body.scrollTop() > 0){ | ||||||
|  | 							// XXX depends on body...
 | ||||||
|  | 							body | ||||||
|  | 								.css({ | ||||||
|  | 									cursor: '', | ||||||
|  | 								}) | ||||||
|  | 								.animate({ | ||||||
|  | 									scrollTop: 0, | ||||||
|  | 								}, _cleanup)  | ||||||
|  | 
 | ||||||
|  | 					// if we are at the top do things fast...
 | ||||||
|  | 					} else { | ||||||
|  | 						_cleanup() | ||||||
|  | 					} | ||||||
|  | 				} | ||||||
|  | 			}) | ||||||
|  | 	return toggler | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | /********************************************************************** | ||||||
|  | * Modes | ||||||
|  | */ | ||||||
| 
 | 
 | ||||||
| // XXX make this save and restore settings...
 | // XXX make this save and restore settings...
 | ||||||
| var toggleSingleImageMode = createCSSClassToggler('.viewer',  | var toggleSingleImageMode = createCSSClassToggler('.viewer',  | ||||||
| @ -201,6 +300,8 @@ function toggleImageProportions(mode){ | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | /* | ||||||
|  | // XXX make this generic, so as to add other UI renderers...
 | ||||||
| var toggleKeyboardHelp = createCSSClassToggler('.viewer', 'help-mode overlay', | var toggleKeyboardHelp = createCSSClassToggler('.viewer', 'help-mode overlay', | ||||||
| 		function(action){ | 		function(action){ | ||||||
| 			var body = $(document.body) | 			var body = $(document.body) | ||||||
| @ -278,6 +379,35 @@ var toggleKeyboardHelp = createCSSClassToggler('.viewer', 'help-mode overlay', | |||||||
| 				} | 				} | ||||||
| 			} | 			} | ||||||
| 		}) | 		}) | ||||||
|  | */ | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | var toggleHelp = makeDrawerToggler( | ||||||
|  | 		function(){ | ||||||
|  | 			return $('<h1>Help</h1>') | ||||||
|  | 		},  | ||||||
|  | 		'.viewer',  | ||||||
|  | 		'.general-help',  | ||||||
|  | 		'general-help-mode') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | var toggleKeyboardHelp = makeDrawerToggler( | ||||||
|  | 		function(){ | ||||||
|  | 			return buildKeybindingsHelpHTML(KEYBOARD_CONFIG) | ||||||
|  | 		},  | ||||||
|  | 		'.viewer',  | ||||||
|  | 		'.keyboard-help',  | ||||||
|  | 		'keyboard-help-mode') | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | var toggleOptionsUI = makeDrawerToggler( | ||||||
|  | 		function(){ | ||||||
|  | 			return $('<h1>Options</h1>') | ||||||
|  | 		},  | ||||||
|  | 		'.viewer',  | ||||||
|  | 		'.options-ui',  | ||||||
|  | 		'options-mode') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user