mirror of
https://github.com/atom/atom.git
synced 2026-02-09 06:05:11 -05:00
Add atom.confirm, which displays a confirmation w/ buttons that fire callbacks
This communicates back to the browser process to display the confirmation, then the browser replies to the message with the index of the clicked button.
This commit is contained in:
@@ -15,7 +15,9 @@ atom.sendMessageToBrowserProcess = (name, data, callback) ->
|
||||
originalSendMessageToBrowserProcess(name, data)
|
||||
|
||||
atom.receiveMessageFromBrowserProcess = (name, data) ->
|
||||
console.log "RECEIVE MESSAGE IN JS", name, data
|
||||
if name is 'reply'
|
||||
[messageId, callbackIndex] = data
|
||||
@pendingBrowserProcessCallbacks[messageId]?[callbackIndex]?()
|
||||
|
||||
atom.open = (args...) ->
|
||||
@sendMessageToBrowserProcess('open', args)
|
||||
@@ -23,6 +25,14 @@ atom.open = (args...) ->
|
||||
atom.newWindow = (args...) ->
|
||||
@sendMessageToBrowserProcess('newWindow', args)
|
||||
|
||||
atom.confirm = (message, detailedMessage, buttonLabelsAndCallbacks...) ->
|
||||
args = [message, detailedMessage]
|
||||
callbacks = []
|
||||
while buttonLabelsAndCallbacks.length
|
||||
args.push(buttonLabelsAndCallbacks.shift())
|
||||
callbacks.push(buttonLabelsAndCallbacks.shift())
|
||||
@sendMessageToBrowserProcess('confirm', args, callbacks)
|
||||
|
||||
atom.getRootViewStateForPath = (path) ->
|
||||
if json = localStorage[path]
|
||||
JSON.parse(json)
|
||||
|
||||
Reference in New Issue
Block a user