diff options
| author | 2015-03-24 21:11:21 +0100 | |
|---|---|---|
| committer | 2015-03-24 21:11:21 +0100 | |
| commit | 800f28a5db367d77918cd3ee83a2d0683eb84dfd (patch) | |
| tree | 0d8a9e2f46368db7cf1c9ac7e8ef47460ae372aa /p/scripts/main.js | |
| parent | a5e960acbe6e69043a52ec1788700a70779f313a (diff) | |
| parent | 5376c37907257ca3515b257413740721bd030254 (diff) | |
Merge branch 'FreshRSS/dev' into dev
Diffstat (limited to 'p/scripts/main.js')
| -rw-r--r-- | p/scripts/main.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/p/scripts/main.js b/p/scripts/main.js index b7c143cc1..eaf6067f7 100644 --- a/p/scripts/main.js +++ b/p/scripts/main.js @@ -1229,6 +1229,33 @@ function init_slider_observers() { }); } +function init_configuration_alert() { + $(window).on('beforeunload', function(e){ + if (e.originalEvent.explicitOriginalTarget.type === 'submit') { + // we don't want an alert when submitting the form with the submit button + return; + } + if ($(e.originalEvent.explicitOriginalTarget).attr('data-leave-validation') !== undefined) { + // we don't want an alert when submitting the form by pressing the enter key + return; + } + var fields = $("[data-leave-validation]"); + for (var i = 0; i < fields.length; i++) { + if ($(fields[i]).attr('type') === 'checkbox' || $(fields[i]).attr('type') === 'radio') { + // The use of != is done on purpose to check boolean against integer + if ($(fields[i]).is(':checked') != $(fields[i]).attr('data-leave-validation')) { + return false; + } + } else { + if ($(fields[i]).attr('data-leave-validation') !== $(fields[i]).val()) { + return false; + } + } + } + return; + }); +} + function init_all() { if (!(window.$ && window.context)) { if (window.console) { @@ -1260,6 +1287,7 @@ function init_all() { init_password_observers(); init_stats_observers(); init_slider_observers(); + init_configuration_alert(); } if (window.console) { |
