mirror of
				https://github.com/flynx/ImageGrid.git
				synced 2025-10-31 03:10:07 +00:00 
			
		
		
		
	made the editor a real mode and tweaked controling it from keyboard...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									27cb832249
								
							
						
					
					
						commit
						2087d0768a
					
				
							
								
								
									
										38
									
								
								ui/editor.js
									
									
									
									
									
								
							
							
						
						
									
										38
									
								
								ui/editor.js
									
									
									
									
									
								
							| @ -9,39 +9,41 @@ | ||||
| 
 | ||||
| /*********************************************************************/ | ||||
| 
 | ||||
| // ImageGrid-specific editor setup...
 | ||||
| function setupEditor(){ | ||||
| 	// build the editor...
 | ||||
| 	if($('.panel').length == 0){ | ||||
| var toggleEditor = createCSSClassToggler('.viewer', '.editor-visible', | ||||
| 		function(action){ | ||||
| 			var ed = $('.panel') | ||||
| 
 | ||||
| 			if(action == 'on'){ | ||||
| 				// create the editor if this is first init...
 | ||||
| 				if(ed.length == 0){ | ||||
| 					$('.viewer') | ||||
| 						.append(makeEditorControls('.current.image') | ||||
| 				.addClass('noScroll')) | ||||
| 							.addClass('noScroll') | ||||
| 							// make clicks on unfocusable elements remove focus...
 | ||||
| 							.click(function(){ | ||||
| 								if(event.target != $('.panel :focus')[0]){ | ||||
| 									$('.panel :focus').blur() | ||||
| 								} | ||||
| 							})) | ||||
| 
 | ||||
| 						// setup the event to update the editor...
 | ||||
| 						.on('focusingImage', function(){ | ||||
| 				if($('.panel').css('display') != 'none'){ | ||||
| 							if(toggleEditor('?') == 'on'){ | ||||
| 								reloadControls('.current.image') | ||||
| 							} | ||||
| 						}) | ||||
| 
 | ||||
| 		reloadControls('.current.image') | ||||
| 
 | ||||
| 	// toggle the editor...
 | ||||
| 	// XXX do we need a real mode for this?
 | ||||
| 				// show the editor...
 | ||||
| 				} else { | ||||
| 		var ed = $('.panel') | ||||
| 
 | ||||
| 		// show...
 | ||||
| 		if(ed.css('display') == 'none'){ | ||||
| 			reloadControls('.current.image') | ||||
| 					ed.show() | ||||
| 				} | ||||
| 				// update the state...
 | ||||
| 				reloadControls('.current.image') | ||||
| 
 | ||||
| 			// hide...
 | ||||
| 			} else { | ||||
| 				ed.hide() | ||||
| 			} | ||||
| 	} | ||||
| } | ||||
| 		}) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -118,7 +118,7 @@ var KEYBOARD_CONFIG = { | ||||
| 
 | ||||
| 	// dialogs...
 | ||||
| 	//
 | ||||
| 	'.viewer.overlay .overlay-block.dialog': { | ||||
| 	'.viewer.overlay .overlay-block.dialog, .panel :focus': { | ||||
| 		title: 'Dialog', | ||||
| 		doc: 'NOTE: to <i>close</i> a dialog, in addition to the keyaboard '+ | ||||
| 			'shortcuts, one can also click anywhere outside the dialog.', | ||||
| @ -128,18 +128,26 @@ var KEYBOARD_CONFIG = { | ||||
| 		'insert-return': doc('Insert return'), | ||||
| 
 | ||||
| 		Enter: { | ||||
| 				default: doc('Accept dialog', | ||||
| 				default: doc('Accept dialog / input', | ||||
| 					function(){ | ||||
| 						var f = $(':focus') | ||||
| 						 | ||||
| 						// trigger the default button action...
 | ||||
| 						if(f.length > 0  | ||||
| 								&& (/button/i.test(f[0].tagName)  | ||||
| 									|| f.attr('type') == 'button')){ | ||||
| 							return true | ||||
| 								&& (/button|summary/i.test(f[0].tagName)  | ||||
| 									|| /button|checkbox/i.test(f.attr('type')))){ | ||||
| 							f.click() | ||||
| 							// prevent the key from propagating to the viewer...
 | ||||
| 							return false | ||||
| 
 | ||||
| 						// accept the input...
 | ||||
| 						} else if(toggleEditor('?') == 'on'){ | ||||
| 							f.blur() | ||||
| 							// prevent the key from propagating to the viewer...
 | ||||
| 							return false | ||||
| 
 | ||||
| 						// accept the dialog...
 | ||||
| 						} else { | ||||
| 						} else if(isOverlayVisible('.viewer')) { | ||||
| 							getOverlay($('.viewer')).trigger('accept') | ||||
| 							hideOverlay($('.viewer'))  | ||||
| 						} | ||||
| @ -149,9 +157,19 @@ var KEYBOARD_CONFIG = { | ||||
| 			}, | ||||
| 		Esc: doc('Close dialog',  | ||||
| 			function(){  | ||||
| 				if(isOverlayVisible('.viewer')){ | ||||
| 					//getOverlay($('.viewer')).trigger('close')
 | ||||
| 					hideOverlay($('.viewer'))  | ||||
| 					return false | ||||
| 
 | ||||
| 				} else if(toggleEditor('?') == 'on'){ | ||||
| 					var f = $(':focus') | ||||
| 					if(f.length > 0){ | ||||
| 						f.blur() | ||||
| 					} else { | ||||
| 						toggleEditor('off') | ||||
| 					} | ||||
| 				} | ||||
| 			}), | ||||
| 	}, | ||||
| 
 | ||||
| @ -703,7 +721,8 @@ var KEYBOARD_CONFIG = { | ||||
| 		E: { | ||||
| 				default: doc('Open image in external software', openImage), | ||||
| 				// XXX Experimental
 | ||||
| 				ctrl: doc('Open preview editor panel (Experimental)', setupEditor), | ||||
| 				ctrl: doc('Open preview editor panel (Experimental)',  | ||||
| 					function(){ toggleEditor() }), | ||||
| 			}, | ||||
| 		// XXX make F4 a default editor and E a default viewer...
 | ||||
| 		F4: 'E', | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user