Hide unsaved changes warning after undoing them

This way showing the warning is consistent with warning users when
they're leaving the page.
This commit is contained in:
Javi Martín
2020-06-18 20:08:49 +02:00
parent cfc60b5de4
commit 0270c4c962
4 changed files with 25 additions and 8 deletions

View File

@@ -22,8 +22,18 @@
});
editor = $(this);
editor.on("input", function() {
var textarea, warning;
textarea = editor.find("textarea")[0];
warning = $(this).closest(".translatable-fields").find(".warning");
App.MarkdownEditor.refresh_preview($(this), md);
$(".legislation-draft-versions-edit .warning").show();
if (textarea.value === textarea.defaultValue) {
warning.hide();
} else {
warning.show();
}
});
editor.find("textarea").on("scroll", function() {
editor.find(".markdown-preview").scrollTop($(this).scrollTop());