Fixed A/D in pager not respecting result boundary

This commit is contained in:
Marcin Kurczewski 2014-11-04 19:00:47 +01:00
parent 26d4686795
commit 248d20ede5
2 changed files with 14 additions and 2 deletions

View file

@ -33,13 +33,17 @@ App.Pager = function(
function prevPage() {
if (pageNumber > 1) {
setPage(pageNumber - 1);
return true;
}
return false;
}
function nextPage() {
if (pageNumber < totalPages) {
setPage(pageNumber + 1);
return true;
}
return false;
}
function setPage(newPageNumber) {

View file

@ -62,8 +62,16 @@ App.Presenters.PagerPresenter = function(
.fail(loaded);
if (!endlessScroll) {
keyboard.keydown('a', function() { syncUrl({page: pager.getPage() - 1}); });
keyboard.keydown('d', function() { syncUrl({page: pager.getPage() + 1}); });
keyboard.keydown('a', function() {
if (pager.prevPage()) {
syncUrl({page: pager.getPage()});
}
});
keyboard.keydown('d', function() {
if (pager.nextPage()) {
syncUrl({page: pager.getPage()});
}
});
}
}