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 paramsobject Properties
Name Type Description titleDefault value is "". The title to be displayed in the dialog.
messageDefault value is "". The message to be displayed in the dialog, next to the text input field.
confirmTextDefault value is "Ok". The text to be displayed for the confirm button.
cancelTextDefault value is "Cancel". The text to be displayed for the deny button.
callbackfunction Called when the user accepts or cancel the dialog, it receives an argument true/false.
Example
Cocoon.Dialog.confirm({ title : "This is the title", message : "Awesome message" }, function(accepted){ if(accepted){ alert("The user has accepted the dialog"); }else{ alert("The user has denied the dialog"); } }); -
<static> dismissKeyboard()
-
Dismisses a keyboard which was previusly shown by Cocoon.Dialog.showKeyboard
Example
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 paramobject Object information.
Properties
Name Type Argument Description titlestring <optional>
The title to be displayed in the dialog.
messagestring <optional>
The message to be displayed in the dialog, next to the text input field.
textstring <optional>
The initial text to be introduced in the text input field.
typeCocoon.Dialog.keyboardType <optional>
Default value is Cocoon.Dialog.keyboardType.TEXT. The keyboard type to be used when the text has to be introduced.
cancelTextstring <optional>
Default value is "Cancel". The text to be displayed in the cancel button of the dialog.
confirmTextstring <optional>
Default value is "Ok". The text to be displayed in the ok button of the dialog.
secureTextboolean <optional>
Default value is "false". The text to be displayed as secure (password-like).
callbackscallback success and cancel callbacks called when the user confirms or cancel the dialog.
Example
Cocoon.Dialog.prompt({ title : "title", message : "message" },{ success : function(text){ ... }, cancel : function(){ ... } }); -
<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 paramobject Object information.
Properties
Name Type Argument Description typeCocoon.Dialog.keyboardType <optional>
Default value is Cocoon.Dialog.keyboardType.TEXT. The keyboard type to be used when the text has to be introduced.
callbackscallback insertText, deleteBackward, done, cancel callbacks called when the user clicks a key, confirms or cancels the keyboard session.
Example
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.keyboardTypeobject Types of input keyboard.
Properties
Name Type Description TEXTstring Represents a generic text input keyboard.
NUMBERstring Represents a number like input keyboard.
PHONEstring Represents a phone like input keyboard.
EMAILstring Represents an email like input keyboard.
URLstring Represents an URL like input keyboard.