File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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-
212213function usfmEditorSaveChapter ( sync )
213214{
214215 // Fix for https://github.com/bibledit/cloud/issues/427
You can’t perform that action at this time.
0 commit comments