mirror of
https://github.com/osmarks/mycorrhiza.git
synced 2025-11-03 09:03:01 +00:00
Make toolbar actions lift the 'text changed' flag
This commit is contained in:
@@ -1,20 +1,20 @@
|
||||
(function () {
|
||||
let changed = false;
|
||||
window.hyphaChanged = false;
|
||||
let textarea = document.querySelector('.edit-form__textarea');
|
||||
let form = document.querySelector('.edit-form');
|
||||
|
||||
let warnBeforeClosing = function (ev) {
|
||||
if (!changed) return;
|
||||
if (!window.hyphaChanged) return;
|
||||
ev.preventDefault();
|
||||
return ev.returnValue = 'Are you sure you want to exit? You have unsaved changes.';
|
||||
};
|
||||
|
||||
textarea.addEventListener('input', function () {
|
||||
changed = true;
|
||||
window.hyphaChanged = true;
|
||||
});
|
||||
|
||||
form.addEventListener('submit', function () {
|
||||
changed = false;
|
||||
window.hyphaChanged = false;
|
||||
});
|
||||
|
||||
window.addEventListener('beforeunload', warnBeforeClosing);
|
||||
|
||||
Reference in New Issue
Block a user