Add message when turbolinks change page with dirty tinyMCE [SCI-3452] (#1754)

* Add message when turbolinks change page with dirty tinuMCE
This commit is contained in:
aignatov-bio 2019-05-14 09:49:00 +02:00 committed by GitHub
parent f970eea525
commit fe2a3c4ee6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -1,4 +1,4 @@
/* global _ hljs tinyMCE SmartAnnotation */
/* global _ hljs tinyMCE SmartAnnotation I18n */
/* eslint-disable no-unused-vars */
var TinyMCE = (function() {
@ -247,3 +247,16 @@ var TinyMCE = (function() {
highlight: initHighlightjs
});
}());
$(document).on('turbolinks:before-visit', function(e) {
_.each(tinyMCE.editors, function(editor) {
if (editor.isNotDirty === false) {
if (confirm(I18n.t('tiny_mce.leaving_warning'))) {
return true;
}
e.preventDefault();
return false;
}
return false;
});
});

View file

@ -1955,6 +1955,7 @@ en:
error_message: 'You must choose a file'
server_not_respond: "Didn't get a response from the server"
saved_label: "Saved"
leaving_warning: 'You have made some changes, are you sure you wan't to leave this page?'
general:
save: "Save"
update: "Update"