All Projects → apache → Cordova Plugin Dialogs

apache / Cordova Plugin Dialogs

Licence: apache-2.0
Apache Cordova Plugin dialogs

Programming Languages

javascript
184084 projects - #8 most used programming language
java
68154 projects - #9 most used programming language
csharp
926 projects
cplusplus
227 projects

Projects that are alternatives of or similar to Cordova Plugin Dialogs

Cordova Browser
Apache Cordova
Stars: ✭ 142 (-46.82%)
Mutual labels:  library, mobile, cordova
Cordova Node Xcode
Apache cordova
Stars: ✭ 128 (-52.06%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Inappbrowser
Apache Cordova Plugin inappbrowser
Stars: ✭ 994 (+272.28%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Device Motion
Apache Cordova Plugin device-motion
Stars: ✭ 58 (-78.28%)
Mutual labels:  library, mobile, cordova
Cordova Windows
Apache Cordova Windows
Stars: ✭ 188 (-29.59%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Test Framework
Apache Cordova
Stars: ✭ 66 (-75.28%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Console
[DEPRECATED] Apache Cordova Plugin console
Stars: ✭ 145 (-45.69%)
Mutual labels:  library, mobile, cordova
Cordova Plugin File
Apache Cordova Plugin file
Stars: ✭ 664 (+148.69%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Contacts
Apache Cordova Plugin contacts
Stars: ✭ 203 (-23.97%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Camera
Apache Cordova Plugin camera
Stars: ✭ 879 (+229.21%)
Mutual labels:  library, mobile, cordova
Cordova Mobile Spec
Apache Cordova mobile-spec
Stars: ✭ 57 (-78.65%)
Mutual labels:  library, mobile, cordova
Cordova Osx
Apache Cordova mac
Stars: ✭ 232 (-13.11%)
Mutual labels:  library, mobile, cordova
Cordova App Harness
[DEPRECATED] Apache Cordova app harness
Stars: ✭ 49 (-81.65%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Vibration
Apache Cordova Plugin vibration
Stars: ✭ 109 (-59.18%)
Mutual labels:  library, mobile, cordova
Cordova Firefoxos
[DEPRECATED] Apache Cordova firefoxos
Stars: ✭ 41 (-84.64%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Globalization
Apache Cordova Plugin globalization
Stars: ✭ 131 (-50.94%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Splashscreen
Apache Cordova Plugin splashscreen
Stars: ✭ 602 (+125.47%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Wkwebview Engine
[DEPRECATED] Apache Cordova wkwebview engine plugin
Stars: ✭ 607 (+127.34%)
Mutual labels:  library, mobile, cordova
Cordova Cli
Apache Cordova CLI
Stars: ✭ 861 (+222.47%)
Mutual labels:  library, mobile, cordova
Cordova Plugin Screen Orientation
Cordova Plugin Screen Orientation
Stars: ✭ 181 (-32.21%)
Mutual labels:  library, mobile, cordova

title: Dialogs description: Use native dialog UI elements

AppVeyor Travis CI
Build status Build Status

cordova-plugin-dialogs

This plugin provides access to some native dialog UI elements via a global navigator.notification object.

Although the object is attached to the global scoped navigator, it is not available until after the deviceready event.

document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
    console.log(navigator.notification);
}

Installation

cordova plugin add cordova-plugin-dialogs

Methods

  • navigator.notification.alert
  • navigator.notification.confirm
  • navigator.notification.prompt
  • navigator.notification.beep
  • navigator.notification.dismissPrevious
  • navigator.notification.dismissAll

navigator.notification.alert

Shows a custom alert or dialog box. Most Cordova implementations use a native dialog box for this feature, but some platforms use the browser's alert function, which is typically less customizable.

navigator.notification.alert(message, alertCallback, [title], [buttonName])
  • message: Dialog message. (String)

  • alertCallback: Callback to invoke when alert dialog is dismissed. (Function)

  • title: Dialog title. (String) (Optional, defaults to Alert)

  • buttonName: Button name. (String) (Optional, defaults to OK)

Example

function alertDismissed() {
    // do something
}

navigator.notification.alert(
    'You are the winner!',  // message
    alertDismissed,         // callback
    'Game Over',            // title
    'Done'                  // buttonName
);

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows

navigator.notification.confirm

Displays a customizable confirmation dialog box.

navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
  • message: Dialog message. (String)

  • confirmCallback: Callback to invoke with index of button pressed (1, 2, or 3) or when the dialog is dismissed without a button press (0). (Function)

  • title: Dialog title. (String) (Optional, defaults to Confirm)

  • buttonLabels: Array of strings specifying button labels. (Array) (Optional, defaults to [OK,Cancel])

confirmCallback

The confirmCallback executes when the user presses one of the buttons in the confirmation dialog box.

The callback takes the argument buttonIndex (Number), which is the index of the pressed button. Note that the index uses one-based indexing, so the value is 1, 2, 3, etc.

Example

function onConfirm(buttonIndex) {
    alert('You selected button ' + buttonIndex);
}

navigator.notification.confirm(
    'You are the winner!', // message
     onConfirm,            // callback to invoke with index of button pressed
    'Game Over',           // title
    ['Restart','Exit']     // buttonLabels
);

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows

Android Quirks

  • Android supports a maximum of three buttons, and ignores any more than that.

  • Android dialog title cannot exceed 2 lines of content, it will ignore any more than this.

Windows Quirks

  • On Windows8/8.1 it is not possible to add more than three buttons to MessageDialog instance.

  • On Windows Phone 8.1 it's not possible to show dialog with more than two buttons.

navigator.notification.prompt

Displays a native dialog box that is more customizable than the browser's prompt function.

navigator.notification.prompt(message, promptCallback, [title], [buttonLabels], [defaultText])
  • message: Dialog message. (String)

  • promptCallback: Callback to invoke with index of button pressed (1, 2, or 3) or when the dialog is dismissed without a button press (0). (Function)

  • title: Dialog title (String) (Optional, defaults to Prompt)

  • buttonLabels: Array of strings specifying button labels (Array) (Optional, defaults to ["OK","Cancel"])

  • defaultText: Default textbox input value (String) (Optional, Default: empty string)

promptCallback

The promptCallback executes when the user presses one of the buttons in the prompt dialog box. The results object passed to the callback contains the following properties:

  • buttonIndex: The index of the pressed button. (Number) Note that the index uses one-based indexing, so the value is 1, 2, 3, etc.

  • input1: The text entered in the prompt dialog box. (String)

Example

function onPrompt(results) {
    alert("You selected button number " + results.buttonIndex + " and entered " + results.input1);
}

navigator.notification.prompt(
    'Please enter your name',  // message
    onPrompt,                  // callback to invoke
    'Registration',            // title
    ['Ok','Exit'],             // buttonLabels
    'Jane Doe'                 // defaultText
);

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows

Android Quirks

  • Android supports a maximum of three buttons, and ignores any more than that.

  • On Android 3.0 and later, buttons are displayed in reverse order for devices that use the Holo theme.

Windows Quirks

  • On Windows prompt dialog is html-based due to lack of such native api.

navigator.notification.beep

The device plays a beep sound.

navigator.notification.beep(times);
  • times: The number of times to repeat the beep. (Number)

Example

// Beep twice!
navigator.notification.beep(2);

Supported Platforms

  • Android
  • Browser
  • iOS
  • Windows 8

Android Quirks

  • Android plays the default Notification ringtone specified under the Settings/Sound & Display panel.

navigator.notification.dismissPrevious

Dismisses the previously opened dialog box. If no dialog box is currently open, the errorCallback will be called.

navigator.notification.dismissPrevious([successCallback], [errorCallback])
  • successCallback: Callback to invoke when previously opened dialog has been dismissed. (Function) (Optional)
  • errorCallback: Callback to invoke on failure to dismiss previously opened dialog. Will be passed the error message. (Function) (Optional)

Example

function successCallback() {
    console.log("Successfully dismissed previously opened dialog.");
}

function errorCallback(error) {
    console.log("Failed to dismiss previously opened dialog: " + error);
}

navigator.notification.dismissPrevious(
    successCallback,
    errorCallback
);

Supported Platforms

  • Android
  • iOS

navigator.notification.dismissAll

Dismisses all previously opened dialog boxes. If no dialog box is currently open, the errorCallback will be called.

navigator.notification.dismissAll([successCallback], [errorCallback])
  • successCallback: Callback to invoke when all previously opened dialogs have been dismissed. (Function) (Optional)
  • errorCallback: Callback to invoke on failure to dismiss all previously opened dialogs. Will be passed the error message. (Function) (Optional)

Example

function successCallback() {
    console.log("Successfully dismissed all previously opened dialogs.");
}

function errorCallback(error) {
    console.log("Failed to dismiss all previously opened dialogs: " + error);
}

navigator.notification.dismissAll(
    successCallback,
    errorCallback
);

Supported Platforms

  • Android
  • iOS
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].