Ask for close confirmation in beforeunload handler.

This commit is contained in:
Cheng Zhao 2013-06-27 18:39:29 +08:00
parent bdbec54f24
commit 45ce8e1d63
5 changed files with 5 additions and 20 deletions

View File

@ -83,7 +83,9 @@ class PaneContainer extends View
saved = true
for pane in @getPanes()
for item in pane.getItems() when item.isModified?()
saved = false if not pane.promptToSaveItem item
if not @paneAtIndex(0).promptToSaveItem item
saved = false
break
saved
getPanes: ->

View File

@ -14,13 +14,10 @@ class WindowEventHandler
@subscribe $(window), 'blur', -> $("body").addClass('is-blurred')
@subscribe $(window), 'window:open-path', (event, pathToOpen) ->
rootView?.open(pathToOpen) unless fsUtils.isDirectorySync(pathToOpen)
@subscribe $(window), 'beforeunload', -> rootView?.confirmClose()
@subscribeToCommand $(window), 'window:toggle-full-screen', => atom.toggleFullScreen()
@subscribeToCommand $(window), 'window:close', =>
if rootView?
closeWithoutConfirm() if rootView.confirmClose()
else
closeWithoutConfirm()
@subscribeToCommand $(window), 'window:close', => window.close()
@subscribeToCommand $(window), 'window:reload', => atom.reload()
@subscribeToCommand $(document), 'core:focus-next', @focusNext

View File

@ -210,10 +210,6 @@ window.restoreDimensions = ->
window.setDimensions(dimensions)
$(window).on 'unload', -> atom.setWindowState('dimensions', window.getDimensions())
window.closeWithoutConfirm = ->
atom.hide()
ipc.sendChannel 'close-without-confirm'
window.onerror = ->
atom.openDevTools()

View File

@ -175,11 +175,6 @@ class AtomApplication
@installUpdate = quitAndUpdate
@buildApplicationMenu version, quitAndUpdate
ipc.on 'close-without-confirm', (processId, routingId) ->
window = BrowserWindow.fromProcessIdAndRoutingId processId, routingId
window.removeAllListeners 'close'
window.close()
ipc.on 'open-config', =>
@openConfig()

View File

@ -89,11 +89,6 @@ class AtomWindow
# Spec window's web view should always have focus
@browserWindow.on 'blur', =>
@browserWindow.focusOnWebView()
else
@browserWindow.on 'close', (event) =>
unless @browserWindow.isCrashed()
event.preventDefault()
@sendCommand 'window:close'
openPath: (pathToOpen) ->
if @loaded