2013-10-15 04:38:07 +02:00
|
|
|
Miniflux.Nav = (function() {
|
|
|
|
|
|
|
|
function scrollPageTo(item)
|
|
|
|
{
|
|
|
|
var clientHeight = pageYOffset + document.documentElement.clientHeight;
|
|
|
|
var itemPosition = item.offsetTop + item.offsetHeight;
|
|
|
|
|
|
|
|
if (clientHeight - itemPosition < 0 || clientHeight - item.offsetTop > document.documentElement.clientHeight) {
|
|
|
|
window.scrollTo(0, item.offsetTop - 10);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function findNextItem()
|
|
|
|
{
|
|
|
|
var items = document.getElementsByTagName("article");
|
|
|
|
|
|
|
|
if (! document.getElementById("current-item")) {
|
|
|
|
|
|
|
|
items[0].id = "current-item";
|
|
|
|
scrollPageTo(items[0]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
for (var i = 0, ilen = items.length; i < ilen; i++) {
|
|
|
|
|
2014-11-10 17:19:08 +01:00
|
|
|
if (items[i].id === "current-item") {
|
2013-10-15 04:38:07 +02:00
|
|
|
|
|
|
|
if (i + 1 < ilen) {
|
2014-11-10 17:19:08 +01:00
|
|
|
items[i].id = "item-" + items[i].getAttribute("data-item-id");
|
|
|
|
|
2013-10-15 04:38:07 +02:00
|
|
|
items[i + 1].id = "current-item";
|
|
|
|
scrollPageTo(items[i + 1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function findPreviousItem()
|
|
|
|
{
|
|
|
|
var items = document.getElementsByTagName("article");
|
|
|
|
|
|
|
|
if (! document.getElementById("current-item")) {
|
|
|
|
|
|
|
|
items[items.length - 1].id = "current-item";
|
|
|
|
scrollPageTo(items[items.length - 1]);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
|
|
|
|
for (var i = items.length - 1; i >= 0; i--) {
|
|
|
|
|
2014-11-10 17:19:08 +01:00
|
|
|
if (items[i].id === "current-item") {
|
2013-10-15 04:38:07 +02:00
|
|
|
|
|
|
|
if (i - 1 >= 0) {
|
2014-11-10 17:19:08 +01:00
|
|
|
items[i].id = "item-" + items[i].getAttribute("data-item-id");
|
2013-10-15 04:38:07 +02:00
|
|
|
items[i - 1].id = "current-item";
|
|
|
|
scrollPageTo(items[i - 1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function isListing()
|
|
|
|
{
|
2016-07-31 00:21:01 +02:00
|
|
|
return !!document.getElementById("listing");
|
2013-10-15 04:38:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
OpenNextPage: function() {
|
|
|
|
var link = document.getElementById("next-page");
|
|
|
|
if (link) link.click();
|
|
|
|
},
|
|
|
|
OpenPreviousPage: function() {
|
|
|
|
var link = document.getElementById("previous-page");
|
|
|
|
if (link) link.click();
|
|
|
|
},
|
|
|
|
SelectNextItem: function() {
|
|
|
|
var link = document.getElementById("next-item");
|
|
|
|
|
|
|
|
if (link) {
|
|
|
|
link.click();
|
|
|
|
}
|
|
|
|
else if (isListing()) {
|
|
|
|
findNextItem();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
SelectPreviousItem: function() {
|
|
|
|
var link = document.getElementById("previous-item");
|
|
|
|
|
|
|
|
if (link) {
|
|
|
|
link.click();
|
|
|
|
}
|
|
|
|
else if (isListing()) {
|
|
|
|
findPreviousItem();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
ShowHelp: function() {
|
2016-03-06 16:23:19 +01:00
|
|
|
var help_layer = document.getElementById("help-layer");
|
|
|
|
help_layer.removeAttribute("class");
|
|
|
|
},
|
|
|
|
CloseHelp: function() {
|
|
|
|
var help_layer = document.getElementById("help-layer");
|
|
|
|
help_layer.setAttribute("class", "hide");
|
2013-10-15 04:38:07 +02:00
|
|
|
},
|
2016-05-04 02:15:20 +02:00
|
|
|
ShowSearch: function() {
|
|
|
|
document.getElementById("search-opener").setAttribute("class", "hide");
|
2016-09-27 17:35:48 +02:00
|
|
|
document.getElementById("search-form").removeAttribute("class");
|
|
|
|
document.getElementById("form-text").focus();
|
2016-05-04 02:15:20 +02:00
|
|
|
},
|
2016-11-10 14:22:48 +01:00
|
|
|
ToggleMenuMore: function () {
|
|
|
|
var menu = document.getElementById("menu-more");
|
2017-01-03 01:21:15 +01:00
|
|
|
|
|
|
|
if (menu.hasAttribute("class")) {
|
|
|
|
menu.removeAttribute("class");
|
|
|
|
} else {
|
|
|
|
menu.setAttribute("class", "hide");
|
|
|
|
}
|
2016-11-10 14:22:48 +01:00
|
|
|
},
|
2013-10-15 04:38:07 +02:00
|
|
|
IsListing: isListing
|
|
|
|
};
|
|
|
|
|
2016-05-04 02:15:20 +02:00
|
|
|
})();
|