diff options
| author | 2022-05-19 21:30:40 +0200 | |
|---|---|---|
| committer | 2022-05-19 21:30:40 +0200 | |
| commit | f5aaf5f46076e0ac11ab52ef2ea940fd789ff174 (patch) | |
| tree | dce366428ef809022d62eee3dd6601083ffa2e0c /p/scripts/extra.js | |
| parent | c1eae578986d5e0d1d9dc8ad1c35e03d8d6f4986 (diff) | |
New limit option when reloading a feed (#4370)
Diffstat (limited to 'p/scripts/extra.js')
| -rw-r--r-- | p/scripts/extra.js | 11 |
1 files changed, 9 insertions, 2 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) { |
