cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject spec commit: CB-2680 - Add prompt dialog to Notification API
Date Thu, 21 Mar 2013 03:11:44 GMT
Updated Branches:
  refs/heads/master c5107bb8c -> 64e9bbadf


CB-2680 - Add prompt dialog to Notification API


Project: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/commit/64e9bbad
Tree: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/tree/64e9bbad
Diff: http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/diff/64e9bbad

Branch: refs/heads/master
Commit: 64e9bbadfc00e633bc7182b32c3fa0d699d1b9ea
Parents: c5107bb
Author: mbillau <mike.billau@gmail.com>
Authored: Tue Mar 19 16:01:34 2013 -0400
Committer: Andrew Grieve <agrieve@chromium.org>
Committed: Wed Mar 20 23:05:09 2013 -0400

----------------------------------------------------------------------
 autotest/tests/notification.tests.js |    5 +++
 notification/index.html              |   48 +++++++++++++++++++++++-----
 2 files changed, 44 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/64e9bbad/autotest/tests/notification.tests.js
----------------------------------------------------------------------
diff --git a/autotest/tests/notification.tests.js b/autotest/tests/notification.tests.js
index 3749a89..6b9f242 100644
--- a/autotest/tests/notification.tests.js
+++ b/autotest/tests/notification.tests.js
@@ -43,4 +43,9 @@ describe('Notification (navigator.notification)', function () {
 		expect(typeof navigator.notification.confirm).toBeDefined();
 		expect(typeof navigator.notification.confirm).toBe("function");
 	});
+	
+	it("should contain a prompt function", function() {
+		expect(typeof navigator.notification.prompt).toBeDefined();
+		expect(typeof navigator.notification.prompt).toBe("function");
+	});
 });

http://git-wip-us.apache.org/repos/asf/cordova-mobile-spec/blob/64e9bbad/notification/index.html
----------------------------------------------------------------------
diff --git a/notification/index.html b/notification/index.html
index 9940ee5..1e99f0b 100644
--- a/notification/index.html
+++ b/notification/index.html
@@ -59,8 +59,13 @@
     var confirmDialogA = function(message, title, buttons) {
         navigator.notification.confirm(message,
             function(r) {
-                console.log("You selected " + r);
-                alert("You selected " + (buttons.split(","))[r-1]);
+                if(r===0){
+                    console.log("Dismissed dialog without making a selection.");
+                    alert("Dismissed dialog without making a selection.");
+                }else{
+                    console.log("You selected " + r);
+                    alert("You selected " + (buttons.split(","))[r-1]);
+                }
             },
             title,
             buttons);
@@ -69,13 +74,36 @@
     var confirmDialogB = function(message, title, buttons) {
         navigator.notification.confirm(message,
             function(r) {
-                console.log("You selected " + r);
-                alert("You selected " + buttons[r-1]);
+                if(r===0){
+                    console.log("Dismissed dialog without making a selection.");
+                    alert("Dismissed dialog without making a selection.");
+                }else{
+                    console.log("You selected " + r);
+                    alert("You selected " + buttons[r-1]);
+                }
             },
             title,
             buttons);
     };
 
+    var promptDialog = function(message, title, buttons) {
+        navigator.notification.prompt(message,
+            function(r) {
+                if(r && r.buttonIndex===0){
+                    var msg = "Dismissed dialog";
+                    if( r.input1 ){
+                        msg+=" with input: " + r.input1
+                    }
+                    console.log(msg);
+                    alert(msg);
+                }else{
+                    console.log("You selected " + r.buttonIndex + " and entered: " + r.input1);
+                    alert("You selected " + buttons[r.buttonIndex-1] + " and entered: " +
r.input1);
+                }
+            },
+            title,
+            buttons);
+    };
     /**
      * Function called when page has finished loading.
      */
@@ -85,9 +113,9 @@
                 console.log("Device="+device.platform+" "+device.version);
             }, false);
         window.setTimeout(function() {
-        	if (!deviceReady) {
-        		alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
-        	}
+            if (!deviceReady) {
+                alert("Error: Apache Cordova did not initialize.  Demo will not run correctly.");
+            }
         },1000);
     }
 
@@ -104,8 +132,10 @@
     <div class="btn large" onclick="beep();">Beep</div>
     <div class="btn large" onclick="vibrate();">Vibrate</div>
     <div class="btn large" onclick="alertDialog('You pressed alert.', 'Alert Dialog',
'Continue');">Alert Dialog</div>
-    <div class="btn large" onclick="confirmDialogA('You pressed confirm.', 'Confirm Dialog',
'Yes,No,Maybe');">Confirm Dialog A</div>
-    <div class="btn large" onclick="confirmDialogB('You pressed confirm.', 'Confirm Dialog',
['Yes', 'No', 'Maybe, Not Sure']);">Confirm Dialog B</div>
+    <div class="btn large" onclick="confirmDialogA('You pressed confirm.', 'Confirm Dialog',
'Yes,No,Maybe');">Confirm Dialog - Deprecated</div>
+    <div class="btn large" onclick="confirmDialogB('You pressed confirm.', 'Confirm Dialog',
['Yes', 'No', 'Maybe, Not Sure']);">Confirm Dialog</div>
+    <div class="btn large" onclick="promptDialog('You pressed prompt.', 'Prompt Dialog',
['Yes', 'No', 'Maybe, Not Sure']);">Prompt Dialog</div>
+    
     <div class="btn large" onclick="alert('You pressed alert.');">Built-in Alert Dialog</div>
     <div class="btn large" onclick="confirm('You selected confirm');">Built-in Confirm
Dialog</div>
     <div class="btn large" onclick="prompt('This is a prompt.', 'Default value');">Built-in
Prompt Dialog</div>


Mime
View raw message