You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2014/11/13 07:53:00 UTC

[3/3] cordova-plugin-dialogs git commit: CB-7639 Handle button labels as array on windows

CB-7639 Handle button labels as array on windows


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/commit/d8d422a4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/d8d422a4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/d8d422a4

Branch: refs/heads/master
Commit: d8d422a4712665a0a63b74aa319769893d6fe17d
Parents: 06a1dea
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Sep 25 17:04:33 2014 +0400
Committer: sgrebnov <v-...@microsoft.com>
Committed: Wed Nov 12 22:50:35 2014 -0800

----------------------------------------------------------------------
 src/windows8/NotificationProxy.js | 24 ++++++++----------------
 www/notification.js               |  5 +++--
 2 files changed, 11 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/d8d422a4/src/windows8/NotificationProxy.js
----------------------------------------------------------------------
diff --git a/src/windows8/NotificationProxy.js b/src/windows8/NotificationProxy.js
index c6bad95..362d431 100644
--- a/src/windows8/NotificationProxy.js
+++ b/src/windows8/NotificationProxy.js
@@ -68,30 +68,22 @@ module.exports = {
         isAlertShowing = true;
 
         var message = args[0];
-        var _title = args[1];
-        var _buttonLabels = args[2];
-
-        var result;
+        var title = args[1];
+        var buttons = args[2];
 
-        var btnList = [];
-        function commandHandler (command) {
-            result = btnList[command.label];
-        }
+        var md = new Windows.UI.Popups.MessageDialog(message, title);
 
-        var md = new Windows.UI.Popups.MessageDialog(message, _title);
-        var button = _buttonLabels.split(',');
+        buttons.forEach(function(buttonLabel) {
+            md.commands.append(new Windows.UI.Popups.UICommand(buttonLabel));
+        });
 
-        for (var i = 0; i<button.length; i++) {
-            btnList[button[i]] = i+1;
-            md.commands.append(new Windows.UI.Popups.UICommand(button[i],commandHandler));
-        }
-        md.showAsync().then(function() {
+        md.showAsync().then(function(res) {
             isAlertShowing = false;
+            var result = res ? buttons.indexOf(res.label) + 1 : 0;
             win && win(result);
             if (alertStack.length) {
                 setTimeout(alertStack.shift(), 0);
             }
-
         });
     },
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/d8d422a4/www/notification.js
----------------------------------------------------------------------
diff --git a/www/notification.js b/www/notification.js
index 6bf815c..c3f70d0 100644
--- a/www/notification.js
+++ b/www/notification.js
@@ -63,10 +63,11 @@ module.exports = {
         // Some platforms take an array of button label names.
         // Other platforms take a comma separated list.
         // For compatibility, we convert to the desired type based on the platform.
-        if (platform.id == "amazon-fireos" || platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone" || platform.id == "firefoxos" || platform.id == "ubuntu") {
+        if (platform.id == "amazon-fireos" || platform.id == "android" || platform.id == "ios" ||
+            platform.id == "windowsphone" || platform.id == "firefoxos" || platform.id == "ubuntu" ||
+            platform.id == "windows8" || platform.id == "windows") {
 
             if (typeof _buttonLabels === 'string') {
-                var buttonLabelString = _buttonLabels;
                 _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
             }
         } else {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org