You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by he...@apache.org on 2014/01/27 23:23:41 UTC

git commit: fixing index + prompt response

Updated Branches:
  refs/heads/dev 15ac14eac -> 3c1f5aecd


fixing index + prompt response


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/3c1f5aec
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/tree/3c1f5aec
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/diff/3c1f5aec

Branch: refs/heads/dev
Commit: 3c1f5aecdb2a9fe47a962708e2f0bc72c7148d7d
Parents: 15ac14e
Author: Piotr Zalewa <pi...@zalewa.info>
Authored: Mon Jan 27 14:36:51 2014 +0100
Committer: Herm Wong <he...@gmail.com>
Committed: Mon Jan 27 14:23:33 2014 -0800

----------------------------------------------------------------------
 src/firefoxos/notification.js | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs/blob/3c1f5aec/src/firefoxos/notification.js
----------------------------------------------------------------------
diff --git a/src/firefoxos/notification.js b/src/firefoxos/notification.js
index 7362934..5c14829 100644
--- a/src/firefoxos/notification.js
+++ b/src/firefoxos/notification.js
@@ -45,7 +45,7 @@ function modal(message, callback, title, buttonLabels, domObjects) {
     function addButton(label, index, recommended) {
         var button = document.createElement('button');
         button.appendChild(document.createTextNode(label));
-        button.labelIndex = index;
+        button.labelIndex = index + 1;
         button.addEventListener('click', callbackButton, false);
         if (recommended) {
           // TODO: default one listens to Enter key
@@ -56,7 +56,17 @@ function modal(message, callback, title, buttonLabels, domObjects) {
 
     // call callback and destroy modal
     function callbackButton() {
-        callback(this.labelIndex);
+        var promptInput = document.getElementById('prompt-input');
+        var promptValue;
+        var response;
+        if (promptInput) {
+            response = {
+                input1: promptInput.value,
+                buttonIndex: this.labelIndex
+            }
+        }
+        response = response || this.labelIndex;
+        callback(response);
         box.parentNode.removeChild(box);
     }
 }
@@ -80,16 +90,15 @@ var Notification = {
         modal(message, _callback, title, buttonLabels);
     },
     prompt: function(successCallback, errorCallback, args) {
-        console.log(args);
         var message = args[0];
         var title = args[1];
         var buttonLabels = args[2];
         var defaultText = args[3];
-        var _tempcallback = (successCallback || _empty);
-        function _callback(labelIndex) {
-            var content = document.getElementById('prompt-input').value;
-            successCallback(labelIndex, content);
-        }
+        var _callback = (successCallback || _empty);
+        // function _callback(labelIndex) {
+        //     console.log(content);
+        //     successCallback(labelIndex, content);
+        // }
         var inputParagraph = document.createElement('p');
         inputParagraph.classList.add('input');
         var inputElement = document.createElement('input');