alert and confirm calls didn't stack as they do on other platforms, well now they do.
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/7e8a2ce8 Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/7e8a2ce8 Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/7e8a2ce8 Branch: refs/heads/master Commit: 7e8a2ce80aa51d0a347e4cfe9f785d6c128c618d Parents: 40d3b0a Author: Jesse MacFadyen <[email protected]> Authored: Tue Jan 8 18:57:06 2013 -0800 Committer: Jesse MacFadyen <[email protected]> Committed: Tue Jan 8 18:57:06 2013 -0800 ---------------------------------------------------------------------- lib/windows8/platform.js | 3 + lib/windows8/plugin/windows8/NotificationProxy.js | 44 ++++++++++++++- 2 files changed, 44 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-js/blob/7e8a2ce8/lib/windows8/platform.js ---------------------------------------------------------------------- diff --git a/lib/windows8/platform.js b/lib/windows8/platform.js index 93ccec6..5ebb2d1 100755 --- a/lib/windows8/platform.js +++ b/lib/windows8/platform.js @@ -46,6 +46,9 @@ module.exports = { id: "windows8", initialize:function() { + window.alert = window.alert || require("cordova/plugin/notification").alert; + window.confirm = window.confirm || require("cordova/plugin/notification").confirm; + var onWinJSReady = function () { var app = WinJS.Application; var checkpointHandler = function checkpointHandler() { http://git-wip-us.apache.org/repos/asf/cordova-js/blob/7e8a2ce8/lib/windows8/plugin/windows8/NotificationProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/NotificationProxy.js b/lib/windows8/plugin/windows8/NotificationProxy.js index 56b4012..35ef6e7 100644 --- a/lib/windows8/plugin/windows8/NotificationProxy.js +++ b/lib/windows8/plugin/windows8/NotificationProxy.js @@ -23,25 +23,57 @@ var cordova = require('cordova'); +var isAlertShowing = false; +var alertStack = []; + module.exports = { alert:function(win, loseX, args) { + + if (isAlertShowing) { + var later = function () { + module.exports.alert(win, loseX, args); + }; + alertStack.push(later); + return; + } + isAlertShowing = true; + var message = args[0]; var _title = args[1]; var _buttonLabel = args[2]; var md = new Windows.UI.Popups.MessageDialog(message, _title); md.commands.append(new Windows.UI.Popups.UICommand(_buttonLabel)); - md.showAsync().then(win); + md.showAsync().then(function() { + isAlertShowing = false; + win && win(); + + if (alertStack.length) { + setTimeout(alertStack.shift(), 0); + } + + }); }, confirm:function(win, loseX, args) { + + if (isAlertShowing) { + var later = function () { + module.exports.confirm(win, loseX, args); + }; + alertStack.push(later); + return; + } + + isAlertShowing = true; + var message = args[0]; var _title = args[1]; var _buttonLabels = args[2]; var btnList = []; function commandHandler (command) { - win(btnList[command.label]); + win && win(btnList[command.label]); } var md = new Windows.UI.Popups.MessageDialog(message, _title); @@ -51,7 +83,13 @@ module.exports = { btnList[button[i]] = i+1; md.commands.append(new Windows.UI.Popups.UICommand(button[i],commandHandler)); } - md.showAsync(); + md.showAsync().then(function() { + isAlertShowing = false; + if (alertStack.length) { + setTimeout(alertStack.shift(), 0); + } + + }); }, vibrate:function(winX, loseX, args) {
