select the previous article if the last selected article is hidden

This commit is contained in:
Mathias Kresin 2015-07-24 13:58:02 +02:00
parent 32658ef4e1
commit 64c65a9139
2 changed files with 24 additions and 17 deletions

32
assets/js/all.min.js vendored
View File

@ -1,19 +1,19 @@
var f=function(){var c=[];return{j:function(d,a){var b=d.querySelector("span.items-count");if(b){var c=d.getAttribute("data-feed-id"),k=d.querySelector("h2:first-of-type");k.className="loading-icon";var p=new XMLHttpRequest;p.onload=function(){k.className="";d.removeAttribute("data-feed-error");var c=d.querySelector(".feed-last-checked");c&&(c.innerHTML=c.getAttribute("data-after-update"));c=JSON.parse(this.responseText);c.result?b.innerHTML=c.items_count.items_unread+"/"+c.items_count.items_total:
d.setAttribute("data-feed-error","1");a?a(c):e.a()};p.open("POST","?action=refresh-feed&feed_id="+c,!0);p.send()}},l:function(){var d=Array.prototype.slice.call(document.querySelectorAll("article:not([data-feed-disabled])")),a=setInterval(function(){for(;0<d.length&&5>c.length;){var b=d.shift();c.push(parseInt(b.getAttribute("data-feed-id"),10));f.j(b,function(b){b=c.indexOf(b.feed_id);0<=b&&c.splice(b,1);0===d.length&&0===c.length&&(clearInterval(a),e.a())})}},100)}}}(),e=function(){function c(a){var b=
document.createEvent("MouseEvents");b.initEvent("mousedown",!0,!0);a.dispatchEvent(b);b=document.createEvent("MouseEvents");b.initEvent("mouseup",!0,!0);a.dispatchEvent(b);a.click()}function d(a){return item_id=a.getAttribute("data-item-id")}function a(a){if(a&&a.hasAttribute("data-reverse-label")){var b=a.innerHTML;a.innerHTML=a.getAttribute("data-reverse-label");a.setAttribute("data-reverse-label",b)}}function b(g){if("read"!==g.getAttribute("data-item-status")){if(g.getAttribute("data-hide"))m(g);
else{g.setAttribute("data-item-status","read");var b=g.querySelector("a.mark");a(b);(g=g.querySelector("a.mark"))&&g.setAttribute("data-action","mark-unread")}l--}}function m(a){"mouse"!==n.c&&t.f();a.parentNode.removeChild(a);q--}function k(){-1<window.location.href.indexOf("nothing_to_read=1")&&0<l?window.location.href="?action=unread":0===q&&window.location.reload();var a=document.getElementById("page-counter");a&&(a.textContent=q||"");document.getElementById("nav-counter").textContent=l||"";var b=
document.querySelector("div.page-header h2:first-of-type");if(b)pageHeading=b.firstChild.nodeValue;else if(b=document.querySelector("article.item h1:first-of-type")){document.title=b.textContent;return}switch(document.querySelector("section.page").getAttribute("data-item-page")){case "unread":document.title="Miniflux ("+l+")";break;case "feed-items":document.title="("+q+") "+pageHeading;break;default:document.title=a?pageHeading+" ("+q+")":pageHeading}}function p(a){var c=d(a),h=new XMLHttpRequest;
h.onload=function(){t.b()&&(b(a),k())};h.open("POST","?action=mark-item-read&id="+c,!0);h.send()}function w(b){var c=d(b),h=new XMLHttpRequest;h.onload=function(){if(t.b()){if("unread"!==b.getAttribute("data-item-status")){if(b.getAttribute("data-hide"))m(b);else{b.setAttribute("data-item-status","unread");var c=b.querySelector("a.mark");a(c);(c=b.querySelector("a.mark"))&&c.setAttribute("data-action","mark-read")}l++}k()}};h.open("POST","?action=mark-item-unread&id="+c,!0);h.send()}var u=[],r=!1,
l=function(){var a=document.getElementById("nav-counter");if(a)return counter=parseInt(a.textContent,10)||0}(),q=function(){var a=document.getElementById("page-counter");if(a)return counter=parseInt(a.textContent,10)||0}();return{v:p,A:w,w:function(a){var b=d(a),c=new XMLHttpRequest;c.onload=function(){t.b()&&(m(a),"unread"===a.getAttribute("data-item-status")&&l--,k())};c.open("POST","?action=mark-item-removed&id="+b,!0);c.send()},i:function(b){var c=d(b),h="1"===b.getAttribute("data-item-bookmark")?
"0":"1",v=new XMLHttpRequest;v.onload=function(){var c=document.querySelector("section.page");if(t.b()&&"bookmarks"===c.getAttribute("data-item-page"))m(b),k();else if(b.setAttribute("data-item-bookmark",h),t.b())c=b.querySelector("a.bookmark"),a(c);else if((c=b.querySelector("a.bookmark-icon"))&&c.hasAttribute("data-reverse-title")){var d=c.getAttribute("title");c.setAttribute("title",c.getAttribute("data-reverse-title"));c.setAttribute("data-reverse-title",d)}};v.open("POST","?action=bookmark&id="+
c+"&value="+h,!0);v.send()},J:function(a){var b=a.getAttribute("data-item-status");"read"===b?w(a):"unread"===b&&p(a)},H:function(a){(a=a.querySelector("a.show"))&&c(a)},D:function(a){(a=a.querySelector("a.original"))&&c(a)},g:function(a){var b=document.getElementById("download-item");if(b){b.innerHTML=" "+b.getAttribute("data-before-message");b.className="loading-icon";var c=new XMLHttpRequest;c.onload=function(){var a=JSON.parse(c.responseText);b.className="";if(a.result){var d=document.getElementById("item-content");
d&&(d.innerHTML=a.content);b.innerHTML=b.getAttribute("data-after-message")}else b.innerHTML=b.getAttribute("data-failure-message")};a=d(a);c.open("POST","?action=download-item&id="+a,!0);c.send()}},B:function(a){var c=new XMLHttpRequest;c.onload=function(){for(var a=document.getElementsByTagName("article"),c=0,d=a.length;c<d;c++)b(a[c]);l=this.responseText;k()};c.open("POST","?action=mark-feed-as-read&feed_id="+a,!0);c.send()},K:function(){for(var a=["#current-item h1","#item-content","#listing #current-item h2",
"#listing #current-item .preview"],b=0;b<a.length;b++){var c=document.querySelector(a[b]);c&&(c.dir=""==c.dir?"rtl":"")}},L:function(){return r},a:function(){if(!document.hidden||!r){var a=new XMLHttpRequest;a.onload=function(){var a=0===u.length,b=!1,c=JSON.parse(this.responseText),d;for(d in c.feeds){var g=c.feeds[d];if(!u.hasOwnProperty(d)||g.time>u[d])u[d]=g.time,"unread"===g.status&&(b=!0)}document.hidden||c.nbUnread===l&&!r?document.hidden&&!a&&b&&(r=!0,document.title="\u21bb "+document.title):
(r=!1,l=c.nbUnread,k())};a.open("POST","?action=latest-feeds-items",!0);a.send()}}}}(),n=function(){function c(a){if(63!==a.keyCode&&63!==a.which&&(a.ctrlKey||a.shiftKey||a.altKey||a.metaKey))return!0;a=a.target||a.srcElement;return"INPUT"===a.tagName||"TEXTAREA"===a.tagName?!0:!1}var d=[];return{c:"",s:function(){document.onclick=function(a){a.target.hasAttribute("data-action")&&"original"!==a.target.className&&a.preventDefault()};document.onmouseup=function(a){if(2!==a.button)if("INPUT"===a.target.nodeName&&
"auto-select"===a.target.className)a.target.select();else{var b=a.target.getAttribute("data-action");if(b){n.c="mouse";a:{for(element=a.target;element&&element.parentNode;)if(element=element.parentNode,element.tagName&&"article"===element.tagName.toLowerCase()){a=element;break a}a=void 0}switch(b){case "refresh-all":f.l();break;case "refresh-feed":a&&f.j(a);break;case "mark-read":a&&e.v(a);break;case "mark-unread":a&&e.A(a);break;case "mark-removed":a&&e.w(a);break;case "bookmark":a&&e.i(a);break;
case "download-item":a&&e.g(a);break;case "mark-feed-read":b=document.getElementById("listing").getAttribute("data-feed-id"),e.B(b)}}}}},o:function(){document.onkeypress=function(a){if(!c(a))if(n.c="keyboard",d.push(a.key||a.which),"g"===d[0]||103===d[0])switch(d[1]){case void 0:break;case "u":case 117:window.location.href="?action=unread";d=[];break;case "b":case 98:window.location.href="?action=bookmarks";d=[];break;case "h":case 104:window.location.href="?action=history";d=[];break;case "s":case 115:window.location.href=
"?action=feeds";d=[];break;case "p":case 112:window.location.href="?action=config";d=[];break;default:d=[]}else{d=[];var b=document.getElementById("current-item");switch(a.key||a.which){case "d":case 100:b&&e.g(b);break;case "p":case 112:case "k":case 107:t.h();break;case "n":case 110:case "j":case 106:t.f();break;case "v":case 118:b&&e.D(b);break;case "o":case 111:b&&e.H(b);break;case "m":case 109:b&&e.J(b);break;case "f":case 102:b&&e.i(b);break;case "h":case 104:t.F();break;case "l":case 108:t.C();
break;case "r":case 114:f.l();break;case "?":case 63:t.I();break;case "z":case 122:e.K()}}};document.onkeydown=function(a){if(!c(a))switch(n.c="keyboard",a.key||a.which){case "ArrowLeft":case "Left":case 37:t.h();break;case "ArrowRight":case "Right":case 39:t.f()}}},u:function(){document.addEventListener("visibilitychange",function(){!document.hidden&&e.L()&&e.a()})}}}(),t=function(){function c(a){var b=pageYOffset+document.documentElement.clientHeight;(0>b-(a.offsetTop+a.offsetHeight)||b-a.offsetTop>
document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function d(){return document.getElementById("listing")?!0:!1}return{C:function(){var a=document.getElementById("next-page");a&&a.click()},F:function(){var a=document.getElementById("previous-page");a&&a.click()},f:function(){var a=document.getElementById("next-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=0,m=a.length;b<m;b++){if("current-item"===
a[b].id){b+1<m&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b+1].id="current-item",c(a[b+1]));break}}else a[0].id="current-item",c(a[0])},h:function(){var a=document.getElementById("previous-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=a.length-1;0<=b;b--){if("current-item"===a[b].id){0<=b-1&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b-1].id="current-item",c(a[b-1]));break}}else a[a.length-1].id=
"current-item",c(a[a.length-1])},I:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},b:d}}();({M:function(){},G:function(){n.o();n.s();n.u();this.m()},m:function(){var c=new XMLHttpRequest;c.onload=function(){var c=JSON.parse(this.responseText);0<c.frontend_updatecheck_interval&&(e.a(),setInterval(function(){e.a()},6E4*c.frontend_updatecheck_interval))};c.open("POST","?action=get-config",!0);c.send(JSON.stringify(["frontend_updatecheck_interval"]))}}).G();
else{g.setAttribute("data-item-status","read");var b=g.querySelector("a.mark");a(b);(g=g.querySelector("a.mark"))&&g.setAttribute("data-action","mark-unread")}l--}}function m(a){if("mouse"!==n.c){var b=document.getElementsByTagName("article");"current-item"===b[b.length-1].id?t.g():t.f()}a.parentNode.removeChild(a);q--}function k(){-1<window.location.href.indexOf("nothing_to_read=1")&&0<l?window.location.href="?action=unread":0===q&&window.location.reload();var a=document.getElementById("page-counter");
a&&(a.textContent=q||"");document.getElementById("nav-counter").textContent=l||"";var b=document.querySelector("div.page-header h2:first-of-type");if(b)pageHeading=b.firstChild.nodeValue;else if(b=document.querySelector("article.item h1:first-of-type")){document.title=b.textContent;return}switch(document.querySelector("section.page").getAttribute("data-item-page")){case "unread":document.title="Miniflux ("+l+")";break;case "feed-items":document.title="("+q+") "+pageHeading;break;default:document.title=
a?pageHeading+" ("+q+")":pageHeading}}function p(a){var c=d(a),h=new XMLHttpRequest;h.onload=function(){t.b()&&(b(a),k())};h.open("POST","?action=mark-item-read&id="+c,!0);h.send()}function w(b){var c=d(b),h=new XMLHttpRequest;h.onload=function(){if(t.b()){if("unread"!==b.getAttribute("data-item-status")){if(b.getAttribute("data-hide"))m(b);else{b.setAttribute("data-item-status","unread");var c=b.querySelector("a.mark");a(c);(c=b.querySelector("a.mark"))&&c.setAttribute("data-action","mark-read")}l++}k()}};
h.open("POST","?action=mark-item-unread&id="+c,!0);h.send()}var u=[],r=!1,l=function(){var a=document.getElementById("nav-counter");if(a)return counter=parseInt(a.textContent,10)||0}(),q=function(){var a=document.getElementById("page-counter");if(a)return counter=parseInt(a.textContent,10)||0}();return{v:p,A:w,w:function(a){var b=d(a),c=new XMLHttpRequest;c.onload=function(){t.b()&&(m(a),"unread"===a.getAttribute("data-item-status")&&l--,k())};c.open("POST","?action=mark-item-removed&id="+b,!0);c.send()},
i:function(b){var c=d(b),h="1"===b.getAttribute("data-item-bookmark")?"0":"1",v=new XMLHttpRequest;v.onload=function(){var c=document.querySelector("section.page");if(t.b()&&"bookmarks"===c.getAttribute("data-item-page"))m(b),k();else if(b.setAttribute("data-item-bookmark",h),t.b())c=b.querySelector("a.bookmark"),a(c);else if((c=b.querySelector("a.bookmark-icon"))&&c.hasAttribute("data-reverse-title")){var d=c.getAttribute("title");c.setAttribute("title",c.getAttribute("data-reverse-title"));c.setAttribute("data-reverse-title",
d)}};v.open("POST","?action=bookmark&id="+c+"&value="+h,!0);v.send()},J:function(a){var b=a.getAttribute("data-item-status");"read"===b?w(a):"unread"===b&&p(a)},H:function(a){(a=a.querySelector("a.show"))&&c(a)},D:function(a){(a=a.querySelector("a.original"))&&c(a)},h:function(a){var b=document.getElementById("download-item");if(b){b.innerHTML=" "+b.getAttribute("data-before-message");b.className="loading-icon";var c=new XMLHttpRequest;c.onload=function(){var a=JSON.parse(c.responseText);b.className=
"";if(a.result){var d=document.getElementById("item-content");d&&(d.innerHTML=a.content);b.innerHTML=b.getAttribute("data-after-message")}else b.innerHTML=b.getAttribute("data-failure-message")};a=d(a);c.open("POST","?action=download-item&id="+a,!0);c.send()}},B:function(a){var c=new XMLHttpRequest;c.onload=function(){for(var a=document.getElementsByTagName("article"),c=0,d=a.length;c<d;c++)b(a[c]);l=this.responseText;k()};c.open("POST","?action=mark-feed-as-read&feed_id="+a,!0);c.send()},K:function(){for(var a=
["#current-item h1","#item-content","#listing #current-item h2","#listing #current-item .preview"],b=0;b<a.length;b++){var c=document.querySelector(a[b]);c&&(c.dir=""==c.dir?"rtl":"")}},L:function(){return r},a:function(){if(!document.hidden||!r){var a=new XMLHttpRequest;a.onload=function(){var a=0===u.length,b=!1,c=JSON.parse(this.responseText),d;for(d in c.feeds){var g=c.feeds[d];if(!u.hasOwnProperty(d)||g.time>u[d])u[d]=g.time,"unread"===g.status&&(b=!0)}document.hidden||c.nbUnread===l&&!r?document.hidden&&
!a&&b&&(r=!0,document.title="\u21bb "+document.title):(r=!1,l=c.nbUnread,k())};a.open("POST","?action=latest-feeds-items",!0);a.send()}}}}(),n=function(){function c(a){if(63!==a.keyCode&&63!==a.which&&(a.ctrlKey||a.shiftKey||a.altKey||a.metaKey))return!0;a=a.target||a.srcElement;return"INPUT"===a.tagName||"TEXTAREA"===a.tagName?!0:!1}var d=[];return{c:"",s:function(){document.onclick=function(a){a.target.hasAttribute("data-action")&&"original"!==a.target.className&&a.preventDefault()};document.onmouseup=
function(a){if(2!==a.button)if("INPUT"===a.target.nodeName&&"auto-select"===a.target.className)a.target.select();else{var b=a.target.getAttribute("data-action");if(b){n.c="mouse";a:{for(element=a.target;element&&element.parentNode;)if(element=element.parentNode,element.tagName&&"article"===element.tagName.toLowerCase()){a=element;break a}a=void 0}switch(b){case "refresh-all":f.l();break;case "refresh-feed":a&&f.j(a);break;case "mark-read":a&&e.v(a);break;case "mark-unread":a&&e.A(a);break;case "mark-removed":a&&
e.w(a);break;case "bookmark":a&&e.i(a);break;case "download-item":a&&e.h(a);break;case "mark-feed-read":b=document.getElementById("listing").getAttribute("data-feed-id"),e.B(b)}}}}},o:function(){document.onkeypress=function(a){if(!c(a))if(n.c="keyboard",d.push(a.key||a.which),"g"===d[0]||103===d[0])switch(d[1]){case void 0:break;case "u":case 117:window.location.href="?action=unread";d=[];break;case "b":case 98:window.location.href="?action=bookmarks";d=[];break;case "h":case 104:window.location.href=
"?action=history";d=[];break;case "s":case 115:window.location.href="?action=feeds";d=[];break;case "p":case 112:window.location.href="?action=config";d=[];break;default:d=[]}else{d=[];var b=document.getElementById("current-item");switch(a.key||a.which){case "d":case 100:b&&e.h(b);break;case "p":case 112:case "k":case 107:t.g();break;case "n":case 110:case "j":case 106:t.f();break;case "v":case 118:b&&e.D(b);break;case "o":case 111:b&&e.H(b);break;case "m":case 109:b&&e.J(b);break;case "f":case 102:b&&
e.i(b);break;case "h":case 104:t.F();break;case "l":case 108:t.C();break;case "r":case 114:f.l();break;case "?":case 63:t.I();break;case "z":case 122:e.K()}}};document.onkeydown=function(a){if(!c(a))switch(n.c="keyboard",a.key||a.which){case "ArrowLeft":case "Left":case 37:t.g();break;case "ArrowRight":case "Right":case 39:t.f()}}},u:function(){document.addEventListener("visibilitychange",function(){!document.hidden&&e.L()&&e.a()})}}}(),t=function(){function c(a){var b=pageYOffset+document.documentElement.clientHeight;
(0>b-(a.offsetTop+a.offsetHeight)||b-a.offsetTop>document.documentElement.clientHeight)&&window.scrollTo(0,a.offsetTop-10)}function d(){return document.getElementById("listing")?!0:!1}return{C:function(){var a=document.getElementById("next-page");a&&a.click()},F:function(){var a=document.getElementById("previous-page");a&&a.click()},f:function(){var a=document.getElementById("next-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=
0,m=a.length;b<m;b++){if("current-item"===a[b].id){b+1<m&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b+1].id="current-item",c(a[b+1]));break}}else a[0].id="current-item",c(a[0])},g:function(){var a=document.getElementById("previous-item");if(a)a.click();else if(d())if(a=document.getElementsByTagName("article"),document.getElementById("current-item"))for(var b=a.length-1;0<=b;b--){if("current-item"===a[b].id){0<=b-1&&(a[b].id="item-"+a[b].getAttribute("data-item-id"),a[b-1].id="current-item",
c(a[b-1]));break}}else a[a.length-1].id="current-item",c(a[a.length-1])},I:function(){open("?action=show-help","Help","width=320,height=450,location=no,scrollbars=no,status=no,toolbar=no")},b:d}}();({M:function(){},G:function(){n.o();n.s();n.u();this.m()},m:function(){var c=new XMLHttpRequest;c.onload=function(){var c=JSON.parse(this.responseText);0<c.frontend_updatecheck_interval&&(e.a(),setInterval(function(){e.a()},6E4*c.frontend_updatecheck_interval))};c.open("POST","?action=get-config",!0);c.send(JSON.stringify(["frontend_updatecheck_interval"]))}}).G();

View File

@ -109,7 +109,14 @@ Miniflux.Item = (function() {
function hideItem(item)
{
if (Miniflux.Event.lastEventType !== "mouse") {
Miniflux.Nav.SelectNextItem();
var items = document.getElementsByTagName("article");
if (items[items.length-1].id === "current-item") {
Miniflux.Nav.SelectPreviousItem();
}
else {
Miniflux.Nav.SelectNextItem();
}
}
item.parentNode.removeChild(item);