| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | /********************************************************************** | 
					
						
							|  |  |  | *  | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | * | 
					
						
							|  |  |  | **********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-08-21 02:19:24 +03:00
										 |  |  | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | 
					
						
							|  |  |  | (function(require){ var module={} // make module AMD/node compatible...
 | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var actions = require('lib/actions') | 
					
						
							|  |  |  | var features = require('lib/features') | 
					
						
							|  |  |  | var toggler = require('lib/toggler') | 
					
						
							| 
									
										
										
										
											2017-01-12 02:09:59 +03:00
										 |  |  | var keyboard = require('lib/keyboard') | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var core = require('features/core') | 
					
						
							| 
									
										
										
										
											2016-04-30 18:39:14 +03:00
										 |  |  | var widgets = require('features/ui-widgets') | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-07 04:58:22 +03:00
										 |  |  | var widget = require('lib/widget/widget') | 
					
						
							|  |  |  | var browse = require('lib/widget/browse') | 
					
						
							|  |  |  | var overlay = require('lib/widget/overlay') | 
					
						
							|  |  |  | var drawer = require('lib/widget/drawer') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var GLOBAL_KEYBOARD = | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | module.GLOBAL_KEYBOARD2 = { | 
					
						
							|  |  |  | 	'Global': { | 
					
						
							|  |  |  | 		doc: 'Global bindings that take priority over other sections.', | 
					
						
							|  |  |  | 		pattern: '*', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 	'Slideshow': { | 
					
						
							|  |  |  | 		pattern: '.slideshow-running', | 
					
						
							|  |  |  | 		drop: [ | 
					
						
							|  |  |  | 			'Esc', | 
					
						
							|  |  |  | 			'Up', 'Down', 'Enter', | 
					
						
							|  |  |  | 			'R', 'L', 'G', 'T', | 
					
						
							|  |  |  | 		], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Esc: 'toggleSlideshow: "off" -- Exit slideshow', | 
					
						
							|  |  |  | 		Enter: 'slideshowDialog', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Left: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 		Right: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 		Home: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 		End: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		T: 'slideshowIntervalDialog', | 
					
						
							| 
									
										
										
										
											2017-01-11 20:03:33 +03:00
										 |  |  | 		R: 'toggleSlideshowDirection -- Reverse slideshow direction', | 
					
						
							|  |  |  | 		L: 'toggleSlideshowLooping -- Toggle slideshow looping', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 	// XXX do we need to prevent up/down navigation here, it may get confusing?
 | 
					
						
							|  |  |  | 	// XXX do we need to disable fast sorting here???
 | 
					
						
							|  |  |  | 	'Single Image': { | 
					
						
							|  |  |  | 		pattern: '.single-image-mode', | 
					
						
							|  |  |  | 		drop: [ | 
					
						
							|  |  |  | 			'Esc', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// do not crop in single image mode...
 | 
					
						
							|  |  |  | 			'C', 'F2', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// zooming...
 | 
					
						
							|  |  |  | 			'#0', '#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', | 
					
						
							|  |  |  | 		], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 		// handle in next section...
 | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 		'(': 'NEXT', | 
					
						
							|  |  |  | 		')': 'NEXT', | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// zooming...
 | 
					
						
							|  |  |  | 		'#1': 'fitScreen', | 
					
						
							|  |  |  | 		// XXX should these also be implemented in the same way as 4-9???
 | 
					
						
							|  |  |  | 		'#2': 'fitNormal', | 
					
						
							|  |  |  | 		'alt+#2': 'setNormalScale -- Set current image size as normal', | 
					
						
							|  |  |  | 		'ctrl+shift+#2': 'setNormalScale: null -- Reset normal image size to default', | 
					
						
							|  |  |  | 		'#3': 'fitSmall', | 
					
						
							|  |  |  | 		'alt+#3': 'setSmallScale -- Set current image size as small', | 
					
						
							|  |  |  | 		'ctrl+shift+#3': 'setSmallScale: null -- Reset small image size to default', | 
					
						
							| 
									
										
										
										
											2017-01-09 05:40:24 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// NOTE: these are the same, the only difference is the number...
 | 
					
						
							|  |  |  | 		'#4': 'fitCustom: 4 -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt+#4': 'setCustomSize: 4 -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift+#4': 'setCustomSize: 4 null -- Clear custom image size', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'#5': 'fitCustom: 5 -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt+#5': 'setCustomSize: 5 -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift+#5': 'setCustomSize: 5 null -- Clear custom image size', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'#6': 'fitCustom: 6 -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt+#6': 'setCustomSize: 6 -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift+#6': 'setCustomSize: 6 null -- Clear custom image size', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'#7': 'fitCustom: 7 -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt+#7': 'setCustomSize: 7 -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift+#7': 'setCustomSize: 7 null -- Clear custom image size', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'#8': 'fitCustom: 8 -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt+#8': 'setCustomSize: 8 -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift+#8': 'setCustomSize: 8 null -- Clear custom image size', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'#9': 'fitCustom: 9 -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt+#9': 'setCustomSize: 9 -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift+#9': 'setCustomSize: 9 null -- Clear custom image size', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'#0': 'fitCustom: 0 -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt+#0': 'setCustomSize: 0 -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift+#0': 'setCustomSize: 0 null -- Clear custom image size', | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Esc: 'toggleSingleImage: "off" -- Exit single image view', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// ignore sorting and reversing...
 | 
					
						
							|  |  |  | 		// XXX not sure about these yet, especially reversing...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 		shift_R: 'DROP', | 
					
						
							|  |  |  | 		shift_S: 'DROP', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 	// XXX add "save as collection..."
 | 
					
						
							|  |  |  | 	'Cropped': { | 
					
						
							|  |  |  | 		pattern: '.crop-mode', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		Esc: 'uncrop', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		ctrl_Esc: 'uncropAll', | 
					
						
							| 
									
										
										
										
											2017-01-11 06:01:42 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		W: 'testAction2 -- XXX DEBUG: remove when done...', | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 	'Range': { | 
					
						
							|  |  |  | 		doc: 'Range editing', | 
					
						
							|  |  |  | 		pattern: '.brace', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		// XXX add:
 | 
					
						
							|  |  |  | 		// 		- range navigation
 | 
					
						
							|  |  |  | 		// 		- range manipulation
 | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		Esc: 'clearRange', | 
					
						
							|  |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 	// XXX add "save as collection..." (???)
 | 
					
						
							|  |  |  | 	// XXX cleanup...
 | 
					
						
							|  |  |  | 	'Viewer': { | 
					
						
							|  |  |  | 		doc: 'NOTE: binding priority is the same as the order of sections '+ | 
					
						
							|  |  |  | 			'on this page.', | 
					
						
							|  |  |  | 		pattern: '*', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		alt_X: 'close', | 
					
						
							|  |  |  | 		alt_F4: 'close', | 
					
						
							|  |  |  | 		meta_Q: 'close', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		// XXX
 | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 		F5: keyboard.doc('Reload viewer (full)',  | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 			function(){  | 
					
						
							|  |  |  | 				//a.stop()
 | 
					
						
							|  |  |  | 				/* | 
					
						
							|  |  |  | 				killAllWorkers() | 
					
						
							|  |  |  | 					.done(function(){ | 
					
						
							|  |  |  | 						reload()  | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 					}) | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 				*/ | 
					
						
							|  |  |  | 				location.reload() | 
					
						
							|  |  |  | 				return false | 
					
						
							|  |  |  | 			}), | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		F12: 'showDevTools', | 
					
						
							|  |  |  | 		// NOTE: these are for systems where F** keys are not available 
 | 
					
						
							|  |  |  | 		// 		or do other stuff...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		meta_alt_I: 'F12', | 
					
						
							|  |  |  | 		ctrl_shift_p: 'F12', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// dialogs...
 | 
					
						
							|  |  |  | 		// XXX should this be all here or in respective sections???
 | 
					
						
							|  |  |  | 		alt_A: 'browseActions', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		//alt_S: 'browseActions: "/Sort/"',
 | 
					
						
							|  |  |  | 		alt_shift_A: 'listActions', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// open/save...
 | 
					
						
							|  |  |  | 		O: 'browsePath', | 
					
						
							|  |  |  | 		ctrl_S: 'saveIndexHere', | 
					
						
							|  |  |  | 		ctrl_shift_S: 'exportDialog', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// external editors...
 | 
					
						
							|  |  |  | 		// XXX not sure if this is the right way to go...
 | 
					
						
							|  |  |  | 		E: 'openInExtenalEditor', | 
					
						
							|  |  |  | 		shift_E: 'openInExtenalEditor: 1 -- Open in alternative editor', | 
					
						
							|  |  |  | 		alt_E: 'listExtenalEditors', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// history...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		ctrl_H: 'listURLHistory', | 
					
						
							|  |  |  | 		ctrl_shift_H: 'listSaveHistory', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		U: 'undo', | 
					
						
							|  |  |  | 		ctrl_Z: 'undo', | 
					
						
							|  |  |  | 		shift_U: 'redo', | 
					
						
							|  |  |  | 		ctrl_shift_Z: 'redo', | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		alt_H: 'browseActions: "/History/" -- Open history menu', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		// tilt...
 | 
					
						
							|  |  |  | 		// XXX experimental, not sure if wee need this with a keyboard...
 | 
					
						
							|  |  |  | 		T: 'rotateRibbonCCW -- Tilt ribbons counter clock wise', | 
					
						
							|  |  |  | 		shift_T: 'rotateRibbonCW -- Tilt ribbons clock wise', | 
					
						
							|  |  |  | 		alt_T: 'resetRibbonRotation -- Reset ribbon tilt', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		// NOTE: this is handled by the wrapper at this point, so we do 
 | 
					
						
							|  |  |  | 		// 		not have to do anything here...
 | 
					
						
							|  |  |  | 		F11: 'toggleFullScreen',  | 
					
						
							|  |  |  | 		ctrl_F: 'F11', | 
					
						
							|  |  |  | 		meta_F: 'F11', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		ctrl_R: 'loadNewImages!', | 
					
						
							|  |  |  | 		ctrl_alt_R: 'reload!', | 
					
						
							|  |  |  | 		ctrl_shift_R: 'F5', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		// modes... 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		Enter: 'toggleSingleImage', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		S: 'slideshowDialog', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// statusbar...
 | 
					
						
							|  |  |  | 		shift_I: 'toggleStatusBar', | 
					
						
							|  |  |  | 		G: 'editStatusBarIndex!', | 
					
						
							|  |  |  | 		shift_G: 'toggleStatusBarIndexMode!', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// theme...
 | 
					
						
							| 
									
										
										
										
											2017-01-12 05:26:09 +03:00
										 |  |  | 		ctrl_B: 'toggleTheme!', | 
					
						
							|  |  |  | 		ctrl_shift_B: 'toggleTheme!: "prev"', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		'ctrl+-': 'darkerTheme!', | 
					
						
							|  |  |  | 		'ctrl++': 'lighterTheme!', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// navigation...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		Left: 'prevImage', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		Backspace: 'Left', | 
					
						
							|  |  |  | 		Right: 'nextImage', | 
					
						
							|  |  |  | 		Space: 'Right', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'(': 'prevImageInOrder', | 
					
						
							|  |  |  | 		')': 'nextImageInOrder', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		PgUp: 'prevScreen', | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		ctrl_Left: 'prevScreen', | 
					
						
							|  |  |  | 		// XXX need to prevent default on mac + browser...
 | 
					
						
							|  |  |  | 		meta_Left: 'prevScreen', | 
					
						
							| 
									
										
										
										
											2017-01-09 03:51:32 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		PgDown: 'nextScreen', | 
					
						
							|  |  |  | 		ctrl_Right: 'nextScreen', | 
					
						
							|  |  |  | 		// XXX need to prevent default on mac + browser...
 | 
					
						
							|  |  |  | 		meta_Right: 'nextScreen', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Home: 'firstImage', | 
					
						
							|  |  |  | 		ctrl_Home: 'firstGlobalImage', | 
					
						
							|  |  |  | 		shift_Home: 'firstRibbon', | 
					
						
							|  |  |  | 		End: 'lastImage', | 
					
						
							|  |  |  | 		ctrl_End: 'lastGlobalImage', | 
					
						
							|  |  |  | 		shift_End: 'lastRibbon', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		Up: 'prevRibbon', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		Down: 'nextRibbon', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// shifting...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		shift_Up: 'shiftImageUp', | 
					
						
							|  |  |  | 		alt_shift_Up: 'travelImageUp', | 
					
						
							|  |  |  | 		ctrl_shift_Up: 'shiftImageUpNewRibbon', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		shift_Down: 'shiftImageDown', | 
					
						
							|  |  |  | 		alt_shift_Down: 'travelImageDown', | 
					
						
							|  |  |  | 		ctrl_shift_Down: 'shiftImageDownNewRibbon', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		alt_Left: 'shiftImageLeft!', | 
					
						
							|  |  |  | 		alt_Right: 'shiftImageRight!', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		shift_R: 'setBaseRibbon', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// editing...
 | 
					
						
							|  |  |  | 		R: 'rotateCW', | 
					
						
							|  |  |  | 		L: 'rotateCCW', | 
					
						
							|  |  |  | 		H: 'flipHorizontal', | 
					
						
							|  |  |  | 		V: 'flipVertical', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// ribbon image stuff...
 | 
					
						
							|  |  |  | 		alt_I: 'browseActions: "/Image/" -- Show image menu', | 
					
						
							|  |  |  | 		alt_R: 'browseActions: "/Ribbon/" -- Open ribbon menu', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// ranges...
 | 
					
						
							|  |  |  | 		// XXX experimental
 | 
					
						
							|  |  |  | 		// XXX add border jumping to Home/End...
 | 
					
						
							|  |  |  | 		'{': 'openRange', | 
					
						
							|  |  |  | 		'}': 'closeRange', | 
					
						
							|  |  |  | 		'*': 'setRangeBorder', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// zooming...
 | 
					
						
							|  |  |  | 		'+': 'zoomIn', | 
					
						
							|  |  |  | 		'=': '+', | 
					
						
							|  |  |  | 		'-': 'zoomOut', | 
					
						
							|  |  |  | 		'_': '-', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		'#0': 'fitMax', | 
					
						
							|  |  |  | 		'#1': 'fitImage', | 
					
						
							|  |  |  | 		'shift+#1': 'fitRibbon', | 
					
						
							|  |  |  | 		'ctrl+#1': 'fitOrig!', | 
					
						
							|  |  |  | 		'#2': 'fitImage: 2 -- Fit 2 Images', | 
					
						
							|  |  |  | 		'#3': 'fitImage: 3 -- Fit 3 images', | 
					
						
							|  |  |  | 		'shift+#3': 'fitRibbon: 3.5 -- Fit 3.5 ribbons', | 
					
						
							|  |  |  | 		'#4': 'fitImage: 4 -- Fit 4 images', | 
					
						
							|  |  |  | 		'#5': 'fitImage: 5 -- Fit 5 images', | 
					
						
							|  |  |  | 		'shift+#5': 'fitRibbon: 5.5 -- Fit 5.5 ribbons', | 
					
						
							|  |  |  | 		'#6': 'fitImage: 6 -- Fit 6 images', | 
					
						
							|  |  |  | 		'#7': 'fitImage: 7 -- Fit 7 images', | 
					
						
							|  |  |  | 		'#8':'fitImage: 8 -- Fit 8 images', | 
					
						
							|  |  |  | 		'#9': 'fitImage: 9 -- Fit 9 images', | 
					
						
							|  |  |  | 		 | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		// cropping...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		F2: 'cropRibbon', | 
					
						
							|  |  |  | 		shift_F2: 'cropRibbonAndAbove', | 
					
						
							|  |  |  | 		ctrl_F2: 'cropMarked', | 
					
						
							|  |  |  | 		alt_F2: 'cropBookmarked', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		C: 'browseActions: "/Crop/" -- Show crop menu', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// metadata...
 | 
					
						
							|  |  |  | 		I: 'showMetadata', | 
					
						
							|  |  |  | 		ctrl_shift_I: 'showMetadata: "current" "full" -- Show full metadata', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// marking...
 | 
					
						
							|  |  |  | 		M: 'toggleMark', | 
					
						
							|  |  |  | 		ctrl_A: 'toggleMark!: "ribbon" "on" -- Mark all images in ribbon', | 
					
						
							|  |  |  | 		ctrl_D: 'toggleMark!: "ribbon" "off" -- Unmark all images in ribbon', | 
					
						
							|  |  |  | 		ctrl_I: 'toggleMark!: "ribbon" -- Invert marks in ribbon', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		',': 'prevMarked', | 
					
						
							|  |  |  | 		'.': 'nextMarked', | 
					
						
							|  |  |  | 		alt_M: 'browseActions: "/Mark/" -- Show mark menu', | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		// bookmarking...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		B: 'toggleBookmark', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		'[': 'prevBookmarked', | 
					
						
							|  |  |  | 		']': 'nextBookmarked', | 
					
						
							|  |  |  | 		alt_B: 'browseActions: "/Bookmark/" -- Show bookmark menu', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// copy/paste...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		// do the default copy thing...
 | 
					
						
							|  |  |  | 		// NOTE: this stops the default: handler from getting the ctrl:
 | 
					
						
							|  |  |  | 		// 		key case...
 | 
					
						
							|  |  |  | 		ctrl_C: '', | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 		ctrl_V: '', | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// sort...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		//shift_S: 'sortImages: "Date" -- Sort images by date',
 | 
					
						
							|  |  |  | 		shift_S: 'sortImages -- Sort images', | 
					
						
							|  |  |  | 		// XXX need to make this save to base_path if it exists and
 | 
					
						
							|  |  |  | 		// 		ask the user if it does not... now it always asks.
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 		shift_R: 'reverseImages', | 
					
						
							|  |  |  | 		alt_S: 'sortDialog', | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 04:58:32 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// doc...
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 		// XXX for debug...
 | 
					
						
							|  |  |  | 		//ctrl_G: function(){ $('.viewer').toggleClass('visible-gid') },
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 		//'?': 'showKeyboardBindings',
 | 
					
						
							|  |  |  | 		'?': 'browseKeyboardBindings', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 		//W: 'testAction -- XXX DEBUG: remove when done...',
 | 
					
						
							|  |  |  | 		W: 'nonAction -- XXX DEBUG: remove when done...', | 
					
						
							| 
									
										
										
										
											2017-01-07 04:22:53 +03:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-04-03 06:30:30 +03:00
										 |  |  | // XXX add loading/storing of kb bindings...
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | var KeyboardActions = actions.Actions({ | 
					
						
							|  |  |  | 	config: { | 
					
						
							| 
									
										
										
										
											2016-12-03 17:28:58 +03:00
										 |  |  | 		// Sets the target element to which the keyboard event handler 
 | 
					
						
							|  |  |  | 		// is bound...
 | 
					
						
							|  |  |  | 		//
 | 
					
						
							|  |  |  | 		// Supported values:
 | 
					
						
							|  |  |  | 		// 	'window'			- window element
 | 
					
						
							|  |  |  | 		// 	'document'			- document element
 | 
					
						
							|  |  |  | 		// 	'viewer'			- the viewer (default)
 | 
					
						
							|  |  |  | 		// 	null				- default element
 | 
					
						
							|  |  |  | 		// 	<css selector>		- any css selector
 | 
					
						
							|  |  |  | 		//
 | 
					
						
							|  |  |  | 		// NOTE: this value is not live, to update the target restart 
 | 
					
						
							|  |  |  | 		// 		the handler by cycling the toggler off and on...
 | 
					
						
							|  |  |  | 		// NOTE: the target element must be focusable...
 | 
					
						
							|  |  |  | 		'keyboard-event-source': 'window', | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 		// limit key repeat to one per N milliseconds.
 | 
					
						
							|  |  |  | 		//
 | 
					
						
							|  |  |  | 		// Set this to -1 or null to run keys without any limitations.
 | 
					
						
							|  |  |  | 		'max-key-repeat-rate': 0, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// The amount of keyboard "quiet" time to wait for when
 | 
					
						
							|  |  |  | 		// .pauseKeyboardRepeat(..) is called...
 | 
					
						
							|  |  |  | 		'keyboard-repeat-pause-check': 100, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// If 'on' enable .keyPressed(..) action calling on keyboard 
 | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 		// activity...
 | 
					
						
							|  |  |  | 		//
 | 
					
						
							|  |  |  | 		// NOTE: if updated the keyboard handler will need to be restarted
 | 
					
						
							|  |  |  | 		// 		for changes to take effect.
 | 
					
						
							|  |  |  | 		// XXX EXPERIMENTAL
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 		'keyboard-key-pressed-action': 'off', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 	get keybindings(){ | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 		return this.__keyboard_config }, | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 	get keyboard(){ | 
					
						
							|  |  |  | 		return this.__keyboard_object }, | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Self-test action...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 	testKeyboardDoc: ['- Interface/', | 
					
						
							|  |  |  | 		{self_test: true}, | 
					
						
							|  |  |  | 		function(){ | 
					
						
							|  |  |  | 			var that = this | 
					
						
							|  |  |  | 			var keys = this.keyboard.keys() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var index = {} | 
					
						
							|  |  |  | 			Object.keys(keys).forEach(function(mode){ | 
					
						
							|  |  |  | 				Object.keys(keys[mode]).forEach(function(code){ | 
					
						
							|  |  |  | 					if(code == ''){ | 
					
						
							|  |  |  | 						return | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					var a = keyboard.parseActionCall(code) | 
					
						
							|  |  |  | 					var doc = a.doc || that.getDocTitle(a.action) || null | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// check if we have no doc...
 | 
					
						
							|  |  |  | 					if(doc == null || doc == ''){ | 
					
						
							|  |  |  | 						console.warn('Action has no doc: "' | 
					
						
							|  |  |  | 							+ a.action +'" at: "'+ code +'"')  | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					// see if two actions have the same doc...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 22:34:57 +03:00
										 |  |  | 					//
 | 
					
						
							|  |  |  | 					// This problem can be fixed by:
 | 
					
						
							|  |  |  | 					// 	- setting a different doc in .keybindings...
 | 
					
						
							|  |  |  | 					// 	- updating action doc...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 					if(index[doc] && index[doc] != a.action){ | 
					
						
							| 
									
										
										
										
											2017-01-11 22:34:57 +03:00
										 |  |  | 						console.warn('Actions have same doc/title: "'  | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 							+ index[doc] +'" and "'+ a.action | 
					
						
							|  |  |  | 							+'" at: "'+ code +'"') | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					index[doc] = a.action | 
					
						
							|  |  |  | 				}) | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Key bindings ---------------------------------------------------
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 	// XXX need a clean deep copy to restore...
 | 
					
						
							|  |  |  | 	resetKeyBindings: ['Interface/Restore default key bindings', | 
					
						
							|  |  |  | 		function(){  | 
					
						
							|  |  |  | 			thiis.__keyboard_config = GLOBAL_KEYBOARD }], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	keyHandler: ['- Interface/Get or set key handler', | 
					
						
							|  |  |  | 		function(mode, key, action){  | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 			var res = this.keyboard.handler(mode, key, action)  | 
					
						
							|  |  |  | 			// return res only if we get a handler...
 | 
					
						
							|  |  |  | 			if(!action){ | 
					
						
							|  |  |  | 				return res | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		}], | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Get normalized, flat set of actions and keys that trigger them...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Format:
 | 
					
						
							|  |  |  | 	// 	{
 | 
					
						
							|  |  |  | 	// 		<action>: [
 | 
					
						
							|  |  |  | 	// 			<key>,
 | 
					
						
							|  |  |  | 	// 			...
 | 
					
						
							|  |  |  | 	// 		],
 | 
					
						
							|  |  |  | 	// 		...
 | 
					
						
							|  |  |  | 	// 	}
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// NOTE: this does not check overloading between modes i.e. if two
 | 
					
						
							|  |  |  | 	// 		actions in two different modes are bound to the same key 
 | 
					
						
							|  |  |  | 	// 		only one is shown...
 | 
					
						
							|  |  |  | 	// 		XXX is this a bug???
 | 
					
						
							|  |  |  | 	// 			...at this point can't find when this produces inconsistencies...
 | 
					
						
							|  |  |  | 	getKeysForAction: ['- Interface/', | 
					
						
							|  |  |  | 		function(actions, modes){ | 
					
						
							|  |  |  | 			var that = this | 
					
						
							|  |  |  | 			var res = {} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// Normalize handler to one of the following forms:
 | 
					
						
							|  |  |  | 			// 	- "<action>"
 | 
					
						
							|  |  |  | 			// 	- "<action>: <arg> ..."
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// We intentionally the following because they are not 
 | 
					
						
							|  |  |  | 			// relevant to the actual action function:
 | 
					
						
							|  |  |  | 			// 	- .doc
 | 
					
						
							|  |  |  | 			// 	- .no_default
 | 
					
						
							|  |  |  | 			// 	- .stop_propagation
 | 
					
						
							|  |  |  | 			var normalizeHandler = function(action){ | 
					
						
							|  |  |  | 				var a = keyboard.parseActionCall(action.doc || action) | 
					
						
							|  |  |  | 				return a.action in that ? | 
					
						
							|  |  |  | 					a.action  | 
					
						
							|  |  |  | 						+(a.arguments.length > 0 ?  | 
					
						
							|  |  |  | 							(': '+ a.arguments.map(JSON.stringify)) | 
					
						
							|  |  |  | 							: '') | 
					
						
							|  |  |  | 					: null  | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			actions = actions || '*' | 
					
						
							|  |  |  | 			actions = (actions != '*' && actions instanceof Array) ? | 
					
						
							|  |  |  | 				actions  | 
					
						
							|  |  |  | 				: [actions] | 
					
						
							|  |  |  | 			actions = actions != '*' ?  | 
					
						
							|  |  |  | 				// normalize the inputs...
 | 
					
						
							|  |  |  | 				actions.map(normalizeHandler)  | 
					
						
							|  |  |  | 				: actions | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			modes = modes || this.keyboard.modes() | 
					
						
							|  |  |  | 			modes = modes == '*' ? Object.keys(this.keybindings) | 
					
						
							|  |  |  | 				: modes instanceof Array ? modes  | 
					
						
							|  |  |  | 				: [modes] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			var keys = this.keyboard.keys() | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// build the result -- flatten the key list...
 | 
					
						
							|  |  |  | 			modes.forEach(function(mode){ | 
					
						
							|  |  |  | 				mode in keys  | 
					
						
							|  |  |  | 					&& Object.keys(keys[mode]) | 
					
						
							|  |  |  | 						// parse the actions...
 | 
					
						
							|  |  |  | 						.forEach(function(action){  | 
					
						
							|  |  |  | 							var t = normalizeHandler(action) | 
					
						
							|  |  |  | 							if(t && (actions == '*' || actions.indexOf(t) >= 0)){ | 
					
						
							|  |  |  | 								res[t] = (res[t] || []).concat(keys[mode][action]) | 
					
						
							|  |  |  | 							} | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 			}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return res | 
					
						
							|  |  |  | 		}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 	// keyboard handling ----------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 	toggleKeyboardHandling: ['- Interface/Keyboard handling', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		toggler.Toggler(null, function(_, state){  | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 			var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			if(state == null){ | 
					
						
							|  |  |  | 				return this.__keyboard_handler ? 'on' : 'off' | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 			// repeat stop checker...
 | 
					
						
							|  |  |  | 			var check = (function(){ | 
					
						
							|  |  |  | 				if(this.config['keyboard-repeat-pause-check'] > 0 | 
					
						
							|  |  |  | 						&& this.__keyboard_repeat_paused){ | 
					
						
							|  |  |  | 					var that = this | 
					
						
							|  |  |  | 					this.__keyboard_repeat_pause_timeout  | 
					
						
							|  |  |  | 						&& clearTimeout(this.__keyboard_repeat_pause_timeout) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					this.__keyboard_repeat_pause_timeout = setTimeout(function(){ | 
					
						
							|  |  |  | 						delete that.__keyboard_repeat_paused | 
					
						
							|  |  |  | 						delete that.__keyboard_repeat_pause_timeout  | 
					
						
							|  |  |  | 					}, this.config['keyboard-repeat-pause-check'] || 100) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					return false | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				return true | 
					
						
							|  |  |  | 			}).bind(this) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 			// pass keys pressed to .keyPressed(..) action...
 | 
					
						
							|  |  |  | 			// XXX EXPERIMENTAL...
 | 
					
						
							|  |  |  | 			var keyPressdCall = function(handler){ | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 				return that.config['keyboard-key-pressed-action'] == 'on' ? | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 					function(evt){ | 
					
						
							|  |  |  | 						var e = that.keyPressed.pre( | 
					
						
							|  |  |  | 							that,  | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 							[evt, keyboard.joinKey(keyboard.event2key(evt))]) | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 						var res = handler.apply(that, arguments) | 
					
						
							|  |  |  | 						e.result = res | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 						that.keyPressed.post(that, e) | 
					
						
							|  |  |  | 						return res | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 					: handler | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 			var kb = this.__keyboard_object =  | 
					
						
							|  |  |  | 				this.__keyboard_object  | 
					
						
							| 
									
										
										
										
											2017-01-12 02:41:03 +03:00
										 |  |  | 					|| keyboard.KeyboardWithCSSModes( | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 						function(){ return that.__keyboard_config }, | 
					
						
							| 
									
										
										
										
											2017-01-12 02:41:03 +03:00
										 |  |  | 						function(){ return that.ribbons.viewer }) | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			// start/reset keyboard handling...
 | 
					
						
							|  |  |  | 			if(state == 'on'){ | 
					
						
							| 
									
										
										
										
											2016-12-03 17:28:58 +03:00
										 |  |  | 				// NOTE: the target element must be focusable...
 | 
					
						
							|  |  |  | 				var target = | 
					
						
							|  |  |  | 				this.__keyboard_event_source = | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 					this.config['keyboard-event-source'] == null ? this.ribbons.viewer  | 
					
						
							|  |  |  | 					: this.config['keyboard-event-source'] == 'window' ? $(window) | 
					
						
							| 
									
										
										
										
											2017-01-11 20:03:33 +03:00
										 |  |  | 					: this.config['keyboard-event-source'] == 'viewer' ? this.ribbons.viewer | 
					
						
							| 
									
										
										
										
											2016-12-03 17:28:58 +03:00
										 |  |  | 					: this.config['keyboard-event-source'] == 'document' ? $(document) | 
					
						
							|  |  |  | 					: $(this.config['keyboard-event-source']) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 				// need to reset...
 | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 				this.__keyboard_handler | 
					
						
							|  |  |  | 					&& target.off('keydown', this.__keyboard_handler) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// make the base handler...
 | 
					
						
							|  |  |  | 				var handler =  | 
					
						
							|  |  |  | 					keyboard.stoppableKeyboardRepeat( | 
					
						
							|  |  |  | 						// XXX EXPERIMENTAL...
 | 
					
						
							|  |  |  | 						keyPressdCall( | 
					
						
							|  |  |  | 							keyboard.makeKeyboardHandler( | 
					
						
							|  |  |  | 								this.keyboard, | 
					
						
							|  |  |  | 								function(k){ window.DEBUG && console.log('KEY:', k) },  | 
					
						
							|  |  |  | 								this)), | 
					
						
							|  |  |  | 							check) | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// setup base keyboard for devel, in case something breaks...
 | 
					
						
							|  |  |  | 				// This branch does not drop keys...
 | 
					
						
							|  |  |  | 				if(this.config['max-key-repeat-rate'] < 0  | 
					
						
							|  |  |  | 						|| this.config['max-key-repeat-rate'] == null){ | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 					this.__keyboard_handler = handler | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// drop keys if repeating too fast...
 | 
					
						
							|  |  |  | 				// NOTE: this is done for smoother animations...
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 					handler =  | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 					this.__keyboard_handler = | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 						keyboard.dropRepeatingkeys( | 
					
						
							|  |  |  | 							handler, | 
					
						
							|  |  |  | 							function(){  | 
					
						
							|  |  |  | 								return that.config['max-key-repeat-rate'] }) | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				target.keydown(handler) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// stop keyboard handling...
 | 
					
						
							|  |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2016-12-03 17:28:58 +03:00
										 |  |  | 				this.__keyboard_event_source | 
					
						
							|  |  |  | 					&& this.__keyboard_event_source | 
					
						
							|  |  |  | 						.off('keydown', this.__keyboard_handler) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 				//delete this.__keyboard_object
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 				delete this.__keyboard_handler | 
					
						
							| 
									
										
										
										
											2016-12-03 17:28:58 +03:00
										 |  |  | 				delete this.__keyboard_event_source | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			} | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-03 20:57:03 +03:00
										 |  |  | 		['on', 'off'])], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 	// Drop keys until non are pressed for a timeout...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// This is useful for stopping repeating (held down) keys after some
 | 
					
						
							|  |  |  | 	// event.
 | 
					
						
							|  |  |  | 	pauseKeyboardRepeat: ['- Interface/', | 
					
						
							|  |  |  | 		function(){ this.__keyboard_repeat_paused = true }], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Keyboard activity event...
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// This is triggered when a key passes to .keyboard. The .pre stage
 | 
					
						
							|  |  |  | 	// is run before the key is handled, .post is run just after.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Option .config['keyboard-key-pressed-action'] controls if this is
 | 
					
						
							|  |  |  | 	// called, when false the functionality is disabled.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// Care must be taken when using binding to this (especially the 
 | 
					
						
							|  |  |  | 	// .pre stage) as this may introduce a lag into user input.
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							|  |  |  | 	// NOTE: updates to .config['keyboard-key-pressed-action'] will take
 | 
					
						
							|  |  |  | 	// 		effect after handler restart via .toggleKeyboardHandling('!') 
 | 
					
						
							|  |  |  | 	// 		or cycling it off and back on...
 | 
					
						
							|  |  |  | 	// NOTE: his is called by the handler created in .toggleKeyboardHandling(..)
 | 
					
						
							|  |  |  | 	//
 | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 	// XXX EXPERIMENTAL: event for actions to be able to handle keys...
 | 
					
						
							|  |  |  | 	// 		...not working yet...
 | 
					
						
							|  |  |  | 	// XXX not sure if we need this...
 | 
					
						
							|  |  |  | 	// 		...the main reason being that this may be a way to bypass the
 | 
					
						
							|  |  |  | 	// 		.keyboard handler and config and handle keys within an action
 | 
					
						
							|  |  |  | 	// 		if overdone this can be a mess...
 | 
					
						
							|  |  |  | 	keyPressed: ['- Interface/Key pressed event', | 
					
						
							|  |  |  | 		'This is called by the keyboard handler when a key is pressed, ' | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 			+'the actual event and key are passed as argument.', | 
					
						
							|  |  |  | 		core.notUserCallable(function(evt, key){ | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 			// This is the keyboard hook protocol root function
 | 
					
						
							|  |  |  | 			//
 | 
					
						
							|  |  |  | 			// Not for direct use.
 | 
					
						
							|  |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 	toggleKeyPressedHandling: ['Interface/keyPressed event', | 
					
						
							|  |  |  | 		core.makeConfigToggler('keyboard-key-pressed-action', | 
					
						
							|  |  |  | 			['off', 'on'], | 
					
						
							|  |  |  | 			function(){ this.toggleKeyboardHandling('!') })], | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-13 06:35:11 +03:00
										 |  |  | 	// Interface stuff ------------------------------------------------
 | 
					
						
							| 
									
										
										
										
											2017-01-03 02:55:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 05:40:48 +03:00
										 |  |  | 	// XXX key editor:
 | 
					
						
							| 
									
										
										
										
											2017-01-05 06:03:46 +03:00
										 |  |  | 	// 		[ mode ]
 | 
					
						
							| 
									
										
										
										
											2017-01-05 05:40:48 +03:00
										 |  |  | 	// 		[  action (text with dataset)  ] [  args (text field)  ] no default: [_]
 | 
					
						
							|  |  |  | 	//		---
 | 
					
						
							|  |  |  | 	//		<list of keys>
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 	//		new key
 | 
					
						
							| 
									
										
										
										
											2017-01-05 07:38:56 +03:00
										 |  |  | 	// XXX BUG sections with doc do not show up in title...
 | 
					
						
							| 
									
										
										
										
											2017-01-09 05:11:29 +03:00
										 |  |  | 	// XXX sub-group by path (???)
 | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 	// XXX place this in /Doc/.. (???)
 | 
					
						
							|  |  |  | 	browseKeyboardBindings: ['Interface|Help/Keyboard bindings...', | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 		widgets.makeUIDialog(function(path, edit, get_text){ | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 			var actions = this | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 			var keybindings = this.keybindings | 
					
						
							| 
									
										
										
										
											2017-01-11 05:53:05 +03:00
										 |  |  | 			var kb = this.keyboard | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 05:53:05 +03:00
										 |  |  | 			var keys = kb.keys('*') | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 			// get doc...
 | 
					
						
							|  |  |  | 			get_text = get_text === undefined && !edit ?  | 
					
						
							|  |  |  | 				function(action){ | 
					
						
							|  |  |  | 					var doc = action.doc ? action.doc | 
					
						
							|  |  |  | 						: action.action in this ? this.getDocTitle(action.action) | 
					
						
							|  |  |  | 						: action.action  | 
					
						
							|  |  |  | 					return doc.length == 0 ? action.action : doc | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				: get_text | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 			var dialog = browse.makeLister(null,  | 
					
						
							|  |  |  | 				function(path, make){ | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 					Object.keys(keybindings) | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 						.forEach(function(mode){ | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 							var dropped = keybindings[mode].drop || [] | 
					
						
							| 
									
										
										
										
											2017-01-06 02:18:21 +03:00
										 |  |  | 							var bound_ignored = [] | 
					
						
							| 
									
										
										
										
											2017-01-05 23:00:49 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 							// section heading...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 							make(keybindings[mode].doc ?  | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 									$('<span>') | 
					
						
							|  |  |  | 										// NOTE: at this time adding a br
 | 
					
						
							|  |  |  | 										// 		is faster and simpler than
 | 
					
						
							|  |  |  | 										// 		doing this in CSS...
 | 
					
						
							|  |  |  | 										// XXX revise...
 | 
					
						
							|  |  |  | 										.html(mode + '<br>') | 
					
						
							|  |  |  | 										.append($('<span>') | 
					
						
							|  |  |  | 											.addClass('doc') | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 											.html(keybindings[mode].doc)) | 
					
						
							| 
									
										
										
										
											2017-01-06 02:18:21 +03:00
										 |  |  | 									: mode,  | 
					
						
							|  |  |  | 									{  | 
					
						
							|  |  |  | 										not_filtered_out: true, | 
					
						
							|  |  |  | 										// XXX should sections be searchable???
 | 
					
						
							| 
									
										
										
										
											2017-01-12 21:23:16 +03:00
										 |  |  | 										not_searchable: true, | 
					
						
							| 
									
										
										
										
											2017-01-06 02:18:21 +03:00
										 |  |  | 									}) | 
					
						
							|  |  |  | 								.addClass('mode') | 
					
						
							| 
									
										
										
										
											2017-01-05 07:38:56 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 							// bindings...
 | 
					
						
							| 
									
										
										
										
											2017-01-06 02:18:21 +03:00
										 |  |  | 							var c = 0 | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 							Object.keys(keys[mode] || {}).forEach(function(action){ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 								action instanceof Function && console.log('!!!!!') | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 								var o = keyboard.parseActionCall(action) | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 								if(get_text){ | 
					
						
							|  |  |  | 									var doc = '' | 
					
						
							|  |  |  | 									var text = get_text.call(actions, o) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 								} else { | 
					
						
							|  |  |  | 									var doc = o.doc | 
					
						
							|  |  |  | 									var text = o.action  | 
					
						
							|  |  |  | 										+ (o.no_default ? '!' : '')  | 
					
						
							|  |  |  | 										+ (o.arguments.length > 0 ?  | 
					
						
							|  |  |  | 											(': '+ o.arguments.map(JSON.stringify).join(' ')) | 
					
						
							|  |  |  | 											: '') | 
					
						
							|  |  |  | 								} | 
					
						
							| 
									
										
										
										
											2017-01-11 05:53:05 +03:00
										 |  |  | 								var hidden = !edit  | 
					
						
							|  |  |  | 									&& !(o.action in actions)  | 
					
						
							|  |  |  | 									&& !(kb.handler(mode, keys[mode][action][0]) | 
					
						
							|  |  |  | 										instanceof Function) | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 								// NOTE: wee need the button spec to be
 | 
					
						
							|  |  |  | 								// 		searchable, thus we are not using 
 | 
					
						
							|  |  |  | 								// 		the keys attr as in .browseActions(..)
 | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 								make([text, ' ', '$BUTTONS'] | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 										.concat($('<span>') | 
					
						
							|  |  |  | 											.addClass('text') | 
					
						
							|  |  |  | 											.html(keys[mode][action] | 
					
						
							|  |  |  | 												// mark key if it is in dropped...
 | 
					
						
							|  |  |  | 												.map(function(s){  | 
					
						
							|  |  |  | 													s = s.split('+') | 
					
						
							|  |  |  | 													var k = s.pop()  | 
					
						
							|  |  |  | 													var i = dropped.indexOf(k) | 
					
						
							|  |  |  | 													i >= 0  | 
					
						
							|  |  |  | 														&& bound_ignored | 
					
						
							|  |  |  | 															.push(dropped[i]) | 
					
						
							|  |  |  | 													s.push(k  | 
					
						
							|  |  |  | 														+ (i >= 0 ?  '<sup>*</sup>' : '')) | 
					
						
							|  |  |  | 													return s.join('+') }) | 
					
						
							| 
									
										
										
										
											2017-01-11 05:53:05 +03:00
										 |  |  | 												.join(' / '))), | 
					
						
							|  |  |  | 									{ | 
					
						
							|  |  |  | 										// hide stuff that is not an action...
 | 
					
						
							|  |  |  | 										hidden: hidden,	 | 
					
						
							|  |  |  | 										disabled: hidden,	 | 
					
						
							|  |  |  | 									}) | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 									.attr('doc',  | 
					
						
							|  |  |  | 										doc.trim() != '' ?  | 
					
						
							|  |  |  | 											doc  | 
					
						
							| 
									
										
										
										
											2017-01-11 05:53:05 +03:00
										 |  |  | 											: (kb.special_handlers[action]  | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 												|| null)) | 
					
						
							| 
									
										
										
										
											2017-01-11 05:16:03 +03:00
										 |  |  | 									.addClass('key' | 
					
						
							|  |  |  | 										// special stuff...
 | 
					
						
							| 
									
										
										
										
											2017-01-11 05:53:05 +03:00
										 |  |  | 										+ (action in kb.special_handlers ? | 
					
						
							| 
									
										
										
										
											2017-01-11 05:16:03 +03:00
										 |  |  | 										   	' special-action'  | 
					
						
							|  |  |  | 											: '') | 
					
						
							|  |  |  | 										// aliases...
 | 
					
						
							|  |  |  | 										+ (o.action in actions ? '' : ' non-action')) | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 								c++ | 
					
						
							| 
									
										
										
										
											2017-01-06 02:18:21 +03:00
										 |  |  | 							}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							// no keys in view mode...
 | 
					
						
							|  |  |  | 							// XXX is adding info stuff like this a correct 
 | 
					
						
							|  |  |  | 							// 		thing to do in code?
 | 
					
						
							|  |  |  | 							c == 0 && !edit  | 
					
						
							|  |  |  | 								&& make('No bindings...',  | 
					
						
							|  |  |  | 									{ | 
					
						
							|  |  |  | 										disabled: true, | 
					
						
							|  |  |  | 										hide_on_search: true, | 
					
						
							|  |  |  | 									}) | 
					
						
							|  |  |  | 									.addClass('info') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							// unpropagated and unbound keys...
 | 
					
						
							|  |  |  | 							make(['Unpropagated and unbound keys:', | 
					
						
							|  |  |  | 									// NOTE: this blank is so as to avoid
 | 
					
						
							|  |  |  | 									// 		sticking the action and keys 
 | 
					
						
							|  |  |  | 									// 		together in path...
 | 
					
						
							|  |  |  | 									' ', | 
					
						
							|  |  |  | 									'$BUTTONS', | 
					
						
							| 
									
										
										
										
											2017-01-11 00:41:35 +03:00
										 |  |  | 									dropped | 
					
						
							| 
									
										
										
										
											2017-01-06 02:18:21 +03:00
										 |  |  | 										.filter(function(k){  | 
					
						
							|  |  |  | 											return bound_ignored.indexOf(k) == -1 }) | 
					
						
							|  |  |  | 										.join(' / ')]) | 
					
						
							|  |  |  | 								.addClass('ignore-list') | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-05 23:00:49 +03:00
										 |  |  | 							// controls...
 | 
					
						
							|  |  |  | 							if(edit){ | 
					
						
							|  |  |  | 								var elem = make('new', { | 
					
						
							|  |  |  | 									buttons: [ | 
					
						
							|  |  |  | 										// XXX
 | 
					
						
							|  |  |  | 										['key',  | 
					
						
							|  |  |  | 											function(){ | 
					
						
							|  |  |  | 												//elem.before( XXX )
 | 
					
						
							|  |  |  | 											}], | 
					
						
							|  |  |  | 										// XXX
 | 
					
						
							|  |  |  | 										['mode',  | 
					
						
							|  |  |  | 											function(){ | 
					
						
							|  |  |  | 												//elem.after( XXX )
 | 
					
						
							|  |  |  | 											}], | 
					
						
							|  |  |  | 									]}) | 
					
						
							|  |  |  | 									.addClass('new') | 
					
						
							|  |  |  | 							} | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 						}) | 
					
						
							| 
									
										
										
										
											2017-01-06 02:18:21 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 					// notes...
 | 
					
						
							|  |  |  | 					// XXX is adding info stuff like this a correct 
 | 
					
						
							|  |  |  | 					// 		thing to do in code?
 | 
					
						
							|  |  |  | 					make('---') | 
					
						
							|  |  |  | 					make($('<span>') | 
					
						
							|  |  |  | 							.addClass('text') | 
					
						
							|  |  |  | 							.html('<sup>*</sup> keys not propogated to next section.'),  | 
					
						
							|  |  |  | 						{  | 
					
						
							|  |  |  | 							disabled: true , | 
					
						
							|  |  |  | 							hide_on_search: true, | 
					
						
							|  |  |  | 						}) | 
					
						
							|  |  |  | 						.addClass('info') | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 				}, { | 
					
						
							| 
									
										
										
										
											2017-01-05 23:00:49 +03:00
										 |  |  | 					cls: [ | 
					
						
							|  |  |  | 						'key-bindings', | 
					
						
							|  |  |  | 						'no-item-numbers', | 
					
						
							|  |  |  | 						(edit ? 'edit' : 'browse'), | 
					
						
							|  |  |  | 					].join(' '), | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 					itemButtons: edit ? | 
					
						
							|  |  |  | 					   	[ | 
					
						
							|  |  |  | 							// NOTE: ordering within one section is purely 
 | 
					
						
							|  |  |  | 							// 		aesthetic and has no function...
 | 
					
						
							|  |  |  | 							// XXX do wee actually need ordering???
 | 
					
						
							|  |  |  | 							// XXX up
 | 
					
						
							|  |  |  | 							//['⏶', function(){}],
 | 
					
						
							|  |  |  | 							// XXX down
 | 
					
						
							|  |  |  | 							//['⏷', function(){}],
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 							// XXX edit -- launch the editor...
 | 
					
						
							|  |  |  | 							['⋯', function(){}], | 
					
						
							|  |  |  | 							//['edit', function(){}],
 | 
					
						
							|  |  |  | 							//['🖉', function(){}],
 | 
					
						
							|  |  |  | 						] | 
					
						
							|  |  |  | 						: [], | 
					
						
							| 
									
										
										
										
											2017-01-05 04:53:46 +03:00
										 |  |  | 				}) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			return dialog | 
					
						
							| 
									
										
										
										
											2017-01-05 03:06:06 +03:00
										 |  |  | 		})], | 
					
						
							| 
									
										
										
										
											2017-01-05 23:00:49 +03:00
										 |  |  | 	editKeyboardBindings: ['Interface/Keyboard bindings editor...', | 
					
						
							|  |  |  | 		widgets.uiDialog(function(path){  | 
					
						
							|  |  |  | 			return this.browseKeyboardBindings(path, true) })], | 
					
						
							| 
									
										
										
										
											2017-01-05 05:23:29 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-08 03:32:49 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-01-11 01:46:47 +03:00
										 |  |  | 	// XXX move to gen2
 | 
					
						
							|  |  |  | 	// XXX need to pre-process the docs...
 | 
					
						
							|  |  |  | 	// 		- remove the path component...
 | 
					
						
							|  |  |  | 	// 		- insert the action name where not doc present...
 | 
					
						
							|  |  |  | 	// XXX cleanup CSS
 | 
					
						
							|  |  |  | 	showKeyboardBindings: ['Interface/Show keyboard bindings...', | 
					
						
							|  |  |  | 		widgets.makeUIDialog('Drawer',  | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				return keyboard.buildKeybindingsHelpHTML( | 
					
						
							|  |  |  | 					this.__keyboard_config,  | 
					
						
							|  |  |  | 					this,  | 
					
						
							|  |  |  | 					function(action){ | 
					
						
							|  |  |  | 						return Object.keys(this.getPath(action))[0] }) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				background: 'white', | 
					
						
							|  |  |  | 				focusable: true, | 
					
						
							|  |  |  | 			})], | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var Keyboard =  | 
					
						
							|  |  |  | module.Keyboard = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'keyboard', | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui' | 
					
						
							|  |  |  | 	], | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 	suggested: [ | 
					
						
							|  |  |  | 		'self-test', | 
					
						
							|  |  |  | 	], | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	actions: KeyboardActions,  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	handlers: [ | 
					
						
							|  |  |  | 		['start', | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							| 
									
										
										
										
											2017-01-11 04:45:34 +03:00
										 |  |  | 				this.__keyboard_config = this.keybindings || GLOBAL_KEYBOARD | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				this.toggleKeyboardHandling('on') | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 			}], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// pause keyboard repeat...
 | 
					
						
							|  |  |  | 		['shiftImageUp.pre shiftImageDown.pre', | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				var r = this.current_ribbon | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				return function(){ | 
					
						
							|  |  |  | 					// pause repeat if shifting last image out of the ribbon... 
 | 
					
						
							|  |  |  | 					if(this.data.ribbons[r] == null  | 
					
						
							|  |  |  | 							|| this.data.ribbons[r].len == 0){ | 
					
						
							|  |  |  | 						this.pauseKeyboardRepeat() | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}], | 
					
						
							| 
									
										
										
										
											2017-01-11 22:32:16 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		['keyHandler', | 
					
						
							|  |  |  | 			function(res, mode, key, action){ | 
					
						
							|  |  |  | 				action && this.checkKeyboardDoc() }], | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |