Do unload work in 'unload' event handler instead of 'beforeunload'.

In Atom, the 'beforeunload' event never prevents window from closing so
it in fact has the same effect with 'unload' event, I guess using
'beforeunload' instead of 'unload' is because the 'beforeunload' is
guarrenteed to happen when window is closing or application is quiting.
However in Atom Shell the 'unload' event is guarrenteed to happen on
both conditions, just like the 'beforeunload' in Atom, so it's safe to
replace the 'beforeunload' with 'unload' here.

And in Atom Shell, the 'beforeunload' event is mainly used for
preventing window from closing, just like the 'window:close' command in
Atom.
This commit is contained in:
Cheng Zhao
2013-05-17 19:32:47 +08:00
parent d1ca0a8f8f
commit acf5e21f50

View File

@@ -52,7 +52,7 @@ window.startEditorWindow = ->
atom.activatePackages()
keymap.loadUserKeymaps()
atom.requireUserInitScript()
$(window).on 'beforeunload', -> unloadEditorWindow(); false
$(window).on 'unload', -> unloadEditorWindow(); false
$(window).focus()
window.startConfigWindow = ->
@@ -65,7 +65,7 @@ window.startConfigWindow = ->
deserializeConfigWindow()
atom.activatePackageConfigs()
keymap.loadUserKeymaps()
$(window).on 'beforeunload', -> unloadConfigWindow(); false
$(window).on 'unload', -> unloadConfigWindow(); false
$(window).focus()
window.unloadEditorWindow = ->