do not deselect the current item if no successor/predecessors exists

When using the previous shortcut with the first article selected, the selection
is removed and no article is the current-item. Using the shortcut again, the
last article is the current-item (as expected on a new loaded page).

The same applies to the combination of last article and next shortcut.
This commit is contained in:
Mathias Kresin 2014-11-10 17:19:08 +01:00
parent 3dae99ac27
commit a1b8c5b160
2 changed files with 7 additions and 8 deletions

View File

@ -15,5 +15,5 @@ break;case "mark-feed-read":c.preventDefault(),Miniflux.Item.MarkListingAsRead("
[];break;case 98:window.location.href="?action=bookmarks";e=[];break;case 104:window.location.href="?action=history";e=[];break;case 115:window.location.href="?action=feeds";e=[];break;case 112:window.location.href="?action=config";e=[];break;default:e=[]}else switch(e=[],b=document.getElementById("current-item"),c.keyCode||c.which){case 100:Miniflux.Item.DownloadContent(b);break;case 112:case 107:Miniflux.Nav.SelectPreviousItem();break;case 110:case 106:Miniflux.Nav.SelectNextItem();break;case 118:Miniflux.Item.OpenOriginal(b);
break;case 111:Miniflux.Item.Show(b);break;case 109:Miniflux.Item.SwitchStatus(b);break;case 102:Miniflux.Item.SwitchBookmark(b);break;case 104:Miniflux.Nav.OpenPreviousPage();break;case 108:Miniflux.Nav.OpenNextPage();break;case 114:Miniflux.Feed.UpdateAll();break;case 63:Miniflux.Nav.ShowHelp()}}}}}}();
Miniflux.Nav=function(){function e(b){var a=pageYOffset+document.documentElement.clientHeight;(0>a-(b.offsetTop+b.offsetHeight)||a-b.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,b.offsetTop-10)}function c(){return document.getElementById("listing")?!0:!1}return{OpenNextPage:function(){var b=document.getElementById("next-page");b&&b.click()},OpenPreviousPage:function(){var b=document.getElementById("previous-page");b&&b.click()},SelectNextItem:function(){var b=document.getElementById("next-item");
if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=0,g=b.length;a<g;a++){if("current-item"==b[a].id){b[a].id="item-"+b[a].getAttribute("data-item-id");a+1<g&&(b[a+1].id="current-item",e(b[a+1]));break}}else b[0].id="current-item",e(b[0])},SelectPreviousItem:function(){var b=document.getElementById("previous-item");if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=
b.length-1;0<=a;a--){if("current-item"==b[a].id){b[a].id="item-"+b[a].getAttribute("data-item-id");0<=a-1&&(b[a-1].id="current-item",e(b[a-1]));break}}else b[b.length-1].id="current-item",e(b[b.length-1])},ShowHelp:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},IsListing:c}}();Miniflux.App.Run();
if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=0,g=b.length;a<g;a++){if("current-item"===b[a].id){a+1<g&&(b[a].id="item-"+b[a].getAttribute("data-item-id"),b[a+1].id="current-item",e(b[a+1]));break}}else b[0].id="current-item",e(b[0])},SelectPreviousItem:function(){var b=document.getElementById("previous-item");if(b)b.click();else if(c())if(b=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var a=
b.length-1;0<=a;a--){if("current-item"===b[a].id){0<=a-1&&(b[a].id="item-"+b[a].getAttribute("data-item-id"),b[a-1].id="current-item",e(b[a-1]));break}}else b[b.length-1].id="current-item",e(b[b.length-1])},ShowHelp:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},IsListing:c}}();Miniflux.App.Run();

View File

@ -23,11 +23,11 @@ Miniflux.Nav = (function() {
for (var i = 0, ilen = items.length; i < ilen; i++) {
if (items[i].id == "current-item") {
items[i].id = "item-" + items[i].getAttribute("data-item-id");
if (items[i].id === "current-item") {
if (i + 1 < ilen) {
items[i].id = "item-" + items[i].getAttribute("data-item-id");
items[i + 1].id = "current-item";
scrollPageTo(items[i + 1]);
}
@ -51,11 +51,10 @@ Miniflux.Nav = (function() {
for (var i = items.length - 1; i >= 0; i--) {
if (items[i].id == "current-item") {
items[i].id = "item-" + items[i].getAttribute("data-item-id");
if (items[i].id === "current-item") {
if (i - 1 >= 0) {
items[i].id = "item-" + items[i].getAttribute("data-item-id");
items[i - 1].id = "current-item";
scrollPageTo(items[i - 1]);
}