Merge branch 'add-jira-link' of https://github.com/revolunet/cordova-plugin-dialogs
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index f7dbcab..4c8e6a5 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -27,7 +27,7 @@
 contribute code.
 
 For instructions on this, start with the 
-[contribution overview](http://cordova.apache.org/#contribute).
+[contribution overview](http://cordova.apache.org/contribute/).
 
 The details are explained there, but the important items are:
  - Sign and submit an Apache ICLA (Contributor License Agreement).
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
index 7957154..c0c98a0 100644
--- a/RELEASENOTES.md
+++ b/RELEASENOTES.md
@@ -20,81 +20,32 @@
 -->
 # Release Notes
 
-### 0.2.2 (Sept 25, 2013)
-* CB-4889 bumping&resetting version
-* [windows8] commandProxy was moved
-* CB-4889 renaming reference in Notification.cs
-* CB-4889 renaming org.apache.cordova.core.dialogs to org.apache.cordova.dialogs
-* Rename CHANGELOG.md -> RELEASENOTES.md
-* [CB-4592] [Blackberry10] Added beep support
-* [CB-4752] Incremented plugin version on dev branch.
+### 1.1.1 (Jun 17, 2015)
+* CB-9128 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs
+* fix npm md
 
- ### 0.2.3 (Oct 28, 2013)
-* CB-5128: added repo + issue tag to plugin.xml for dialogs plugin
-* new plugin execute arguments supported
-* new plugin style
-* smaller fonts styling input
-* img files copied inside plugin
-* style added
-* prompt added
-* styling from James
-* fixed "exec" calls addedd css, but not working yet
-* first (blind) try
-* [CB-4915] Incremented plugin version on dev branch.
-
+### 1.1.0 (May 06, 2015)
+* CB-8928: Removed direct call to `toStaticHTML`, only call it if we are sure it's present. This closes #52
+* CB-7734 - `navigator.notification.alert` or `navigator.notification.confirm` seem have a "many words" issue. (closes #39)
  
-### 0.2.4 (Dec 4, 2013)
-* add ubuntu platform
-* 1. Added amazon-fireos platform. 2. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'.
-* added beep funtionality using ms-winsoundevent:Notfication.Default
+### 1.0.0 (Apr 15, 2015)
+* CB-8746 gave plugin major version bump
+* CB-8683 updated wp and bb specific references of old id to new id
+* CB-8683 changed plugin-id to pacakge-name
+* CB-8653 properly updated translated docs to use new id
+* CB-8653 updated translated docs to use new id
+* Use TRAVIS_BUILD_DIR, install paramedic by npm
+* CB-8653 Updated Readme
+* CB-8659: ios: 4.0.x Compatibility: Remove use of deprecated headers
+* CB-8565 Integrate TravisCI
+* CB-8438 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs
+* CB-8538 Added package.json file
+* CB-8367 [org.apache.cordova.dialogs] Add Prompt support on Windows
 
-### 0.2.5 (Jan 02, 2014)
-* CB-4696 Fix compile error for Xcode 4.5.
-* CB-5658 Add doc/index.md for Dialogs plugin
-* CB-3762 Change prompt default to empty string
-* Move images from css to img
-
-### 0.2.6 (Feb 05, 2014)
-* no need to recreate the manifest.webapp file after each `cordova prepare` for FFOS
-* FFOS description added
-
-### 0.2.7 (Apr 17, 2014)
-* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
-* CB-6411: [BlackBerry10] Work around Audio playback issue
-* CB-6411: [BlackBerry10] Updates to beep
-* CB-6422: [windows8] use cordova/exec/proxy
-* CB-6460: Update license headers
-* Add NOTICE file
-
-### 0.2.8 (Jun 05, 2014)
-* CB-6801 Add license
-* running original windows.open, inAppBrowser is overriding it no need to place CSS in every page anymore
-* CB-5945 [Windows8] do not call success callbacks until dialog is dismissed
-* CB-4616 Returned index 0 was not documented for notification.prompt
-* update docs to state that prompt is supported on windowsphone
-* CB-6528 allow scroll on alert message content
-* [CB-6628][amazon-fireos]dialogs plugin's confirm and prompt methods dont work confirm() method was missing amazon-fireos platform check. added that. prompt() method had bug. It is executed in a worker thread that does not have a message queue(or Looper object) associated with it and hence "can't create a handler" exception is thrown. To fix this issue, we need to create the EditText widget from within the UI thread. This was fixed sometime ago when we added fireos platform but commit got lost somewhere. So fixing it again now.
-* CB-6491 add CONTRIBUTING.md
-* Added check for isFinishing() on the parent activity to prevent crashes when trying to display dialogs when activity is in this phase of it's lifecycle
-* CB-4966 Dialogs are in window now No need to add anything to manifest or index.html
-* Removing FirefoxOS Quirks * no need to add special permission (it's different API with the same name) * notification.css is added automatically
-
-### 0.2.9 (Aug 06, 2014)
-* ubuntu: pass proper arguments to prompt callback
-* ubuntu: use TextField instead of TextInput
-* ubuntu: proper message escaping before passing to qml
-* **FFOS** update notification.js
-* CB-6127 Updated translations for docs
-* android: Explicitly apply default theme to dialogs
-* Fix Beep exception on Android when no argument passed
-
-### 0.2.10 (Sep 17, 2014)
-* CB-7538 Android beep thread fix Beep now executes in it's own thread. It was previously executing in the main UI thread which was causing the application to lock up will the beep was occurring.  Closing pull request
-* Set dialog text dir to locale
-* Renamed test dir, added nested plugin.xml
-* added documentation for manual tests
-* CB-6965 Added manual tests
-* CB-6965 Port notification tests to test-framework
+### 0.3.0 (Feb 04, 2015)
+* Correct way to specify Windows platform in config.xml
+* CB-8351 ios: Use argumentForIndex rather than NSArray extension
+* CB-7955 Add support "browser" platform
 
 ### 0.2.11 (Dec 02, 2014)
 * [CB-7737] lower min height for alert
@@ -111,29 +62,77 @@
 * CB-7700 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs
 * CB-7571 Bump version of nested plugin to match parent plugin
 
-### 0.3.0 (Feb 04, 2015)
-* Correct way to specify Windows platform in config.xml
-* CB-8351 ios: Use argumentForIndex rather than NSArray extension
-* CB-7955 Add support "browser" platform
+### 0.2.10 (Sep 17, 2014)
+* CB-7538 Android beep thread fix Beep now executes in it's own thread. It was previously executing in the main UI thread which was causing the application to lock up will the beep was occurring.  Closing pull request
+* Set dialog text dir to locale
+* Renamed test dir, added nested plugin.xml
+* added documentation for manual tests
+* CB-6965 Added manual tests
+* CB-6965 Port notification tests to test-framework
 
-### 1.0.0 (Apr 15, 2015)
-* CB-8746 gave plugin major version bump
-* CB-8683 updated wp and bb specific references of old id to new id
-* CB-8683 changed plugin-id to pacakge-name
-* CB-8653 properly updated translated docs to use new id
-* CB-8653 updated translated docs to use new id
-* Use TRAVIS_BUILD_DIR, install paramedic by npm
-* CB-8653 Updated Readme
-* CB-8659: ios: 4.0.x Compatibility: Remove use of deprecated headers
-* CB-8565 Integrate TravisCI
-* CB-8438 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs
-* CB-8538 Added package.json file
-* CB-8367 [org.apache.cordova.dialogs] Add Prompt support on Windows
+### 0.2.9 (Aug 06, 2014)
+* ubuntu: pass proper arguments to prompt callback
+* ubuntu: use TextField instead of TextInput
+* ubuntu: proper message escaping before passing to qml
+* **FFOS** update notification.js
+* CB-6127 Updated translations for docs
+* android: Explicitly apply default theme to dialogs
+* Fix Beep exception on Android when no argument passed
 
-### 1.1.0 (May 06, 2015)
-* CB-8928: Removed direct call to `toStaticHTML`, only call it if we are sure it's present. This closes #52
-* CB-7734 - `navigator.notification.alert` or `navigator.notification.confirm` seem have a "many words" issue. (closes #39)
+### 0.2.8 (Jun 05, 2014)
+* CB-6801 Add license
+* running original windows.open, inAppBrowser is overriding it no need to place CSS in every page anymore
+* CB-5945 [Windows8] do not call success callbacks until dialog is dismissed
+* CB-4616 Returned index 0 was not documented for notification.prompt
+* update docs to state that prompt is supported on windowsphone
+* CB-6528 allow scroll on alert message content
+* [CB-6628][amazon-fireos]dialogs plugin's confirm and prompt methods dont work confirm() method was missing amazon-fireos platform check. added that. prompt() method had bug. It is executed in a worker thread that does not have a message queue(or Looper object) associated with it and hence "can't create a handler" exception is thrown. To fix this issue, we need to create the EditText widget from within the UI thread. This was fixed sometime ago when we added fireos platform but commit got lost somewhere. So fixing it again now.
+* CB-6491 add CONTRIBUTING.md
+* Added check for isFinishing() on the parent activity to prevent crashes when trying to display dialogs when activity is in this phase of it's lifecycle
+* CB-4966 Dialogs are in window now No need to add anything to manifest or index.html
+* Removing FirefoxOS Quirks * no need to add special permission (it's different API with the same name) * notification.css is added automatically
 
-### 1.1.1 (Jun 17, 2015)
-* CB-9128 cordova-plugin-dialogs documentation translation: cordova-plugin-dialogs
-* fix npm md
+### 0.2.7 (Apr 17, 2014)
+* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
+* CB-6411: [BlackBerry10] Work around Audio playback issue
+* CB-6411: [BlackBerry10] Updates to beep
+* CB-6422: [windows8] use cordova/exec/proxy
+* CB-6460: Update license headers
+* Add NOTICE file
+
+### 0.2.6 (Feb 05, 2014)
+* no need to recreate the manifest.webapp file after each `cordova prepare` for FFOS
+* FFOS description added
+
+### 0.2.5 (Jan 02, 2014)
+* CB-4696 Fix compile error for Xcode 4.5.
+* CB-5658 Add doc/index.md for Dialogs plugin
+* CB-3762 Change prompt default to empty string
+* Move images from css to img
+
+### 0.2.4 (Dec 4, 2013)
+* add ubuntu platform
+* 1. Added amazon-fireos platform. 2. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'.
+* added beep funtionality using ms-winsoundevent:Notfication.Default
+
+### 0.2.3 (Oct 28, 2013)
+* CB-5128: added repo + issue tag to plugin.xml for dialogs plugin
+* new plugin execute arguments supported
+* new plugin style
+* smaller fonts styling input
+* img files copied inside plugin
+* style added
+* prompt added
+* styling from James
+* fixed "exec" calls addedd css, but not working yet
+* first (blind) try
+* [CB-4915] Incremented plugin version on dev branch.
+
+### 0.2.2 (Sept 25, 2013)
+* CB-4889 bumping&resetting version
+* [windows8] commandProxy was moved
+* CB-4889 renaming reference in Notification.cs
+* CB-4889 renaming org.apache.cordova.core.dialogs to org.apache.cordova.dialogs
+* Rename CHANGELOG.md -> RELEASENOTES.md
+* [CB-4592] [Blackberry10] Added beep support
+* [CB-4752] Incremented plugin version on dev branch.
diff --git a/src/android/Notification.java b/src/android/Notification.java
old mode 100755
new mode 100644
index 3bc3cee..9be56c0
--- a/src/android/Notification.java
+++ b/src/android/Notification.java
@@ -21,6 +21,7 @@
 import org.apache.cordova.CallbackContext;
 import org.apache.cordova.CordovaInterface;
 import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.LOG;
 import org.apache.cordova.PluginResult;
 import org.json.JSONArray;
 import org.json.JSONException;
@@ -48,6 +49,8 @@
  */
 public class Notification extends CordovaPlugin {
 
+    private static final String LOG_TAG = "Notification";
+    
     public int confirmResult = -1;
     public ProgressDialog spinnerDialog = null;
     public ProgressDialog progressDialog = null;
@@ -139,6 +142,7 @@
                             try {
                                 Thread.sleep(100);
                             } catch (InterruptedException e) {
+                                Thread.currentThread().interrupt();
                             }
                         }
                     }
@@ -215,7 +219,9 @@
                                     callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 1));
                                 }
                             });
