Add buttonLabel param to showOpen/showSave dialogs

This commit is contained in:
Ben Gotow 2016-05-06 11:10:31 -07:00
parent 88f3c34412
commit 40c531737d
10 changed files with 67 additions and 19 deletions

View file

@ -75,6 +75,15 @@ module.exports = {
} else if (typeof options.title !== 'string') {
throw new TypeError('Title must be a string')
}
if (options.buttonLabel == null) {
if (options.properties.indexOf('openDirectory') !== -1) {
options.buttonLabel = 'Choose'
} else {
options.buttonLabel = 'Open'
}
} else if (typeof options.buttonLabel !== 'string') {
throw new TypeError('buttonLabel must be a string')
}
if (options.defaultPath == null) {
options.defaultPath = ''
} else if (typeof options.defaultPath !== 'string') {
@ -86,7 +95,7 @@ module.exports = {
wrappedCallback = typeof callback === 'function' ? function (success, result) {
return callback(success ? result : void 0)
} : null
return binding.showOpenDialog(String(options.title), String(options.defaultPath), options.filters, properties, window, wrappedCallback)
return binding.showOpenDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, properties, window, wrappedCallback)
},
showSaveDialog: function (...args) {
@ -103,6 +112,11 @@ module.exports = {
} else if (typeof options.title !== 'string') {
throw new TypeError('Title must be a string')
}
if (options.buttonLabel == null) {
options.buttonLabel = 'Save'
} else if (typeof options.buttonLabel !== 'string') {
throw new TypeError('buttonLabel must be a string')
}
if (options.defaultPath == null) {
options.defaultPath = ''
} else if (typeof options.defaultPath !== 'string') {
@ -114,7 +128,7 @@ module.exports = {
wrappedCallback = typeof callback === 'function' ? function (success, result) {
return callback(success ? result : void 0)
} : null
return binding.showSaveDialog(String(options.title), String(options.defaultPath), options.filters, window, wrappedCallback)
return binding.showSaveDialog(String(options.title), String(options.buttonLabel), String(options.defaultPath), options.filters, window, wrappedCallback)
},
showMessageBox: function (...args) {