aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/extra.js26
-rw-r--r--p/scripts/feed.js11
-rw-r--r--p/scripts/main.js40
3 files changed, 59 insertions, 18 deletions
diff --git a/p/scripts/extra.js b/p/scripts/extra.js
index 52a480c9a..707719430 100644
--- a/p/scripts/extra.js
+++ b/p/scripts/extra.js
@@ -145,6 +145,9 @@ function init_archiving(parent) {
const freshrssSliderLoadEvent = new Event('freshrss:slider-load');
function open_slider_listener(ev) {
+ if (ev.ctrlKey || ev.shiftKey) {
+ return;
+ }
const a = ev.target.closest('.open-slider');
if (a) {
if (!context.ajax_loading) {
@@ -175,21 +178,24 @@ function open_slider_listener(ev) {
function init_slider(slider) {
window.onclick = open_slider_listener;
- const closer = document.getElementById('close-slider');
- closer.addEventListener('click', function (ev) {
- if (data_leave_validation(slider) || confirm(context.i18n.confirmation_default)) {
- slider.querySelectorAll('form').forEach(function (f) { f.reset(); });
- document.documentElement.classList.remove('slider-active');
- return true;
- } else {
- return false;
- }
- });
+ document.getElementById('close-slider').addEventListener('click', close_slider_listener);
+ document.querySelector('#slider .toggle_aside').addEventListener('click', close_slider_listener);
if (slider.children.length > 0) {
slider.dispatchEvent(freshrssSliderLoadEvent);
}
}
+
+function close_slider_listener(ev) {
+ const slider = document.getElementById('slider');
+ if (data_leave_validation(slider) || confirm(context.i18n.confirmation_default)) {
+ slider.querySelectorAll('form').forEach(function (f) { f.reset(); });
+ document.documentElement.classList.remove('slider-active');
+ return true;
+ } else {
+ return false;
+ }
+}
// </slider>
// overwrites the href attribute from the url input
diff --git a/p/scripts/feed.js b/p/scripts/feed.js
index 1a6833db6..29af2a3ea 100644
--- a/p/scripts/feed.js
+++ b/p/scripts/feed.js
@@ -88,10 +88,17 @@ function init_disable_elements_on_update(parent) {
function init_select_show(parent) {
const listener = (select) => {
const options = select.querySelectorAll('option[data-show]');
+ const shows = {}; // To allow multiple options to show the same element
for (const option of options) {
- const elem = document.getElementById(option.dataset.show);
+ if (!shows[option.dataset.show]) {
+ shows[option.dataset.show] = option.selected;
+ }
+ }
+
+ for (const show in shows) {
+ const elem = document.getElementById(show);
if (elem) {
- elem.style.display = option.selected ? 'block' : 'none';
+ elem.style.display = shows[show] ? 'block' : 'none';
}
}
};
diff --git a/p/scripts/main.js b/p/scripts/main.js
index 268fd2858..bca6c2407 100644
--- a/p/scripts/main.js
+++ b/p/scripts/main.js
@@ -264,6 +264,7 @@ function send_mark_read_queue(queue, asRead, callback) {
incUnreadsTag(tagId, (asRead ? -1 : 1) * json.tags[tagId].length);
}
}
+ toggle_bigMarkAsRead_button();
onScroll();
if (callback) {
callback();
@@ -1012,11 +1013,13 @@ function init_shortcuts() {
}
const link_go_website = document.querySelector('.flux.current a.go_website');
- const newWindow = window.open();
- if (link_go_website && newWindow) {
- newWindow.opener = null;
- newWindow.location = link_go_website.href;
- ev.preventDefault();
+ if (link_go_website) {
+ const newWindow = window.open();
+ if (newWindow) {
+ newWindow.opener = null;
+ newWindow.location = link_go_website.href;
+ ev.preventDefault();
+ }
}
return;
}
@@ -1101,6 +1104,12 @@ function init_stream(stream) {
return false;
}
+ el = ev.target.closest('.item.share > a[data-type="email-webmail-firefox-fix"]');
+ if (el) {
+ window.open(el.href);
+ return false;
+ }
+
el = ev.target.closest('.item.share > a[href="POST"]');
if (el) { // Share by POST
const f = el.parentElement.querySelector('form');
@@ -1562,7 +1571,7 @@ function notifs_html5_show(nb, nb_new) {
const notification = new window.Notification(context.i18n.notif_title_articles, {
icon: '../themes/icons/favicon-256-padding.png',
- body: context.i18n.notif_body_new_articles.replace('%d', nb_new) + ' ' + context.i18n.notif_body_unread_articles.replace('%d', nb),
+ body: context.i18n.notif_body_new_articles.replace('%%d', nb_new) + ' ' + context.i18n.notif_body_unread_articles.replace('%%d', nb),
tag: 'freshRssNewArticles',
});
@@ -1655,6 +1664,23 @@ function refreshUnreads() {
req.send();
}
+function toggle_bigMarkAsRead_button() {
+ const bigMarkAsRead_button = document.getElementById('bigMarkAsRead');
+ if (bigMarkAsRead_button) {
+ if (document.querySelector('.flux.not_read') != null) {
+ bigMarkAsRead_button.style = '';
+ bigMarkAsRead_button.querySelector('.markAllRead').style.visibility = '';
+ } else {
+ if (bigMarkAsRead_button.querySelector('.jumpNext')) {
+ bigMarkAsRead_button.querySelector('.markAllRead').style.visibility = 'hidden';
+ } else {
+ bigMarkAsRead_button.querySelector('.markAllRead').style.visibility = '';
+ bigMarkAsRead_button.style.visibility = 'hidden';
+ }
+ }
+ }
+}
+
// <endless_mode>
let url_load_more = '';
let load_more = false;
@@ -1691,6 +1717,7 @@ function load_more_posts() {
} else {
bigMarkAsRead.formAction = readAll.formAction;
}
+ toggle_bigMarkAsRead_button();
}
document.querySelectorAll('[id^=day_]').forEach(function (div) {
@@ -1843,6 +1870,7 @@ function init_main_afterDOM() {
init_posts();
init_nav_entries();
init_notifs_html5();
+ toggle_bigMarkAsRead_button();
setTimeout(faviconNbUnread, 1000);
setInterval(refreshUnreads, 120000);
}