2016-09-03 21:33:48 +02:00
|
|
|
function enableKeyDownNavigation() {
|
|
|
|
document.addEventListener("keydown", function (event) {
|
|
|
|
if (event.keyCode == 37) {
|
2023-03-20 18:30:30 +01:00
|
|
|
var target = document.querySelector("ul.pagination > :first-child a");
|
2016-09-03 21:33:48 +02:00
|
|
|
if (target && target.href) {
|
|
|
|
event.preventDefault();
|
|
|
|
document.location.href = target.href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (event.keyCode == 39) {
|
2023-03-20 18:30:30 +01:00
|
|
|
var target = document.querySelector("ul.pagination > :last-child a");
|
2016-09-03 21:33:48 +02:00
|
|
|
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"));
|