Dialog functions (prompt / confirm).
Methods
-
<static> confirm(params, callback)
-
Pops up a message dialog so the user can decide between a yes or no like confirmation.
Parameters:
Name Type Description params
object Properties
Name Type Description title
Default value is "". The title to be displayed in the dialog.
message
Default value is "". The message to be displayed in the dialog, next to the text input field.
confirmText
Default value is "Ok". The text to be displayed for the confirm button.
cancelText
Default value is "Cancel". The text to be displayed for the deny button.
callback
function Called when the user accepts or cancel the dialog, it receives an argument true/false.
Example
-
<static> dismissKeyboard()
-
Dismisses a keyboard which was previusly shown by Cocoon.Dialog.showKeyboard
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
var text = ""; Cocoon.Dialog.showKeyboard({ type: Cocoon.Dialog.keyboardType.TEXT, }, { insertText: function(inserted) { if (inserted === "A") { //Custom keyboard hide Cocoon.Dialog.dismissKeyboard(); } text += inserted; console.log(text); }, deleteBackward: function() { text = text.slice(0, text.length - 1); console.log(text); }, done: function() { console.log("user clicked done key"); }, cancel: function() { console.log("user dismissed keyboard"); } });
-
<static> prompt(param, callbacks)
-
Pops up a text dialog so the user can introduce some text and the application can get it back. It is the first approach Cocoon has taken to be able to introduce text input in a easy way. The dialog execution events are passed to the application through the Cocoon.Dialog.onTextDialogFinished and the Cocoon.Dialog.onTextDialogCancelled event objects.
Parameters:
Name Type Description param
object Object information.
Properties
Name Type Argument Description title
string <optional>
The title to be displayed in the dialog.
message
string <optional>
The message to be displayed in the dialog, next to the text input field.
text
string <optional>
The initial text to be introduced in the text input field.
type
Cocoon.Dialog.keyboardType <optional>
Default value is Cocoon.Dialog.keyboardType.TEXT. The keyboard type to be used when the text has to be introduced.
cancelText
string <optional>
Default value is "Cancel". The text to be displayed in the cancel button of the dialog.
confirmText
string <optional>
Default value is "Ok". The text to be displayed in the ok button of the dialog.
secureText
boolean <optional>
Default value is "false". The text to be displayed as secure (password-like).
callbacks
callback success and cancel callbacks called when the user confirms or cancel the dialog.
Example
-
<static> showKeyboard(param, callbacks)
-
Shows a keyboard to receive user input. The developer has to process input events and render the resulting text.
Parameters:
Name Type Description param
object Object information.
Properties
Name Type Argument Description type
Cocoon.Dialog.keyboardType <optional>
Default value is Cocoon.Dialog.keyboardType.TEXT. The keyboard type to be used when the text has to be introduced.
callbacks
callback insertText, deleteBackward, done, cancel callbacks called when the user clicks a key, confirms or cancels the keyboard session.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
var text = ""; Cocoon.Dialog.showKeyboard({ type: Cocoon.Dialog.keyboardType.TEXT, }, { insertText: function(inserted) { text += inserted; console.log(text); }, deleteBackward: function() { text = text.slice(0, text.length - 1); console.log(text); }, done: function() { console.log("user clicked done key"); }, cancel: function() { console.log("user dismissed keyboard"); } });
Members
-
<static> keyboardType
-
Properties:
Name Type Description Cocoon.Dialog.keyboardType
object Types of input keyboard.
Properties
Name Type Description TEXT
string Represents a generic text input keyboard.
NUMBER
string Represents a number like input keyboard.
PHONE
string Represents a phone like input keyboard.
EMAIL
string Represents an email like input keyboard.
URL
string Represents an URL like input keyboard.