Fix bug where we would not check if there was actually a page to navigate to when using arrow keys

This commit is contained in:
Mathieu David 2015-12-30 17:19:43 +01:00
parent 98cd2f0c27
commit ae6334f358
1 changed files with 6 additions and 2 deletions

View File

@ -32,11 +32,15 @@ $( document ).ready(function() {
switch (e.keyCode) { switch (e.keyCode) {
case KEY_CODES.NEXT_KEY: case KEY_CODES.NEXT_KEY:
e.preventDefault(); e.preventDefault();
window.location.href = $('.nav-chapters.next').attr('href'); if($('.nav-chapters.next').length) {
window.location.href = $('.nav-chapters.next').attr('href');
}
break; break;
case KEY_CODES.PREVIOUS_KEY: case KEY_CODES.PREVIOUS_KEY:
e.preventDefault(); e.preventDefault();
window.location.href = $('.nav-chapters.previous').attr('href'); if($('.nav-chapters.previous').length) {
window.location.href = $('.nav-chapters.previous').attr('href');
}
break; break;
} }
}); });