Allow changing album pages by arrow keys.
This commit is contained in:
		
							parent
							
								
									f86a3ce358
								
							
						
					
					
						commit
						0341f73d09
					
				
							
								
								
									
										32
									
								
								public/js/albumnav.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								public/js/albumnav.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,32 @@
 | 
				
			|||||||
 | 
					function enableKeyDownNavigation() {
 | 
				
			||||||
 | 
						document.addEventListener("keydown", function (event) {
 | 
				
			||||||
 | 
							if (event.keyCode == 37) {
 | 
				
			||||||
 | 
								var target = document.querySelector(".pagination ul > :first-child a");
 | 
				
			||||||
 | 
								if (target && target.href) {
 | 
				
			||||||
 | 
									event.preventDefault();
 | 
				
			||||||
 | 
									document.location.href = target.href;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
							else if (event.keyCode == 39) {
 | 
				
			||||||
 | 
								var target = document.querySelector(".pagination ul > :last-child a");
 | 
				
			||||||
 | 
								if (target && target.href) {
 | 
				
			||||||
 | 
									event.preventDefault();
 | 
				
			||||||
 | 
									document.location.href = target.href;
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}, false);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function disableKeyDownPropagation(obj) {
 | 
				
			||||||
 | 
						for (var x = 0; x < obj.length; x++) {
 | 
				
			||||||
 | 
							obj[x].addEventListener("keydown", function (event) {
 | 
				
			||||||
 | 
								if (event.keyCode == 37 || event.keyCode == 39) {
 | 
				
			||||||
 | 
									event.stopPropagation();
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							});
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					enableKeyDownNavigation();
 | 
				
			||||||
 | 
					disableKeyDownPropagation(document.getElementsByTagName("textarea"));
 | 
				
			||||||
 | 
					disableKeyDownPropagation(document.getElementsByTagName("input"));
 | 
				
			||||||
@ -53,7 +53,8 @@ class PhotosIndex extends SubTemplate
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		echo '
 | 
							echo '
 | 
				
			||||||
			</div>';
 | 
								</div>
 | 
				
			||||||
 | 
								<script type="text/javascript" src="', BASEURL, '/js/albumnav.js"></script>';
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	protected function header($photos)
 | 
						protected function header($photos)
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user