diff --git a/public/js/albumnav.js b/public/js/albumnav.js new file mode 100644 index 0000000..fc8cfe6 --- /dev/null +++ b/public/js/albumnav.js @@ -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")); diff --git a/templates/PhotosIndex.php b/templates/PhotosIndex.php index 5f353b1..044ef39 100644 --- a/templates/PhotosIndex.php +++ b/templates/PhotosIndex.php @@ -53,7 +53,8 @@ class PhotosIndex extends SubTemplate } echo ' - '; + + '; } protected function header($photos)