mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +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 | ||||
| */ | ||||
| 
 | ||||
| // XXX shifting images and unmarking in this mode do not work correctly...
 | ||||
| var toggleMarkedOnlyView = createCSSClassToggler('.viewer', 'marked-only', | ||||
| 	function(){ | ||||
| 		var cur = $('.current.image') | ||||
| @ -522,6 +523,7 @@ function markAll(mode){ | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // NOTE: this only does it's work in the current ribbon...
 | ||||
| function invertImageMarks(){ | ||||
| 	return $('.current.image') | ||||
| 		.closest('.ribbon') | ||||
| @ -559,8 +561,7 @@ function toggleImageMarkBlock(image){ | ||||
| function clickHandler(evt){ | ||||
| 	var img = $(evt.target).closest('.image') | ||||
| 
 | ||||
| 	centerImage( | ||||
| 		focusImage(img)) | ||||
| 	centerImage( focusImage(img) ) | ||||
| } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -281,6 +281,10 @@ var KEYBOARD_CONFIG = { | ||||
| 				} | ||||
| 				*/ | ||||
| 			}, | ||||
| 		Space: { | ||||
| 				default: 'Right', | ||||
| 				shift: 'Left', | ||||
| 			}, | ||||
| 
 | ||||
| 		Home: function(){ | ||||
| 				firstImage() | ||||
| @ -304,6 +308,13 @@ var KEYBOARD_CONFIG = { | ||||
| 		F: function(){ toggleImageProportions() }, | ||||
| 
 | ||||
| 		// XXX not final, think of a better way to do this... | ||||
| 		I: { | ||||
| 				shift: function(){ invertImageMarks() }, | ||||
| 		}, | ||||
| 		A: { | ||||
| 				shift: function(){ toggleImageMarkBlock() }, | ||||
| 				ctrl: function(){ markAll('ribbon') }, | ||||
| 			}, | ||||
| 		M: { | ||||
| 				default: function(){ toggleImageMark() }, | ||||
| 				shift: function(){ toggleMarkedOnlyView() }, | ||||
|  | ||||
| @ -100,7 +100,12 @@ var KEYBOARD_HANDLER_PROPAGATE = true | ||||
|  * 			<key-def> : <callback>, | ||||
|  * | ||||
|  * 			<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 
 | ||||
|  *				// combination of modifers like 'ctrl+shift', given in order 
 | ||||
|  *				// of priority.
 | ||||
| @ -171,11 +176,26 @@ function makeKeyboardHandler(keybindings, unhandled){ | ||||
| 				} | ||||
| 
 | ||||
| 				// 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){ | ||||
| 						// XXX need to take care of that we can always be a number or a string...
 | ||||
| 						handler = bindings[handler] | ||||
| 					} else if(typeof(h) == typeof(1)) { | ||||
| 					} else if(typeof(handler) == typeof(1)) { | ||||
| 						handler = bindings[toKeyName(handler)] | ||||
| 					} else { | ||||
| 						handler = bindings[toKeyCode(handler)] | ||||
| @ -200,7 +220,7 @@ function makeKeyboardHandler(keybindings, unhandled){ | ||||
| 					handler = handler[0] | ||||
| 				} | ||||
| 				// complex handler...
 | ||||
| 				if(typeof(handler) == typeof({})){ | ||||
| 				if(typeof(handler) == typeof({}) && handler.constructor.name == 'Object'){ | ||||
| 					var callback = handler[modifers] | ||||
| 					if(callback == null){ | ||||
| 						callback = handler['default'] | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user