summaryrefslogtreecommitdiff
path: root/p/scripts/extra.js
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2019-10-31 18:15:47 +0100
committerGravatar GitHub <noreply@github.com> 2019-10-31 18:15:47 +0100
commit3aa66f317b496ccd9a2df914bbc747c52081a7ad (patch)
tree6a3f3f74899801abdca00546e213dfdc141c53cf /p/scripts/extra.js
parent82611c9622ed23b0e9fcf5f9f651ddffa1fd7706 (diff)
parentfcae48f313d399050cb15f37a8a73ae52fc67796 (diff)
Merge pull request #2599 from FreshRSS/dev1.15.0
FreshRSS 1.15
Diffstat (limited to 'p/scripts/extra.js')
-rw-r--r--p/scripts/extra.js40
1 files changed, 27 insertions, 13 deletions
diff --git a/p/scripts/extra.js b/p/scripts/extra.js
index c0d0c89e1..1fd8a19de 100644
--- a/p/scripts/extra.js
+++ b/p/scripts/extra.js
@@ -1,3 +1,4 @@
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0
"use strict";
/* globals context, openNotification, xmlHttpRequestJson */
/* jshint esversion:6, strict:global */
@@ -183,12 +184,32 @@ function init_slider_observers() {
};
closer.onclick = function (ev) {
- closer.classList.remove('active');
- slider.classList.remove('active');
- return false;
+ if (data_leave_validation() || confirm(context.i18n.confirmation_default)) {
+ slider.querySelectorAll('form').forEach(function (f) { f.reset(); });
+ closer.classList.remove('active');
+ slider.classList.remove('active');
+ return true;
+ } else {
+ return false;
+ }
};
}
+function data_leave_validation() {
+ const ds = document.querySelectorAll('[data-leave-validation]');
+ for (let i = ds.length - 1; i >= 0; i--) {
+ const input = ds[i];
+ if (input.type === 'checkbox' || input.type === 'radio') {
+ if (input.checked != input.getAttribute('data-leave-validation')) {
+ return false;
+ }
+ } else if (input.value != input.getAttribute('data-leave-validation')) {
+ return false;
+ }
+ }
+ return true;
+}
+
function init_configuration_alert() {
window.onsubmit = function (e) {
window.hasSubmit = true;
@@ -197,16 +218,8 @@ function init_configuration_alert() {
if (window.hasSubmit) {
return;
}
- const ds = document.querySelectorAll('[data-leave-validation]');
- for (let i = ds.length - 1; i >= 0; i--) {
- const input = ds[i];
- if (input.type === 'checkbox' || input.type === 'radio') {
- if (input.checked != input.getAttribute('data-leave-validation')) {
- return false;
- }
- } else if (input.value != input.getAttribute('data-leave-validation')) {
- return false;
- }
+ if (!data_leave_validation()) {
+ return false;
}
};
}
@@ -239,3 +252,4 @@ if (document.readyState && document.readyState !== 'loading') {
init_extra();
}, false);
}
+// @license-end