Skip to content

Commit 34377ba

Browse files
committed
Replace deprecated "unload" for USFM editor
#1080
1 parent 1a2f304 commit 34377ba

1 file changed

Lines changed: 8 additions & 7 deletions

File tree

editusfm/index.js

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,14 @@ document.addEventListener("DOMContentLoaded", function(e) {
5353
usfmeditor.addEventListener("keydown", function (event) {
5454
usfmHandleKeyDown(event);
5555
});
56-
window.addEventListener("unload", usfmEditorUnload);
56+
document.addEventListener("visibilitychange", (event) => {
57+
if (document.visibilityState == "hidden") {
58+
usfmEditorSaveChapter (true);
59+
}
60+
})
61+
window.addEventListener("pagehide", (event) => {
62+
usfmEditorSaveChapter (true);
63+
})
5764
usfmIdPollerOn ();
5865
if (usfmEditorWriteAccess) usfmeditor.focus ();
5966
window.addEventListener("focus", usfmWindowFocused);
@@ -203,12 +210,6 @@ function usfmEditorLoadChapter ()
203210
}
204211

205212

206-
function usfmEditorUnload ()
207-
{
208-
usfmEditorSaveChapter (true);
209-
}
210-
211-
212213
function usfmEditorSaveChapter (sync)
213214
{
214215
// Fix for https://github.com/bibledit/cloud/issues/427

0 commit comments

Comments
 (0)