]> khamidou — GitHub mirrors - electron.git/commitdiff
Use string instead of integer to represent dialog's types.
authorCheng Zhao <zcbenz@gmail.com>
Sat, 18 May 2013 02:41:43 +0000 (10:41 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Sat, 18 May 2013 02:41:43 +0000 (10:41 +0800)
browser/api/lib/dialog.coffee

index 72e8eb9f5697e6f37d907d55d9a7f3a24e000357..f87884c9e580bcb2f798bc54b2d1bfe2705b60e6 100644 (file)
@@ -53,6 +53,8 @@ selectFileWrap = (window, options, callback, type, title) ->
                         options.defaultExtension,
                         callbackId
 
+messageBoxTypes = ['none', 'info', 'warning']
+
 module.exports =
   openFolder: (args...) ->
     selectFileWrap args..., 1, 'Open Folder'
@@ -70,8 +72,9 @@ module.exports =
     throw new TypeError('Need Window object') unless window.constructor is BrowserWindow
 
     options = {} unless options?
-    options.type = options.type ? module.exports.MESSAGE_BOX_NONE
-    throw new TypeError('Invalid message box type') unless 0 <= options.type <= 2
+    options.type = options.type ? 'none'
+    options.type = messageBoxTypes.indexOf options.type
+    throw new TypeError('Invalid message box type') unless options.type > -1
 
     throw new TypeError('Buttons need to be array') unless Array.isArray options.buttons
 
@@ -83,8 +86,3 @@ module.exports =
                            String(options.title),
                            String(options.message),
                            String(options.detail)
-
-  # Message box types:
-  MESSAGE_BOX_NONE: 0
-  MESSAGE_BOX_INFORMATION: 1
-  MESSAGE_BOX_WARNING: 2