diff --git a/modules/meeting/app/assets/javascripts/meeting/meeting.js b/modules/meeting/app/assets/javascripts/meeting/meeting.js index f383b6a109..68bc6de1e4 100644 --- a/modules/meeting/app/assets/javascripts/meeting/meeting.js +++ b/modules/meeting/app/assets/javascripts/meeting/meeting.js @@ -1,4 +1,5 @@ jQuery(function($) { + var formSubmitting = false; function toggleContentTypeForm(content_type, edit) { jQuery('.edit-' + content_type).toggle(edit); jQuery('.show-' + content_type).toggle(!edit); @@ -11,6 +12,17 @@ jQuery(function($) { var content_type = $(this).data('contentType'); toggleContentTypeForm(content_type, true); + + $(window).on("beforeunload", function (e) { + if (formSubmitting) { + return undefined; + } + + // For browser compatibility we need to set the event return value + e.returnValue = ''; + return ''; + }); + return false; }); @@ -18,12 +30,18 @@ jQuery(function($) { var content_type = $(this).data('contentType'); toggleContentTypeForm(content_type, false); + $(window).off("beforeunload"); + return false; }); + $('.button--save-agenda').click(function() { + formSubmitting = true; + }); + $('.meetings--checkbox-version-to').click(function() { var target = $(this).data('target'); $(target).prop('checked', true); }); -}); \ No newline at end of file +}); diff --git a/modules/meeting/app/views/meeting_contents/_form.html.erb b/modules/meeting/app/views/meeting_contents/_form.html.erb index 2ef9b6a95a..140f3d5dd0 100644 --- a/modules/meeting/app/views/meeting_contents/_form.html.erb +++ b/modules/meeting/app/views/meeting_contents/_form.html.erb @@ -31,7 +31,7 @@ See doc/COPYRIGHT.md for more details. <%= wikitoolbar_for "#{content_type}_text", preview_context: preview_context(content.meeting, @project) %>
<%= f.text_field :comment, :size => 120 %>
-<%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark' %> +
<%= styled_button_tag l(:button_save), class: '-highlight -with-icon icon-checkmark button--save-agenda' %> <%= link_to l(:button_cancel), "#", data: { 'content-type': content_type }, class: 'button button--cancel-agenda' %> <% end %>