| 
									
										
										
										
											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') | 
					
						
							|  |  |  | var keyboard = require('lib/keyboard') | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 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
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-21 02:10:26 +03:00
										 |  |  | // helper...
 | 
					
						
							|  |  |  | function customScale(n){ | 
					
						
							|  |  |  | 	return { | 
					
						
							| 
									
										
										
										
											2016-06-21 02:45:45 +03:00
										 |  |  | 		default: 'fitCustom: '+n+' -- Set cutom image size', | 
					
						
							|  |  |  | 		'alt': 'setCustomSize: '+n+' -- Set current image size as custom', | 
					
						
							|  |  |  | 		'ctrl+shift': 'setCustomSize: '+n+' null -- Clear custom image size', | 
					
						
							| 
									
										
										
										
											2016-06-21 02:10:26 +03:00
										 |  |  | 	} | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:55 +03:00
										 |  |  | // XXX might be a good idea to be able ignore actions rather than keys...
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | // XXX add this to the global doc...
 | 
					
						
							|  |  |  | var GLOBAL_KEYBOARD = | 
					
						
							|  |  |  | module.GLOBAL_KEYBOARD = { | 
					
						
							| 
									
										
										
										
											2016-04-03 20:57:03 +03:00
										 |  |  | 	'Global':{ | 
					
						
							|  |  |  | 		doc: 'Global bindings that take priority over other sections.', | 
					
						
							|  |  |  | 		pattern: '*', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// XXX
 | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	'Slideshow': { | 
					
						
							|  |  |  | 		pattern: '.slideshow-running', | 
					
						
							|  |  |  | 		ignore: [ | 
					
						
							| 
									
										
										
										
											2016-04-03 00:58:49 +03:00
										 |  |  | 			'Esc', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			'Up', 'Down', 'Enter', | 
					
						
							| 
									
										
										
										
											2016-04-03 20:57:03 +03:00
										 |  |  | 			'R', 'L', 'G', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 		Esc: 'toggleSlideshow: "off" -- Exit slideshow', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		Enter: 'slideshowDialog', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Left: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 		Right: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 		Home: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 		End: 'resetSlideshowTimer', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-16 01:36:55 +03:00
										 |  |  | 		T: 'slideshowIntervalDialog', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		R: 'toggleSlideshowDirection', | 
					
						
							|  |  |  | 		L: 'toggleSlideshowLooping', | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:55 +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???
 | 
					
						
							| 
									
										
										
										
											2016-04-03 00:58:49 +03:00
										 |  |  | 	'Single Image': { | 
					
						
							|  |  |  | 		pattern: '.single-image-mode', | 
					
						
							|  |  |  | 		ignore: [ | 
					
						
							|  |  |  | 			'Esc', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// do not crop in single image mode...
 | 
					
						
							|  |  |  | 			'C', 'F2', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-24 01:13:12 +03:00
										 |  |  | 			// zooming...
 | 
					
						
							|  |  |  | 			'#0', '#1', '#2', '#3', '#4', '#5', '#6', '#7', '#8', '#9', | 
					
						
							| 
									
										
										
										
											2016-04-03 00:58:49 +03:00
										 |  |  | 		], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-21 02:45:45 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-10-23 04:16:54 +03:00
										 |  |  | 		// NOTE: these are here so as to enable handling via the next 
 | 
					
						
							|  |  |  | 		// 		block, i.e. the Viewer
 | 
					
						
							|  |  |  | 		// 		...if not given, then the ignore above will shadow the 
 | 
					
						
							|  |  |  | 		// 		keys...
 | 
					
						
							|  |  |  | 		// NOTE: the 'nop' action does not exist, this it will get ignored
 | 
					
						
							|  |  |  | 		'(': 'nop', | 
					
						
							|  |  |  | 		')': 'nop', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-06-21 02:45:45 +03:00
										 |  |  | 		// zooming...
 | 
					
						
							| 
									
										
										
										
											2016-04-28 18:01:00 +03:00
										 |  |  | 		'#1': 'fitScreen', | 
					
						
							| 
									
										
										
										
											2016-06-21 05:43:14 +03:00
										 |  |  | 		// XXX should these also be implemented in the same way as 4-9???
 | 
					
						
							| 
									
										
										
										
											2016-06-21 02:10:26 +03:00
										 |  |  | 		'#2': { | 
					
						
							|  |  |  | 			default: 'fitNormal', | 
					
						
							| 
									
										
										
										
											2016-06-21 05:43:14 +03:00
										 |  |  | 			'alt': 'setNormalScale -- Set current image size as normal', | 
					
						
							| 
									
										
										
										
											2016-06-21 06:06:34 +03:00
										 |  |  | 			'ctrl+shift': 'setNormalScale: null -- Reset normal image size to default', | 
					
						
							| 
									
										
										
										
											2016-06-21 02:10:26 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		'#3': { | 
					
						
							|  |  |  | 			default: 'fitSmall', | 
					
						
							| 
									
										
										
										
											2016-06-21 05:43:14 +03:00
										 |  |  | 			'alt': 'setSmallScale -- Set current image size as small', | 
					
						
							| 
									
										
										
										
											2016-06-21 06:06:34 +03:00
										 |  |  | 			'ctrl+shift': 'setSmallScale: null -- Reset small image size to default', | 
					
						
							| 
									
										
										
										
											2016-06-21 02:10:26 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		'#4': customScale(4), | 
					
						
							|  |  |  | 		'#5': customScale(5), | 
					
						
							|  |  |  | 		'#6': customScale(6), | 
					
						
							|  |  |  | 		'#7': customScale(7), | 
					
						
							|  |  |  | 		'#8': customScale(8), | 
					
						
							|  |  |  | 		'#9': customScale(9), | 
					
						
							|  |  |  | 		'#0': customScale(0), | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-24 01:13:12 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 		Esc: 'toggleSingleImage: "off" -- Exit single image view', | 
					
						
							| 
									
										
										
										
											2016-04-28 16:11:55 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// ignore sorting and reversing...
 | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:55 +03:00
										 |  |  | 		// XXX not sure about these yet, especially reversing...
 | 
					
						
							| 
									
										
										
										
											2016-04-28 16:11:55 +03:00
										 |  |  | 		R: { | 
					
						
							|  |  |  | 			shift: 'IGNORE', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		S: { | 
					
						
							|  |  |  | 			shift: 'IGNORE', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-03 00:58:49 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-05 18:54:09 +03:00
										 |  |  | 	// XXX add "save as collection..."
 | 
					
						
							| 
									
										
										
										
											2016-04-03 20:57:03 +03:00
										 |  |  | 	'Cropped': { | 
					
						
							| 
									
										
										
										
											2016-04-04 19:36:50 +03:00
										 |  |  | 		pattern: '.crop-mode', | 
					
						
							| 
									
										
										
										
											2016-04-05 18:54:09 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		Esc: { | 
					
						
							|  |  |  | 			default: 'uncrop', | 
					
						
							|  |  |  | 			ctrl: 'uncropAll', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-03 20:57:03 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-05 18:54:09 +03:00
										 |  |  | 	// XXX add "save as collection..." (???)
 | 
					
						
							| 
									
										
										
										
											2016-04-03 20:57:03 +03:00
										 |  |  | 	// XXX cleanup...
 | 
					
						
							|  |  |  | 	'Viewer': { | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		doc: 'NOTE: binding priority is the same as the order of sections '+ | 
					
						
							|  |  |  | 			'on this page.', | 
					
						
							|  |  |  | 		pattern: '*', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-07 04:58:22 +03:00
										 |  |  | 		X: { | 
					
						
							|  |  |  | 			alt: 'close', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		F4: { | 
					
						
							|  |  |  | 			alt: 'close', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Q: { | 
					
						
							|  |  |  | 			meta: 'close', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-03 20:57:03 +03:00
										 |  |  | 		// XXX
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		F5: keyboard.doc('Full reload viewer',  | 
					
						
							|  |  |  | 			function(){  | 
					
						
							|  |  |  | 				//a.stop()
 | 
					
						
							|  |  |  | 				/* | 
					
						
							|  |  |  | 				killAllWorkers() | 
					
						
							|  |  |  | 					.done(function(){ | 
					
						
							|  |  |  | 						reload()  | 
					
						
							|  |  |  | 					}) | 
					
						
							|  |  |  | 				*/ | 
					
						
							|  |  |  | 				location.reload() | 
					
						
							|  |  |  | 				return false | 
					
						
							|  |  |  | 			}), | 
					
						
							|  |  |  | 		F12: 'showDevTools', | 
					
						
							|  |  |  | 		// NOTE: these are for systems where F** keys are not available 
 | 
					
						
							|  |  |  | 		// 		or do other stuff...
 | 
					
						
							|  |  |  | 		R: { | 
					
						
							|  |  |  | 			default: 'rotateCW', | 
					
						
							|  |  |  | 			shift: 'reverseImages', | 
					
						
							| 
									
										
										
										
											2016-06-09 00:10:11 +03:00
										 |  |  | 			ctrl: 'loadNewImages!', | 
					
						
							| 
									
										
										
										
											2016-08-07 02:42:25 +03:00
										 |  |  | 			alt: 'browseActions: "/Ribbon/" -- Open ribbon menu', | 
					
						
							| 
									
										
										
										
											2016-06-09 00:10:11 +03:00
										 |  |  | 			'ctrl+alt': 'reload!', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			'ctrl+shift': 'F5', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		L: 'rotateCCW', | 
					
						
							|  |  |  | 		H: { | 
					
						
							|  |  |  | 			default: 'flipHorizontal', | 
					
						
							|  |  |  | 			ctrl: 'listURLHistory', | 
					
						
							| 
									
										
										
										
											2016-05-04 21:28:46 +03:00
										 |  |  | 			'ctrl+shift': 'listSaveHistory', | 
					
						
							| 
									
										
										
										
											2016-04-03 21:33:36 +03:00
										 |  |  | 			alt: 'browseActions: "/History/" -- Open history menu', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		V: 'flipVertical', | 
					
						
							| 
									
										
										
										
											2016-11-23 16:14:38 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		// tilt...
 | 
					
						
							|  |  |  | 		// XXX experimental, not sure if wee need this with a keyboard...
 | 
					
						
							|  |  |  | 		T: { | 
					
						
							|  |  |  | 			default: 'rotateRibbonCCW -- Tilt ribbons counter clock wise', | 
					
						
							|  |  |  | 			shift: 'rotateRibbonCW -- Tilt ribbons clock wise', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			alt: 'resetRibbonRotation -- Reset ribbon tilt', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		P: { | 
					
						
							|  |  |  | 			'ctrl+shift': 'F12', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// NOTE: this is handled by the wrapper at this point, so we do 
 | 
					
						
							|  |  |  | 		// 		not have to do anything here...
 | 
					
						
							|  |  |  | 		F11: 'toggleFullScreen',  | 
					
						
							|  |  |  | 		F: { | 
					
						
							|  |  |  | 			ctrl: 'F11', | 
					
						
							|  |  |  | 			meta: 'F11', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// XXX testing...
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Enter: 'toggleSingleImage', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Home: { | 
					
						
							|  |  |  | 			default: 'firstImage', | 
					
						
							|  |  |  | 			ctrl: 'firstGlobalImage', | 
					
						
							|  |  |  | 			shift: 'firstRibbon', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		End: { | 
					
						
							|  |  |  | 			default: 'lastImage', | 
					
						
							|  |  |  | 			ctrl: 'lastGlobalImage', | 
					
						
							|  |  |  | 			shift: 'lastRibbon', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Left: { | 
					
						
							|  |  |  | 			default: 'prevImage', | 
					
						
							|  |  |  | 			alt: 'shiftImageLeft!', | 
					
						
							|  |  |  | 			ctrl: 'prevScreen', | 
					
						
							|  |  |  | 			// XXX need to prevent default on mac + browser...
 | 
					
						
							|  |  |  | 			meta: 'prevScreen', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		PgUp: 'prevScreen', | 
					
						
							|  |  |  | 		PgDown: 'nextScreen', | 
					
						
							|  |  |  | 		Right: { | 
					
						
							|  |  |  | 			default: 'nextImage', | 
					
						
							|  |  |  | 			alt: 'shiftImageRight!', | 
					
						
							|  |  |  | 			ctrl: 'nextScreen', | 
					
						
							|  |  |  | 			// XXX need to prevent default on mac + browser...
 | 
					
						
							|  |  |  | 			meta: 'nextScreen', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-23 00:07:04 +03:00
										 |  |  | 		Space: 'Right', | 
					
						
							|  |  |  | 		Backspace: 'Left', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		'(': 'prevImageInOrder', | 
					
						
							|  |  |  | 		')': 'nextImageInOrder', | 
					
						
							|  |  |  | 		',': 'prevMarked', | 
					
						
							|  |  |  | 		'.': 'nextMarked', | 
					
						
							|  |  |  | 		'[': 'prevBookmarked', | 
					
						
							|  |  |  | 		']': 'nextBookmarked', | 
					
						
							|  |  |  | 		Up: { | 
					
						
							|  |  |  | 			default: 'prevRibbon', | 
					
						
							|  |  |  | 			shift: 'shiftImageUp', | 
					
						
							|  |  |  | 			'alt+shift': 'travelImageUp', | 
					
						
							|  |  |  | 			'ctrl+shift': 'shiftImageUpNewRibbon', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Down: { | 
					
						
							|  |  |  | 			default: 'nextRibbon', | 
					
						
							|  |  |  | 			shift: 'shiftImageDown', | 
					
						
							|  |  |  | 			'alt+shift': 'travelImageDown', | 
					
						
							|  |  |  | 			'ctrl+shift': 'shiftImageDownNewRibbon', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'#0': 'fitMax', | 
					
						
							|  |  |  | 		'#1': { | 
					
						
							|  |  |  | 			default: 'fitImage', | 
					
						
							|  |  |  | 			shift: 'fitRibbon', | 
					
						
							|  |  |  | 			ctrl: 'fitOrig!', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 		'#2': 'fitImage: 2 -- Fit 2 Images', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		'#3': { | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			default: 'fitImage: 3 -- Fit 3 images', | 
					
						
							|  |  |  | 			shift: 'fitRibbon: 3.5 -- Fit 3.5 ribbons', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-07 05:41:06 +03:00
										 |  |  | 		'#4': 'fitImage: 4 -- Fit 4 images', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		'#5': { | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			default: 'fitImage: 5 -- Fit 5 images', | 
					
						
							|  |  |  | 			shift: 'fitRibbon: 5.5 -- Fit 5.5 ribbons', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 		'#6': 'fitImage: 6 -- Fit 6 images', | 
					
						
							|  |  |  | 		'#7': 'fitImage: 7 -- Fit 7 images', | 
					
						
							|  |  |  | 		'#8':'fitImage: 8 -- Fit 8 images', | 
					
						
							|  |  |  | 		'#9': 'fitImage: 9 -- Fit 9 images', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		 | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 		'+': { | 
					
						
							|  |  |  | 			default: 'zoomIn', | 
					
						
							|  |  |  | 			ctrl: 'lighterTheme!', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		'=': '+', | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 		'-': { | 
					
						
							|  |  |  | 			default: 'zoomOut', | 
					
						
							|  |  |  | 			ctrl: 'darkerTheme!', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		F2: { | 
					
						
							|  |  |  | 			default: 'cropRibbon', | 
					
						
							|  |  |  | 			shift: 'cropRibbonAndAbove', | 
					
						
							|  |  |  | 			ctrl: 'cropMarked', | 
					
						
							|  |  |  | 			alt: 'cropBookmarked', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// marking...
 | 
					
						
							|  |  |  | 		M: { | 
					
						
							|  |  |  | 			default: 'toggleMark', | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			alt: 'browseActions: "/Mark/" -- Show mark menu', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		A: { | 
					
						
							|  |  |  | 			alt: 'browseActions', | 
					
						
							|  |  |  | 			'alt+shift': 'listActions', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			ctrl: 'toggleMark!: "ribbon" "on" -- Mark all images in ribbon', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		D: { | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			ctrl: 'toggleMark!: "ribbon" "off" -- Unmark all images in ribbon', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		I: { | 
					
						
							|  |  |  | 			default: 'showMetadata', | 
					
						
							| 
									
										
										
										
											2016-06-23 01:00:24 +03:00
										 |  |  | 			alt: 'browseActions: "/Image/" -- Show image menu', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			shift: 'toggleStatusBar', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			ctrl: 'toggleMark!: "ribbon" -- Invert marks in ribbon', | 
					
						
							|  |  |  | 			'ctrl+shift': 'showMetadata: "current" "full" -- Show full metadata', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			'meta+alt': 'showDevTools', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		 | 
					
						
							|  |  |  | 		B: { | 
					
						
							|  |  |  | 			default: 'toggleBookmark', | 
					
						
							|  |  |  | 			ctrl: 'toggleTheme!', | 
					
						
							| 
									
										
										
										
											2016-11-09 04:53:42 +03:00
										 |  |  | 			'ctrl+shift': 'toggleTheme!: "prev"', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			alt: 'browseActions: "/Bookmark/" -- Show bookmark menu', | 
					
						
							| 
									
										
										
										
											2016-06-29 19:58:10 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			// XXX not sure if this is the right way to go...
 | 
					
						
							|  |  |  | 			shift: 'setBaseRibbon', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 		E: { | 
					
						
							|  |  |  | 			default: 'openInExtenalEditor', | 
					
						
							| 
									
										
										
										
											2016-04-03 22:04:38 +03:00
										 |  |  | 			shift: 'openInExtenalEditor: 1 -- Open in alternative editor', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			alt: 'listExtenalEditors', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-12 19:01:40 +03:00
										 |  |  | 		C: { | 
					
						
							|  |  |  | 			default: 'browseActions: "/Crop/" -- Show crop menu', | 
					
						
							|  |  |  | 			// do the default copy thing...
 | 
					
						
							|  |  |  | 			// NOTE: this stops the default: handler from getting the ctrl:
 | 
					
						
							|  |  |  | 			// 		key case...
 | 
					
						
							|  |  |  | 			ctrl: '', | 
					
						
							|  |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		O: 'browsePath', | 
					
						
							|  |  |  | 		S: { | 
					
						
							|  |  |  | 			default: 'slideshowDialog', | 
					
						
							| 
									
										
										
										
											2016-04-22 18:11:22 +03:00
										 |  |  | 			//shift: 'sortImages: "Date" -- Sort images by date',
 | 
					
						
							|  |  |  | 			shift: 'sortImages -- Sort images', | 
					
						
							| 
									
										
										
										
											2016-04-28 17:50:55 +03:00
										 |  |  | 			//alt: 'browseActions: "/Sort/"',
 | 
					
						
							|  |  |  | 			alt: 'sortDialog', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			// XXX need to make this save to base_path if it exists and
 | 
					
						
							|  |  |  | 			// 		ask the user if it does not... now it always asks.
 | 
					
						
							|  |  |  | 			ctrl: 'saveIndexHere', | 
					
						
							| 
									
										
										
										
											2016-04-16 05:19:31 +03:00
										 |  |  | 			'ctrl+shift': 'exportDialog', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// XXX still experimental...
 | 
					
						
							|  |  |  | 		U: { | 
					
						
							|  |  |  | 			default: 'undoLast', | 
					
						
							|  |  |  | 			shift: 'redoLast', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		Z: { | 
					
						
							|  |  |  | 			ctrl: 'undoLast', | 
					
						
							|  |  |  | 			'ctrl+shift': 'redoLast', | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		G: { | 
					
						
							|  |  |  | 			default: 'editStatusBarIndex!', | 
					
						
							|  |  |  | 			shift: 'toggleStatusBarIndexMode!', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			// XXX for debug...
 | 
					
						
							| 
									
										
										
										
											2016-11-17 04:21:20 +03:00
										 |  |  | 			//ctrl: function(){ $('.viewer').toggleClass('visible-gid') },
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 		}, | 
					
						
							| 
									
										
										
										
											2016-04-07 05:41:06 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		'?': 'showKeyboardBindings', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | }	 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 00:58:49 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2016-04-03 06:30:30 +03:00
										 |  |  | // XXX add a key binding list UI...
 | 
					
						
							|  |  |  | // XXX add loading/storing of kb bindings...
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-03 00:58:49 +03:00
										 |  |  | // XXX add introspection and doc actions...
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | var KeyboardActions = actions.Actions({ | 
					
						
							|  |  |  | 	config: { | 
					
						
							|  |  |  | 		// 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, | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		'keyboard-repeat-pause-check': 100, | 
					
						
							| 
									
										
										
										
											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', | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	get keyboard(){ | 
					
						
							|  |  |  | 		return this.__keyboard_config | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 	pauseKeyboardRepeat: ['- Interface/', | 
					
						
							| 
									
										
										
										
											2016-12-03 17:28:58 +03:00
										 |  |  | 		function(){  | 
					
						
							|  |  |  | 			this.__keyboard_repeat_paused = true }], | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	toggleKeyboardHandling: ['- Interface/Toggle keyboard handling', | 
					
						
							|  |  |  | 		toggler.Toggler(null, function(_, state){  | 
					
						
							|  |  |  | 			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) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 			// start/reset keyboard handling...
 | 
					
						
							|  |  |  | 			if(state == 'on'){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-12-03 17:28:58 +03:00
										 |  |  | 				// NOTE: the target element must be focusable...
 | 
					
						
							|  |  |  | 				var target = | 
					
						
							|  |  |  | 				this.__keyboard_event_source = | 
					
						
							|  |  |  | 					this.config['keyboard-event-source'] == null  | 
					
						
							|  |  |  | 						|| this.config['keyboard-event-source'] == 'viewer' ? this.ribbons.viewer | 
					
						
							|  |  |  | 					: this.config['keyboard-event-source'] == 'window' ? $(window) | 
					
						
							|  |  |  | 					: this.config['keyboard-event-source'] == 'document' ? $(document) | 
					
						
							|  |  |  | 					: $(this.config['keyboard-event-source']) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 				// need to reset...
 | 
					
						
							|  |  |  | 				if(this.__keyboard_handler != null){ | 
					
						
							|  |  |  | 					target.off('keydown', this.__keyboard_handler) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				// 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){ | 
					
						
							|  |  |  | 					//this.ribbons.viewer
 | 
					
						
							|  |  |  | 					var handler =  | 
					
						
							|  |  |  | 					this.__keyboard_handler = | 
					
						
							| 
									
										
										
										
											2016-12-12 15:29:37 +03:00
										 |  |  | 						keyboard.stoppableKeyboardRepeat( | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 							keyboard.makeKeyboardHandler( | 
					
						
							|  |  |  | 								function(){ return that.__keyboard_config }, | 
					
						
							|  |  |  | 								function(k){ window.DEBUG && console.log('KEY:', k) },  | 
					
						
							|  |  |  | 								this), | 
					
						
							|  |  |  | 							check) | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  | 				// drop keys if repeating too fast...
 | 
					
						
							|  |  |  | 				// NOTE: this is done for smoother animations...
 | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					var handler =  | 
					
						
							|  |  |  | 					this.__keyboard_handler = | 
					
						
							| 
									
										
										
										
											2016-12-12 15:29:37 +03:00
										 |  |  | 						keyboard.stoppableKeyboardRepeat( | 
					
						
							| 
									
										
										
										
											2016-12-03 14:39:04 +03:00
										 |  |  | 							keyboard.dropRepeatingkeys( | 
					
						
							|  |  |  | 								keyboard.makeKeyboardHandler( | 
					
						
							|  |  |  | 									function(){ return that.__keyboard_config }, | 
					
						
							|  |  |  | 									function(k){ window.DEBUG && console.log(k) }, | 
					
						
							|  |  |  | 									this),  | 
					
						
							|  |  |  | 								function(){  | 
					
						
							|  |  |  | 									return that.config['max-key-repeat-rate'] | 
					
						
							|  |  |  | 								}), | 
					
						
							|  |  |  | 							check) | 
					
						
							| 
									
										
										
										
											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) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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'])], | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-04-07 04:58:22 +03:00
										 |  |  | 	// XXX need to pre-process the docs...
 | 
					
						
							|  |  |  | 	// 		- remove the path component...
 | 
					
						
							|  |  |  | 	// 		- insert the action name where not doc present...
 | 
					
						
							|  |  |  | 	// XXX cleanup CSS
 | 
					
						
							| 
									
										
										
										
											2016-05-08 19:03:04 +03:00
										 |  |  | 	showKeyboardBindings: ['Interface/Show keyboard bindings...', | 
					
						
							| 
									
										
										
										
											2016-04-30 18:39:14 +03:00
										 |  |  | 		widgets.makeUIDialog('Drawer',  | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				return keyboard.buildKeybindingsHelpHTML(this.__keyboard_config, this) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 			{ | 
					
						
							|  |  |  | 				background: 'white', | 
					
						
							|  |  |  | 				focusable: true, | 
					
						
							|  |  |  | 			})], | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var Keyboard =  | 
					
						
							|  |  |  | module.Keyboard = core.ImageGridFeatures.Feature({ | 
					
						
							|  |  |  | 	title: '', | 
					
						
							|  |  |  | 	doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	tag: 'keyboard', | 
					
						
							|  |  |  | 	depends: [ | 
					
						
							|  |  |  | 		'ui' | 
					
						
							|  |  |  | 	], | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	actions: KeyboardActions,  | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	handlers: [ | 
					
						
							|  |  |  | 		['start', | 
					
						
							|  |  |  | 			function(){ | 
					
						
							|  |  |  | 				var that = this | 
					
						
							|  |  |  | 				this.__keyboard_config = this.keyboard || GLOBAL_KEYBOARD | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				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() | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}], | 
					
						
							| 
									
										
										
										
											2016-04-02 17:34:25 +03:00
										 |  |  | 	], | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /********************************************************************** | 
					
						
							| 
									
										
										
										
											2016-08-20 22:49:36 +03:00
										 |  |  | * vim:set ts=4 sw=4 :                               */ return module }) |