-                    } catch (JSONException e) { }
+                    } catch (JSONException e) {
+                        LOG.d(LOG_TAG,"JSONException on first button.");
+                    }
                 }
 
                 // Second button
@@ -228,7 +234,9 @@
                                     callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 2));
                                 }
                             });
-                    } catch (JSONException e) { }
+                    } catch (JSONException e) {
+                        LOG.d(LOG_TAG,"JSONException on second button.");
+                    }
                 }
 
                 // Third button
@@ -241,7 +249,9 @@
                                   callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, 3));
                                 }
                             });
-                    } catch (JSONException e) { }
+                    } catch (JSONException e) {
+                        LOG.d(LOG_TAG,"JSONException on third button.");
+                    }
                 }
                 dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                     public void onCancel(DialogInterface dialog)
@@ -296,11 +306,15 @@
                                     try {
                                         result.put("buttonIndex",1);
                                         result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());											
-                                    } catch (JSONException e) { e.printStackTrace(); }
+                                    } catch (JSONException e) {
+                                        LOG.d(LOG_TAG,"JSONException on first button.", e);
+                                    }
                                     callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                                 }
                             });
-                    } catch (JSONException e) { }
+                    } catch (JSONException e) {
+                        LOG.d(LOG_TAG,"JSONException on first button.");
+                    }
                 }
 
                 // Second button
