From 20e07649d4e81b11ceed43616da735f16fee131d Mon Sep 17 00:00:00 2001 From: Nathan Sobo Date: Tue, 13 Oct 2015 18:09:35 -0600 Subject: [PATCH] Move confirm into ApplicationDelegate Signed-off-by: Max Brunsfeld --- src/application-delegate.coffee | 23 +++++++++++++++++++++-- src/atom-environment.coffee | 21 ++------------------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/application-delegate.coffee b/src/application-delegate.coffee index 10ef81e71..74a3dd04b 100644 --- a/src/application-delegate.coffee +++ b/src/application-delegate.coffee @@ -94,9 +94,28 @@ class ApplicationDelegate screen = remote.require 'screen' screen.getPrimaryDisplay().workAreaSize - showMessageDialog: (params) -> + confirm: ({message, detailedMessage, buttons}) -> + buttons ?= {} + if _.isArray(buttons) + buttonLabels = buttons + else + buttonLabels = Object.keys(buttons) + dialog = remote.require('dialog') - dialog.showMessageBox remote.getCurrentWindow(), params + chosen = dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'info' + message: message + detail: detailedMessage + buttons: buttonLabels + }) + + if _.isArray(buttons) + chosen + else + callback = buttons[buttonLabels[chosen]] + callback?() + + showMessageDialog: (params) -> showSaveDialog: (params) -> if _.isString(params) diff --git a/src/atom-environment.coffee b/src/atom-environment.coffee index 1706459c6..9d0c9d76a 100644 --- a/src/atom-environment.coffee +++ b/src/atom-environment.coffee @@ -684,25 +684,8 @@ class AtomEnvironment extends Model # button names and the values are callbacks to invoke when clicked. # # Returns the chosen button index {Number} if the buttons option was an array. - confirm: ({message, detailedMessage, buttons}={}) -> - buttons ?= {} - if _.isArray(buttons) - buttonLabels = buttons - else - buttonLabels = Object.keys(buttons) - - chosen = @applicationDelegate.showMessageDialog( - type: 'info' - message: message - detail: detailedMessage - buttons: buttonLabels - ) - - if _.isArray(buttons) - chosen - else - callback = buttons[buttonLabels[chosen]] - callback?() + confirm: (params={}) -> + @applicationDelegate.confirm(params) ### Section: Managing the Dev Tools