| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | /*********************************************************************/ | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | var KEYBOARD_CONFIG = { | 
					
						
							|  |  |  | 	'Global bindings': { | 
					
						
							|  |  |  | 		doc: 'NOTE: binding priority is the same as the order of sections '+ | 
					
						
							|  |  |  | 			'on this page.', | 
					
						
							|  |  |  | 		pattern: '*', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		F4: { | 
					
						
							|  |  |  | 			alt: doc('Close viewer',  | 
					
						
							|  |  |  | 				function(){  | 
					
						
							|  |  |  | 					if(window.require != null){ | 
					
						
							|  |  |  | 						require('nw.gui') | 
					
						
							|  |  |  | 							.Window.get().close() | 
					
						
							|  |  |  | 						return false | 
					
						
							|  |  |  | 					} | 
					
						
							|  |  |  | 				}), | 
					
						
							|  |  |  | 		}, | 
					
						
							|  |  |  | 		F5: doc('Full reload viewer',  | 
					
						
							|  |  |  | 			function(){  | 
					
						
							|  |  |  | 				if(window.require != null){ | 
					
						
							|  |  |  | 					require('nw.gui') | 
					
						
							|  |  |  | 						.Window.get().reload() | 
					
						
							|  |  |  | 					return false | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}), | 
					
						
							|  |  |  | 		F12: doc('Show devTools',  | 
					
						
							|  |  |  | 			function(){  | 
					
						
							|  |  |  | 				if(window.require != null){ | 
					
						
							|  |  |  | 					require('nw.gui') | 
					
						
							|  |  |  | 						.Window.get().showDevTools() | 
					
						
							|  |  |  | 					return false | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}), | 
					
						
							|  |  |  | 	},	 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	'.overlay': { | 
					
						
							|  |  |  | 		title: 'Overlay mode.', | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 		doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 		ignore: '*', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		Esc: function(){ | 
					
						
							|  |  |  | 				removeOverlay() | 
					
						
							|  |  |  | 				return false | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 	'.editor:not(.inline-editor-mode)': { | 
					
						
							|  |  |  | 		title: 'Editor mode.', | 
					
						
							|  |  |  | 		doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'0': function(){ | 
					
						
							|  |  |  | 				var n = getPageNumber() | 
					
						
							|  |  |  | 				if(togglePageView('?') == 'on'){ | 
					
						
							|  |  |  | 					setMagazineScale(getPageTargetScale(1)) | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					setMagazineScale(getPageTargetScale(PAGES_IN_RIBBON)) | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 				setCurrentPage(n) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		Esc: '0', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'=': function(){ | 
					
						
							|  |  |  | 				var n = getPageNumber() | 
					
						
							|  |  |  | 				setMagazineScale(Math.min( | 
					
						
							|  |  |  | 						getMagazineScale() * 1.2,  | 
					
						
							|  |  |  | 						getPageTargetScale(1))) | 
					
						
							|  |  |  | 				setCurrentPage(n) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		'-': function(){ | 
					
						
							|  |  |  | 				var n = getPageNumber() | 
					
						
							|  |  |  | 				setMagazineScale(Math.max( | 
					
						
							|  |  |  | 						getMagazineScale() * 0.8,  | 
					
						
							|  |  |  | 						getPageTargetScale(PAGES_IN_RIBBON*2))) | 
					
						
							|  |  |  | 				setCurrentPage(n) | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		'O': { | 
					
						
							|  |  |  | 				// load...
 | 
					
						
							|  |  |  | 				// XXX needs testing...
 | 
					
						
							|  |  |  | 				'ctrl': function(){ | 
					
						
							|  |  |  | 					showInOverlay('<h1>Open Issue</h1>'+ | 
					
						
							|  |  |  | 						'<input type="file" id="upload" name="file" multiple onchange="handleFileSelect(event)"/>') | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		'S': { | 
					
						
							|  |  |  | 				// save...
 | 
					
						
							|  |  |  | 				// XXX needs testing...
 | 
					
						
							|  |  |  | 				'ctrl': function(){ | 
					
						
							|  |  |  | 					showInOverlay('<h1>Save Issue</h1>'+ | 
					
						
							|  |  |  | 						'<p>NOTE: this download will not include the actual '+ | 
					
						
							|  |  |  | 						'images. at this point, images should be added manually.</p>'+ | 
					
						
							|  |  |  | 						'<p><a id="data_download" href="#">Download</a></p>') | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 					// setup the data...
 | 
					
						
							|  |  |  | 					$(generateMagazineDownload) | 
					
						
							|  |  |  | 				}, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		// ?
 | 
					
						
							|  |  |  | 		'/': function(){ | 
					
						
							|  |  |  | 				showInOverlay('<h1>Controls</h1>'+ | 
					
						
							|  |  |  | 					'<p>NOTE: this section is a stub.<p>'+ | 
					
						
							|  |  |  | 					'<table width="100%">'+ | 
					
						
							|  |  |  | 						'<tr><td align="right" width="45%"><b> C-O </b></td><td> Load issue from file. </td></tr>'+ | 
					
						
							|  |  |  | 						'<tr><td align="right"><b> C-S </b></td><td> Save issue to file. </td></tr>'+ | 
					
						
							|  |  |  | 						'<tr><td align="right"><b> - / + </b></td><td> Zoom out/in. </td></tr>'+ | 
					
						
							|  |  |  | 						'<tr><td align="right"><b> 0 </b></td><td> Set default zoom level. </td></tr>'+ | 
					
						
							|  |  |  | 					'</table>') | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 	}, | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 	// ignore all keys except Esc here...
 | 
					
						
							| 
									
										
										
										
											2013-02-10 05:09:30 +04:00
										 |  |  | 	'.inline-editor-mode': { | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 		title: 'Inline editor mode.', | 
					
						
							|  |  |  | 		doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		//ignore: '*'
 | 
					
						
							|  |  |  | 		Esc: function(){ | 
					
						
							|  |  |  | 				$(':focus').blur() | 
					
						
							|  |  |  | 				return false | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2013-01-31 02:46:02 +04:00
										 |  |  | 	}, | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 	'.chrome:not(.inline-editor-mode)': { | 
					
						
							|  |  |  | 		title: 'Global bindings.', | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 		doc: '', | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 		Esc: function(){ | 
					
						
							|  |  |  | 				if(toggleEditor('?') == 'on'){ | 
					
						
							|  |  |  | 					toggleEditor('off') | 
					
						
							|  |  |  | 				} else { | 
					
						
							|  |  |  | 					togglePageView('off') | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2013-01-28 18:15:14 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 		Home: firstPage, | 
					
						
							|  |  |  | 		End: lastPage,  | 
					
						
							|  |  |  | 		Left: { | 
					
						
							|  |  |  | 				default: function(){ prevPage() }, | 
					
						
							|  |  |  | 				shift: prevBookmark, | 
					
						
							|  |  |  | 				ctrl: prevArticle, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		Right: { | 
					
						
							|  |  |  | 				default: function(){ nextPage() }, | 
					
						
							|  |  |  | 				shift: nextBookmark, | 
					
						
							|  |  |  | 				ctrl: nextArticle, | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		Space:	{ | 
					
						
							|  |  |  | 				default: 'Right', | 
					
						
							|  |  |  | 				shift: 'Left' | 
					
						
							|  |  |  | 			}, | 
					
						
							|  |  |  | 		//Tab: 'Space',
 | 
					
						
							|  |  |  | 		Tab: function(){ return false }, | 
					
						
							|  |  |  | 		Enter: function(){ togglePageView('on') }, | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 		// combined navigation with actions..
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 		Up: function(){ togglePageView() }, | 
					
						
							|  |  |  | 		Down: function(){ togglePageView() }, | 
					
						
							| 
									
										
										
										
											2013-01-31 02:46:02 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 		F: function(){ togglePageFitMode() }, | 
					
						
							|  |  |  | 		B: { | 
					
						
							|  |  |  | 				default: function(){ toggleBookmark() }, | 
					
						
							|  |  |  | 				ctrl: function(){ toggleThemes() }, | 
					
						
							|  |  |  | 			}, | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-02-04 00:23:11 +04:00
										 |  |  | 		// XXX this should not be in the production viewer...
 | 
					
						
							|  |  |  | 		E: function(){ toggleEditor() }, | 
					
						
							|  |  |  | 	}, | 
					
						
							|  |  |  | }  | 
					
						
							| 
									
										
										
										
											2013-01-27 22:41:06 +04:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /*********************************************************************/ | 
					
						
							|  |  |  | // vim:set ts=4 sw=4 nowrap :
 |