@@ -313,11 +327,15 @@
                                     try {
                                         result.put("buttonIndex",2);
                                         result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
-                                    } catch (JSONException e) { e.printStackTrace(); }
+                                    } catch (JSONException e) {
+                                        LOG.d(LOG_TAG,"JSONException on second button.", e);
+                                    }
                                     callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                                 }
                             });
-                    } catch (JSONException e) { }
+                    } catch (JSONException e) {
+                        LOG.d(LOG_TAG,"JSONException on second button.");
+                    }
                 }
 
                 // Third button
@@ -330,11 +348,15 @@
                                     try {
                                         result.put("buttonIndex",3);
                                         result.put("input1", promptInput.getText().toString().trim().length()==0 ? defaultText : promptInput.getText());
-                                    } catch (JSONException e) { e.printStackTrace(); }
+                                    } catch (JSONException e) { 
+                                        LOG.d(LOG_TAG,"JSONException on third button.", e);
+                                    }
                                     callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, result));
                                 }
                             });
-                    } catch (JSONException e) { }
+                    } catch (JSONException e) {
+                        LOG.d(LOG_TAG,"JSONException on third button.");
+                    }
                 }
                 dlg.setOnCancelListener(new AlertDialog.OnCancelListener() {
                     public void onCancel(DialogInterface dialog){
diff --git a/src/ios/CDVNotification.m b/src/ios/CDVNotification.m
index 1581ad3..a4c95e9 100644
--- a/src/ios/CDVNotification.m
+++ b/src/ios/CDVNotification.m
@@ -23,6 +23,7 @@
 #define DIALOG_TYPE_PROMPT @"prompt"
 
 static void soundCompletionCallback(SystemSoundID ssid, void* data);
+static NSMutableArray *alertList = nil;
 
 @implementation CDVNotification
 
@@ -58,31 +59,32 @@
             
             alertController.view.frame =  alertFrame;
         }
-        
+
+        __weak CDVNotification* weakNotif = self;
+
         for (int n = 0; n < count; n++) {
             
             UIAlertAction* action = [UIAlertAction actionWithTitle:[buttons objectAtIndex:n] style:UIAlertActionStyleDefault handler:^(UIAlertAction * action)
-                                     {
-                                         CDVPluginResult* result;
-                                         
-                                         if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT]) {
-                                             
-                                             NSString* value0 = [[alertController.textFields objectAtIndex:0] text];
-                                             NSDictionary* info = @{
-                                                                    @"buttonIndex":@(n + 1),
-                                                                    @"input1":(value0 ? value0 : [NSNull null])
-                                                                    };
-                                             result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
-                                             
-                                         } else {
-                                             
-                                             result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n  + 1)];
-                                             
-                                         }
-                                         
-                                         [self.commandDelegate sendPluginResult:result callbackId:callbackId];
-                                         
-                                     }];
+            {
+                CDVPluginResult* result;
+
+                if ([dialogType isEqualToString:DIALOG_TYPE_PROMPT])
+                {
+                    NSString* value0 = [[alertController.textFields objectAtIndex:0] text];
+                    NSDictionary* info = @{
+                        @"buttonIndex":@(n + 1),
+                        @"input1":(value0 ? value0 : [NSNull null])
+                    };
+                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:info];
+                }
+                else
+                {
+                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:(int)(n  + 1)];
+                }
+
+                [weakNotif.commandDelegate sendPluginResult:result callbackId:callbackId];
+
+            }];
             [alertController addAction:action];
             
         }
