2018-07-06 07:18:51 +02:00
|
|
|
document.addEventListener("DOMContentLoaded", function() {
|
|
|
|
FormHandler.handleSubmitButtons();
|
|
|
|
|
|
|
|
let navHandler = new NavHandler();
|
2019-04-29 03:20:46 +02:00
|
|
|
|
|
|
|
if (! document.querySelector("body[data-disable-keyboard-shortcuts=true]")) {
|
|
|
|
let keyboardHandler = new KeyboardHandler();
|
|
|
|
keyboardHandler.on("g u", () => navHandler.goToPage("unread"));
|
|
|
|
keyboardHandler.on("g b", () => navHandler.goToPage("starred"));
|
|
|
|
keyboardHandler.on("g h", () => navHandler.goToPage("history"));
|
|
|
|
keyboardHandler.on("g f", () => navHandler.goToFeedOrFeeds());
|
|
|
|
keyboardHandler.on("g c", () => navHandler.goToPage("categories"));
|
|
|
|
keyboardHandler.on("g s", () => navHandler.goToPage("settings"));
|
|
|
|
keyboardHandler.on("ArrowLeft", () => navHandler.goToPrevious());
|
|
|
|
keyboardHandler.on("ArrowRight", () => navHandler.goToNext());
|
2019-05-26 20:02:52 +02:00
|
|
|
keyboardHandler.on("k", () => navHandler.goToPrevious());
|
2019-04-29 03:20:46 +02:00
|
|
|
keyboardHandler.on("p", () => navHandler.goToPrevious());
|
2019-05-26 20:02:52 +02:00
|
|
|
keyboardHandler.on("j", () => navHandler.goToNext());
|
2019-04-29 03:20:46 +02:00
|
|
|
keyboardHandler.on("n", () => navHandler.goToNext());
|
|
|
|
keyboardHandler.on("h", () => navHandler.goToPage("previous"));
|
|
|
|
keyboardHandler.on("l", () => navHandler.goToPage("next"));
|
|
|
|
keyboardHandler.on("o", () => navHandler.openSelectedItem());
|
|
|
|
keyboardHandler.on("v", () => navHandler.openOriginalLink());
|
|
|
|
keyboardHandler.on("m", () => navHandler.toggleEntryStatus());
|
|
|
|
keyboardHandler.on("A", () => {
|
|
|
|
let element = document.querySelector("a[data-on-click=markPageAsRead]");
|
|
|
|
navHandler.markPageAsRead(element.dataset.showOnlyUnread || false);
|
|
|
|
});
|
|
|
|
keyboardHandler.on("s", () => navHandler.saveEntry());
|
|
|
|
keyboardHandler.on("d", () => navHandler.fetchOriginalContent());
|
|
|
|
keyboardHandler.on("f", () => navHandler.toggleBookmark());
|
|
|
|
keyboardHandler.on("?", () => navHandler.showKeyboardShortcuts());
|
|
|
|
keyboardHandler.on("#", () => navHandler.unsubscribeFromFeed());
|
|
|
|
keyboardHandler.on("/", (e) => navHandler.setFocusToSearchInput(e));
|
|
|
|
keyboardHandler.on("Escape", () => ModalHandler.close());
|
|
|
|
keyboardHandler.listen();
|
|
|
|
}
|
2018-07-06 07:18:51 +02:00
|
|
|
|
2019-03-09 14:00:26 +01:00
|
|
|
let touchHandler = new TouchHandler(navHandler);
|
|
|
|
touchHandler.listen();
|
|
|
|
|
2018-07-06 07:18:51 +02:00
|
|
|
let mouseHandler = new MouseHandler();
|
|
|
|
mouseHandler.onClick("a[data-save-entry]", (event) => {
|
|
|
|
EntryHandler.saveEntry(event.target);
|
|
|
|
});
|
|
|
|
|
|
|
|
mouseHandler.onClick("a[data-toggle-bookmark]", (event) => {
|
|
|
|
EntryHandler.toggleBookmark(event.target);
|
|
|
|
});
|
|
|
|
|
|
|
|
mouseHandler.onClick("a[data-toggle-status]", (event) => {
|
2018-08-29 05:44:34 +02:00
|
|
|
let currentItem = DomHelper.findParent(event.target, "entry");
|
|
|
|
if (! currentItem) {
|
|
|
|
currentItem = DomHelper.findParent(event.target, "item");
|
|
|
|
}
|
|
|
|
|
2018-07-06 07:18:51 +02:00
|
|
|
if (currentItem) {
|
|
|
|
EntryHandler.toggleEntryStatus(currentItem);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mouseHandler.onClick("a[data-fetch-content-entry]", (event) => {
|
|
|
|
EntryHandler.fetchOriginalContent(event.target);
|
|
|
|
});
|
|
|
|
|
2019-04-05 03:59:04 +02:00
|
|
|
mouseHandler.onClick("a[data-on-click=markPageAsRead]", (event) => {
|
|
|
|
navHandler.markPageAsRead(event.target.dataset.showOnlyUnread || false);
|
|
|
|
});
|
2018-08-25 21:21:54 +02:00
|
|
|
|
2018-07-06 07:18:51 +02:00
|
|
|
mouseHandler.onClick("a[data-confirm]", (event) => {
|
|
|
|
(new ConfirmHandler()).handle(event);
|
|
|
|
});
|
|
|
|
|
|
|
|
mouseHandler.onClick("a[data-action=search]", (event) => {
|
|
|
|
navHandler.setFocusToSearchInput(event);
|
|
|
|
});
|
|
|
|
|
2018-10-09 03:49:15 +02:00
|
|
|
mouseHandler.onClick("a[data-link-state=flip]", (event) => {
|
|
|
|
LinkStateHandler.flip(event.target);
|
|
|
|
}, true);
|
|
|
|
|
2018-07-06 07:18:51 +02:00
|
|
|
if (document.documentElement.clientWidth < 600) {
|
|
|
|
let menuHandler = new MenuHandler();
|
|
|
|
mouseHandler.onClick(".logo", () => menuHandler.toggleMainMenu());
|
|
|
|
mouseHandler.onClick(".header nav li", (event) => menuHandler.clickMenuListItem(event));
|
|
|
|
}
|
2018-07-16 06:51:09 +02:00
|
|
|
|
|
|
|
if ("serviceWorker" in navigator) {
|
|
|
|
let scriptElement = document.getElementById("service-worker-script");
|
|
|
|
if (scriptElement) {
|
|
|
|
navigator.serviceWorker.register(scriptElement.src);
|
|
|
|
}
|
|
|
|
}
|
2018-07-06 07:18:51 +02:00
|
|
|
});
|