mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-17 14:32:34 +08:00
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:
parent
f970eea525
commit
fe2a3c4ee6
2 changed files with 15 additions and 1 deletions
15
app/assets/javascripts/sitewide/tiny_mce.js
vendored
15
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
|
@ -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;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue