Consolidate Atom::confirm/confirmSync

Support both an array and hash of buttons to allow callbacks
optionally.
This commit is contained in:
Kevin Sawicki
2013-11-22 15:00:32 -08:00
parent c754b73b71
commit ef9ce1bf70
3 changed files with 39 additions and 33 deletions

View File

@@ -220,12 +220,11 @@ class Pane extends View
return true unless item.shouldPromptToSave?()
uri = item.getUri()
chosen = atom.confirmSync(
"'#{item.getTitle?() ? item.getUri()}' has changes, do you want to save them?"
"Your changes will be lost if you close this item without saving."
["Save", "Cancel", "Don't Save"]
atom.getCurrentWindow()
)
chosen = atom.confirm
message: "'#{item.getTitle?() ? item.getUri()}' has changes, do you want to save them?"
detailedMessage: "Your changes will be lost if you close this item without saving."
buttons: ["Save", "Cancel", "Don't Save"]
switch chosen
when 0 then @saveItem(item, -> true)
when 1 then false