aboutsummaryrefslogtreecommitdiff
path: root/p/scripts
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2022-05-19 21:30:40 +0200
committerGravatar GitHub <noreply@github.com> 2022-05-19 21:30:40 +0200
commitf5aaf5f46076e0ac11ab52ef2ea940fd789ff174 (patch)
treedce366428ef809022d62eee3dd6601083ffa2e0c /p/scripts
parentc1eae578986d5e0d1d9dc8ad1c35e03d8d6f4986 (diff)
New limit option when reloading a feed (#4370)
Diffstat (limited to 'p/scripts')
-rw-r--r--p/scripts/extra.js11
-rw-r--r--p/scripts/feed.js4
2 files changed, 12 insertions, 3 deletions
diff --git a/p/scripts/extra.js b/p/scripts/extra.js
index e20fe821c..a95eb620d 100644
--- a/p/scripts/extra.js
+++ b/p/scripts/extra.js
@@ -233,11 +233,18 @@ function init_select_observers() {
});
}
-function data_leave_validation(parent) {
+/**
+ * Returns true when no input element is changed, false otherwise.
+ * When excludeForm is defined, will only report changes outside the specified form.
+ */
+function data_leave_validation(parent, excludeForm = null) {
const ds = parent.querySelectorAll('[data-leave-validation]');
for (let i = ds.length - 1; i >= 0; i--) {
const input = ds[i];
+ if (excludeForm && excludeForm === input.form) {
+ continue;
+ }
if (input.type === 'checkbox' || input.type === 'radio') {
if (input.checked != input.getAttribute('data-leave-validation')) {
return false;
@@ -251,7 +258,7 @@ function data_leave_validation(parent) {
function init_configuration_alert() {
window.onsubmit = function (e) {
- window.hasSubmit = true;
+ window.hasSubmit = data_leave_validation(document.body, e.submitter ? e.submitter.form : null);
};
window.onbeforeunload = function (e) {
if (window.hasSubmit) {
diff --git a/p/scripts/feed.js b/p/scripts/feed.js
index b206b79d4..2a213b422 100644
--- a/p/scripts/feed.js
+++ b/p/scripts/feed.js
@@ -1,6 +1,6 @@
// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
'use strict';
-/* globals init_archiving, init_password_observers, init_slider */
+/* globals init_archiving, init_configuration_alert, init_password_observers, init_slider */
// <popup>
let popup = null;
@@ -134,6 +134,8 @@ function init_feed_afterDOM() {
init_valid_xpath(document.body);
}
+ init_configuration_alert();
+
if (window.console) {
console.log('FreshRSS feed init done.');
}