💄 CoffeeScript is cute.
This commit is contained in:
parent
76ac8f2719
commit
f444e9dc74
1 changed files with 19 additions and 17 deletions
|
@ -8,54 +8,56 @@ messageBoxTypes = ['none', 'info', 'warning']
|
||||||
|
|
||||||
module.exports =
|
module.exports =
|
||||||
showOpenDialog: (window, options, callback) ->
|
showOpenDialog: (window, options, callback) ->
|
||||||
if window? and window.constructor isnt BrowserWindow
|
unless window?.constructor is BrowserWindow
|
||||||
# Shift.
|
# Shift.
|
||||||
callback = options
|
callback = options
|
||||||
options = window
|
options = window
|
||||||
window = null
|
window = null
|
||||||
|
|
||||||
options = title: 'Open', properties: ['openFile'] unless options?
|
options ?= title: 'Open', properties: ['openFile']
|
||||||
options.properties = options.properties ? ['openFile']
|
options.properties ?= ['openFile']
|
||||||
throw new TypeError('Properties need to be array') unless Array.isArray options.properties
|
throw new TypeError('Properties need to be array') unless Array.isArray options.properties
|
||||||
|
|
||||||
properties = 0
|
properties = 0
|
||||||
for prop, value of fileDialogProperties
|
for prop, value of fileDialogProperties
|
||||||
properties |= value if prop in options.properties
|
properties |= value if prop in options.properties
|
||||||
|
|
||||||
options.title = options.title ? ''
|
options.title ?= ''
|
||||||
options.defaultPath = options.defaultPath ? ''
|
options.defaultPath ?= ''
|
||||||
|
|
||||||
binding.showOpenDialog options.title,
|
binding.showOpenDialog String(options.title),
|
||||||
options.defaultPath,
|
String(options.defaultPath),
|
||||||
properties,
|
properties,
|
||||||
window
|
window
|
||||||
|
|
||||||
showSaveDialog: (window, options) ->
|
showSaveDialog: (window, options) ->
|
||||||
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
throw new TypeError('Invalid window') unless window?.constructor is BrowserWindow
|
||||||
options = title: 'Save' unless options?
|
|
||||||
|
|
||||||
options.title = options.title ? ''
|
options ?= title: 'Save'
|
||||||
options.defaultPath = options.defaultPath ? ''
|
options.title ?= ''
|
||||||
|
options.defaultPath ?= ''
|
||||||
|
|
||||||
binding.showSaveDialog window, options.title, options.defaultPath
|
binding.showSaveDialog window,
|
||||||
|
String(options.title),
|
||||||
|
String(options.defaultPath)
|
||||||
|
|
||||||
showMessageBox: (window, options, callback) ->
|
showMessageBox: (window, options, callback) ->
|
||||||
if window? and window.constructor isnt BrowserWindow
|
unless window?.constructor is BrowserWindow
|
||||||
# Shift.
|
# Shift.
|
||||||
callback = options
|
callback = options
|
||||||
options = window
|
options = window
|
||||||
window = null
|
window = null
|
||||||
|
|
||||||
options = type: 'none' unless options?
|
options ?= type: 'none'
|
||||||
options.type = options.type ? 'none'
|
options.type ?= 'none'
|
||||||
options.type = messageBoxTypes.indexOf options.type
|
options.type = messageBoxTypes.indexOf options.type
|
||||||
throw new TypeError('Invalid message box type') unless options.type > -1
|
throw new TypeError('Invalid message box type') unless options.type > -1
|
||||||
|
|
||||||
throw new TypeError('Buttons need to be array') unless Array.isArray options.buttons
|
throw new TypeError('Buttons need to be array') unless Array.isArray options.buttons
|
||||||
|
|
||||||
options.title = options.title ? ''
|
options.title ?= ''
|
||||||
options.message = options.message ? ''
|
options.message ?= ''
|
||||||
options.detail = options.detail ? ''
|
options.detail ?= ''
|
||||||
|
|
||||||
binding.showMessageBox options.type,
|
binding.showMessageBox options.type,
|
||||||
options.buttons,
|
options.buttons,
|
||||||
|
|
Loading…
Reference in a new issue