mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 11:20:09 +00:00 
			
		
		
		
	added complex handler aliases to keyboard.js...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									e32384b64d
								
							
						
					
					
						commit
						346b09b4c0
					
				| @ -176,6 +176,7 @@ function createRibbon(){ | |||||||
| * Modes | * Modes | ||||||
| */ | */ | ||||||
| 
 | 
 | ||||||
|  | // XXX shifting images and unmarking in this mode do not work correctly...
 | ||||||
| var toggleMarkedOnlyView = createCSSClassToggler('.viewer', 'marked-only', | var toggleMarkedOnlyView = createCSSClassToggler('.viewer', 'marked-only', | ||||||
| 	function(){ | 	function(){ | ||||||
| 		var cur = $('.current.image') | 		var cur = $('.current.image') | ||||||
| @ -522,6 +523,7 @@ function markAll(mode){ | |||||||
| 	} | 	} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | // NOTE: this only does it's work in the current ribbon...
 | ||||||
| function invertImageMarks(){ | function invertImageMarks(){ | ||||||
| 	return $('.current.image') | 	return $('.current.image') | ||||||
| 		.closest('.ribbon') | 		.closest('.ribbon') | ||||||
| @ -559,8 +561,7 @@ function toggleImageMarkBlock(image){ | |||||||
| function clickHandler(evt){ | function clickHandler(evt){ | ||||||
| 	var img = $(evt.target).closest('.image') | 	var img = $(evt.target).closest('.image') | ||||||
| 
 | 
 | ||||||
| 	centerImage( | 	centerImage( focusImage(img) ) | ||||||
| 		focusImage(img)) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -281,6 +281,10 @@ var KEYBOARD_CONFIG = { | |||||||
| 				} | 				} | ||||||
| 				*/ | 				*/ | ||||||
| 			}, | 			}, | ||||||
|  | 		Space: { | ||||||
|  | 				default: 'Right', | ||||||
|  | 				shift: 'Left', | ||||||
|  | 			}, | ||||||
| 
 | 
 | ||||||
| 		Home: function(){ | 		Home: function(){ | ||||||
| 				firstImage() | 				firstImage() | ||||||
| @ -304,6 +308,13 @@ var KEYBOARD_CONFIG = { | |||||||
| 		F: function(){ toggleImageProportions() }, | 		F: function(){ toggleImageProportions() }, | ||||||
| 
 | 
 | ||||||
| 		// XXX not final, think of a better way to do this... | 		// XXX not final, think of a better way to do this... | ||||||
|  | 		I: { | ||||||
|  | 				shift: function(){ invertImageMarks() }, | ||||||
|  | 		}, | ||||||
|  | 		A: { | ||||||
|  | 				shift: function(){ toggleImageMarkBlock() }, | ||||||
|  | 				ctrl: function(){ markAll('ribbon') }, | ||||||
|  | 			}, | ||||||
| 		M: { | 		M: { | ||||||
| 				default: function(){ toggleImageMark() }, | 				default: function(){ toggleImageMark() }, | ||||||
| 				shift: function(){ toggleMarkedOnlyView() }, | 				shift: function(){ toggleMarkedOnlyView() }, | ||||||
|  | |||||||
| @ -100,7 +100,12 @@ var KEYBOARD_HANDLER_PROPAGATE = true | |||||||
|  * 			<key-def> : <callback>, |  * 			<key-def> : <callback>, | ||||||
|  * |  * | ||||||
|  * 			<key-def> : { |  * 			<key-def> : { | ||||||
|  * 				'default': <callback>, |  *				// modifiers can either have a callback or an alias as 
 | ||||||
|  |  *				// a value...
 | ||||||
|  |  *				// NOTE: when the alias is resolved, the same modifiers 
 | ||||||
|  |  *				//		will be applied to the final resolved handler.
 | ||||||
|  |  * 				'default': <callback> | <key-def-x>, | ||||||
|  |  * | ||||||
|  *				// a modifier can be any single modifier, like shift or a 
 |  *				// a modifier can be any single modifier, like shift or a 
 | ||||||
|  *				// combination of modifers like 'ctrl+shift', given in order 
 |  *				// combination of modifers like 'ctrl+shift', given in order 
 | ||||||
|  *				// of priority.
 |  *				// of priority.
 | ||||||
| @ -171,11 +176,26 @@ function makeKeyboardHandler(keybindings, unhandled){ | |||||||
| 				} | 				} | ||||||
| 
 | 
 | ||||||
| 				// alias...
 | 				// alias...
 | ||||||
| 				while (typeof(handler) == typeof(123) || typeof(handler) == typeof('str')) { | 				while (typeof(handler) == typeof(123)  | ||||||
|  | 						|| typeof(handler) == typeof('str') | ||||||
|  | 						|| typeof(handler) == typeof({}) && handler.constructor.name == 'Object') { | ||||||
|  | 
 | ||||||
|  | 					// do the complex handler aliases...
 | ||||||
|  | 					if(typeof(handler) == typeof({}) && handler.constructor.name == 'Object'){ | ||||||
|  | 						if(typeof(handler[modifers]) == typeof('str')){ | ||||||
|  | 							handler = handler[modifers] | ||||||
|  | 						} else if(typeof(handler['default']) == typeof('str')){ | ||||||
|  | 							handler = handler['default'] | ||||||
|  | 						} else { | ||||||
|  | 							break | ||||||
|  | 						} | ||||||
|  | 					} | ||||||
|  | 
 | ||||||
|  | 					// simple handlers...
 | ||||||
| 					if(handler in bindings){ | 					if(handler in bindings){ | ||||||
| 						// XXX need to take care of that we can always be a number or a string...
 | 						// XXX need to take care of that we can always be a number or a string...
 | ||||||
| 						handler = bindings[handler] | 						handler = bindings[handler] | ||||||
| 					} else if(typeof(h) == typeof(1)) { | 					} else if(typeof(handler) == typeof(1)) { | ||||||
| 						handler = bindings[toKeyName(handler)] | 						handler = bindings[toKeyName(handler)] | ||||||
| 					} else { | 					} else { | ||||||
| 						handler = bindings[toKeyCode(handler)] | 						handler = bindings[toKeyCode(handler)] | ||||||
| @ -200,7 +220,7 @@ function makeKeyboardHandler(keybindings, unhandled){ | |||||||
| 					handler = handler[0] | 					handler = handler[0] | ||||||
| 				} | 				} | ||||||
| 				// complex handler...
 | 				// complex handler...
 | ||||||
| 				if(typeof(handler) == typeof({})){ | 				if(typeof(handler) == typeof({}) && handler.constructor.name == 'Object'){ | ||||||
| 					var callback = handler[modifers] | 					var callback = handler[modifers] | ||||||
| 					if(callback == null){ | 					if(callback == null){ | ||||||
| 						callback = handler['default'] | 						callback = handler['default'] | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user