miniflux/ui/static/js/bootstrap.js

80 lines
3.3 KiB
JavaScript
Raw Normal View History

2019-07-18 05:27:39 +02:00
document.addEventListener("DOMContentLoaded", function () {
handleSubmitButtons();
2019-07-18 05:27:39 +02:00
if (!document.querySelector("body[data-disable-keyboard-shortcuts=true]")) {
let keyboardHandler = new KeyboardHandler();
2019-07-18 05:27:39 +02:00
keyboardHandler.on("g u", () => goToPage("unread"));
keyboardHandler.on("g b", () => goToPage("starred"));
keyboardHandler.on("g h", () => goToPage("history"));
keyboardHandler.on("g f", () => goToFeedOrFeeds());
keyboardHandler.on("g c", () => goToPage("categories"));
keyboardHandler.on("g s", () => goToPage("settings"));
keyboardHandler.on("ArrowLeft", () => goToPrevious());
keyboardHandler.on("ArrowRight", () => goToNext());
keyboardHandler.on("k", () => goToPrevious());
keyboardHandler.on("p", () => goToPrevious());
keyboardHandler.on("j", () => goToNext());
keyboardHandler.on("n", () => goToNext());
keyboardHandler.on("h", () => goToPage("previous"));
keyboardHandler.on("l", () => goToPage("next"));
keyboardHandler.on("o", () => openSelectedItem());
keyboardHandler.on("v", () => openOriginalLink());
keyboardHandler.on("m", () => handleEntryStatus());
keyboardHandler.on("A", () => markPageAsRead());
keyboardHandler.on("s", () => handleSaveEntry());
keyboardHandler.on("d", () => handleFetchOriginalContent());
keyboardHandler.on("f", () => handleBookmark());
keyboardHandler.on("?", () => showKeyboardShortcuts());
keyboardHandler.on("#", () => unsubscribeFromFeed());
keyboardHandler.on("/", (e) => setFocusToSearchInput(e));
keyboardHandler.on("Escape", () => ModalHandler.close());
keyboardHandler.listen();
}
2019-07-18 05:27:39 +02:00
let touchHandler = new TouchHandler();
touchHandler.listen();
2019-07-18 05:27:39 +02:00
onClick("a[data-save-entry]", () => handleSaveEntry());
onClick("a[data-toggle-bookmark]", () => handleBookmark());
onClick("a[data-fetch-content-entry]", () => handleFetchOriginalContent());
onClick("a[data-action=search]", (event) => setFocusToSearchInput(event));
2019-07-18 06:07:29 +02:00
onClick("a[data-action=markPageAsRead]", () => handleConfirmationMessage(event.target, () => markPageAsRead()));
2019-07-18 05:27:39 +02:00
onClick("a[data-toggle-status]", (event) => {
2018-08-29 05:44:34 +02:00
let currentItem = DomHelper.findParent(event.target, "entry");
2019-07-18 05:27:39 +02:00
if (!currentItem) {
2018-08-29 05:44:34 +02:00
currentItem = DomHelper.findParent(event.target, "item");
}
if (currentItem) {
2019-07-18 05:27:39 +02:00
toggleEntryStatus(currentItem);
}
});
2019-07-18 06:07:29 +02:00
onClick("a[data-confirm]", (event) => handleConfirmationMessage(event.target, (url, redirectURL) => {
let request = new RequestBuilder(url);
request.withCallback(() => {
if (redirectURL) {
window.location.href = redirectURL;
} else {
window.location.reload();
}
});
request.execute();
}));
if (document.documentElement.clientWidth < 600) {
2019-07-18 05:27:39 +02:00
onClick(".logo", () => toggleMainMenu());
onClick(".header nav li", (event) => onClickMainMenuListItem(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);
}
}
});