A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cordova.apache.org/docs/en/latest/guide/support/../../reference/cordova-plugin-dialogs/ below:

Dialogs - Apache Cordova

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

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])
Example
function alertDismissed() {
    // do something
}

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

Displays a customizable confirmation dialog box.

navigator.notification.confirm(message, confirmCallback, [title], [buttonLabels])
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 Quirks Windows Quirks 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])
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:

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 Quirks Windows Quirks navigator.notification.beep

The device plays a beep sound.

navigator.notification.beep(times);
Example
// Beep twice!
navigator.notification.beep(2);
Supported Platforms Android Quirks 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])
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 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])
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

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.3