Reloading when there are modified buffers pops up a dialog.

This commit is contained in:
Corey Johnson
2012-06-12 10:50:05 -07:00
parent aa32655542
commit 8ab167fd00
3 changed files with 42 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
# This a weirdo file. We don't create a Window class, we just add stuff to
# the DOM window.
Native = require 'native'
fs = require 'fs'
_ = require 'underscore'
$ = require 'jquery'
@@ -60,6 +61,20 @@ windowAdditions =
return if $("head style[path='#{fullPath}']").length
$('head').append "<style path='#{fullPath}'>#{content}</style>"
reload: ->
console.log rootView.modifiedBuffers()
if rootView.modifiedBuffers().length > 0
message = "There are unsaved buffers, reload anyway?"
detailedMessage = "You will lose all unsaved changes if you reload"
buttons = [
["Reload", -> Native.reload()]
["Cancel", ->]
]
Native.alert(message, detailedMessage, buttons)
else
Native.reload()
showConsole: ->
$native.showDevTools()