You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mw...@apache.org on 2013/03/20 21:15:19 UTC
docs commit: CB-2677: Doc adding prompt to Notification API
Updated Branches:
refs/heads/master 08d685ec1 -> ce4ac58df
CB-2677: Doc adding prompt to Notification API
-added new notification.prompt.md file with API and samples
-updated to include prompt in Notification API reference
Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/ce4ac58d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/ce4ac58d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/ce4ac58d
Branch: refs/heads/master
Commit: ce4ac58dfcc5c9a211b05feedc5063bb80a3a808
Parents: 08d685e
Author: James Jong <wj...@gmail.com>
Authored: Tue Mar 19 13:43:14 2013 -0400
Committer: Michael Brooks <mi...@michaelbrooks.ca>
Committed: Wed Mar 20 13:14:00 2013 -0700
----------------------------------------------------------------------
docs/en/edge/config.json | 1 +
docs/en/edge/cordova/notification/notification.md | 1 +
.../cordova/notification/notification.prompt.md | 120 +++++++++++++++
3 files changed, 122 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/ce4ac58d/docs/en/edge/config.json
----------------------------------------------------------------------
diff --git a/docs/en/edge/config.json b/docs/en/edge/config.json
index 2af4a62..1887fd2 100644
--- a/docs/en/edge/config.json
+++ b/docs/en/edge/config.json
@@ -167,6 +167,7 @@
"cordova/notification/notification.md",
"cordova/notification/notification.alert.md",
"cordova/notification/notification.confirm.md",
+ "cordova/notification/notification.prompt.md",
"cordova/notification/notification.beep.md",
"cordova/notification/notification.vibrate.md"
],
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/ce4ac58d/docs/en/edge/cordova/notification/notification.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/cordova/notification/notification.md b/docs/en/edge/cordova/notification/notification.md
index 1c33c9f..2f6c059 100644
--- a/docs/en/edge/cordova/notification/notification.md
+++ b/docs/en/edge/cordova/notification/notification.md
@@ -27,6 +27,7 @@ Methods
- notification.alert
- notification.confirm
+- notification.prompt
- notification.beep
- notification.vibrate
http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/ce4ac58d/docs/en/edge/cordova/notification/notification.prompt.md
----------------------------------------------------------------------
diff --git a/docs/en/edge/cordova/notification/notification.prompt.md b/docs/en/edge/cordova/notification/notification.prompt.md
new file mode 100644
index 0000000..57bcbd7
--- /dev/null
+++ b/docs/en/edge/cordova/notification/notification.prompt.md
@@ -0,0 +1,120 @@
+---
+license: Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+---
+
+notification.prompt
+====================
+
+Shows a customizable prompt dialog box.
+
+ navigator.notification.prompt(message, promptCallback, [title], [buttonLabels])
+
+- __message:__ Dialog message (`String`)
+- __promptCallback:__ - Callback to invoke when a button is pressed (`Function`)
+- __title:__ Dialog title (`String`) (Optional, Default: "Prompt")
+- __buttonLabels:__ Array of strings for the button labels (`Array`) (Optional, Default: ["OK","Cancel"])
+
+Description
+-----------
+
+Function `notification.prompt` displays a native dialog box that is more customizable than the browser's `prompt` function.
+
+promptCallback
+---------------
+
+The `promptCallback` is called when the user has pressed one of the buttons on the prompt dialog box.
+
+The callback takes the argument `results` which contains the following properties:
+
+- __buttonIndex:__ (`Number`), which is the index of the pressed button. It's important to note that the index uses one-based indexing, so the value will be `1`, `2`, `3`, etc.
+- __input1:__ (`String`), which is the text entered in the prompt dialog box.
+
+Supported Platforms
+-------------------
+
+- Android
+- iPhone
+
+Quick Example
+-------------
+
+ // process the promp dialog results
+ function onPrompt(results) {
+ alert("You selected button number " + results.buttonIndex + " and entered " + results.input1);
+ }
+
+ // Show a custom prompt dialog
+ //
+ function showPrompt() {
+ navigator.notification.prompt(
+ 'Please enter your name', // message
+ onPrompt, // callback to invoke
+ 'Registration', // title
+ ['Ok','Exit'] // buttonLabels
+ );
+ }
+
+Full Example
+------------
+
+ <!DOCTYPE html>
+ <html>
+ <head>
+ <title>Notification Prompt Dialog Example</title>
+
+ <script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
+ <script type="text/javascript" charset="utf-8">
+
+ // Wait for Cordova to load
+ //
+ document.addEventListener("deviceready", onDeviceReady, false);
+
+ // Cordova is ready
+ //
+ function onDeviceReady() {
+ // Empty
+ }
+
+ // process the promptation dialog result
+ function onPrompt(results) {
+ alert("You selected button number " + results.buttonIndex + " and entered " + results.input1);
+ }
+
+ // Show a custom prompt dialog
+ //
+ function showPrompt() {
+ navigator.notification.prompt(
+ 'Please enter your name', // message
+ onPrompt, // callback to invoke
+ 'Registration', // title
+ ['Ok','Exit'] // buttonLabels
+ );
+ }
+
+ </script>
+ </head>
+ <body>
+ <p><a href="#" onclick="showPrompt(); return false;">Show Prompt</a></p>
+ </body>
+ </html>
+
+Android Quirks
+----------------------
+
+- Android supports up to a maximum of 3 buttons. Additional button labels over 3 are ignored.
+- On Android 3.0 and later, the buttons will be displayed in reverse order for devices using the Holo theme.