@@ -94,12 +96,19 @@
             }];
         }
         
+        if(!alertList)
+            alertList = [[NSMutableArray alloc] init];
+        [alertList addObject:alertController];
         
+        if ([alertList count]==1) {
+            [self presentAlertcontroller];
+        }
         
-        [self.viewController presentViewController:alertController animated:YES completion:nil];
-        
-    } else {
+    }
+    else
+    {
 #endif
+
         CDVAlertView* alertView = [[CDVAlertView alloc]
                                    initWithTitle:title
                                    message:message
@@ -211,6 +220,26 @@
     playBeep([count intValue]);
 }
 
+-(UIViewController *)getTopPresentedViewController {
+    UIViewController *presentingViewController = self.viewController;
+    while(presentingViewController.presentedViewController != nil)
+    {
+        presentingViewController = presentingViewController.presentedViewController;
+    }
+    return presentingViewController;
+}
+
+-(void)presentAlertcontroller {
+    
+    __weak CDVNotification* weakNotif = self;
+    [self.getTopPresentedViewController presentViewController:[alertList firstObject] animated:YES completion:^{
+        [alertList removeObject:[alertList firstObject]];
+        if ([alertList count]>0) {
+            [weakNotif presentAlertcontroller];
+        }
+    }];
+    
+}
 
 @end
 
diff --git a/src/windows/NotificationProxy.js b/src/windows/NotificationProxy.js
index d1eb344..a8c5987 100644
--- a/src/windows/NotificationProxy.js
+++ b/src/windows/NotificationProxy.js
@@ -44,6 +44,7 @@
     dlgWrap.style.height = "100%";
     dlgWrap.style.backgroundColor = "rgba(0,0,0,0.25)";
     dlgWrap.style.zIndex = "100000";
+    dlgWrap.className = "dlgWrap";
 
     var dlg = document.createElement("div");
     dlg.style.width = "100%";
diff --git a/www/notification.js b/www/notification.js
index c3f70d0..44f25c1 100644
--- a/www/notification.js
+++ b/www/notification.js
@@ -37,7 +37,7 @@
      * @param {String} buttonLabel          Label of the close button (default: OK)
      */
     alert: function(message, completeCallback, title, buttonLabel) {
-        var _title = (title || "Alert");
+        var _title = (typeof title === "string" ? title : "Alert");
         var _buttonLabel = (buttonLabel || "OK");
         exec(completeCallback, null, "Notification", "alert", [message, _title, _buttonLabel]);
     },
@@ -52,7 +52,7 @@
      * @param {Array} buttonLabels          Array of the labels of the buttons (default: ['OK', 'Cancel'])
      */
     confirm: function(message, resultCallback, title, buttonLabels) {
-        var _title = (title || "Confirm");
+        var _title = (typeof title === "string" ? title : "Confirm");
         var _buttonLabels = (buttonLabels || ["OK", "Cancel"]);
 
         // Strings are deprecated!
@@ -92,8 +92,8 @@
      * @param {String} defaultText          Textbox input value (default: empty string)
      */
     prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
-        var _message = (message || "Prompt message");
-        var _title = (title || "Prompt");
+        var _message = (typeof message === "string" ? message : "Prompt message");
+        var _title = (typeof title === "string" ? title : "Prompt");
         var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
         var _defaultText = (defaultText || "");
         exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);