Constructor
(abstract, protected) new SystemDialogBox(type, optionsopt, nullable)
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
type |
string | ||
options |
jrt.SystemDialogBox.Options |
<optional> <nullable> |
Extends
Members
(static, non-null) defaultOptions :jrt.SystemDialogBox.Options
Default dialog box options. They can be overridden with setDefaultOptions
or with the options parameter in the alert, confirm
and prompt methods.
Type:
(protected, constant, non-null) app :jrt.App
Reference to the app instance, just for convenience.
Type:
- Overrides:
(protected, non-null) buttons :HTMLElement
The paragraph that contains the dialog's buttons.
Type:
- HTMLElement
(protected, constant) dynamic :boolean
Type:
- boolean
- Overrides:
(nullable) form :jrt.Form
The first FORM element present in this view.
Type:
- Overrides:
(constant) id :string
The view id, which is the same as the element id.
Type:
- string
- Overrides:
(protected, non-null) options :jrt.SystemDialogBox.Options
Type:
(protected, non-null) para :HTMLElement
The last text paragraph in the dialog box.
Type:
- HTMLElement
(nullable) parent :jrt.View
The view that opened this dialog (which is also the view that lays behind it).
Type:
- Overrides:
(nullable) returnValue :jrt.DialogReturnValue
The return value for the dialog. It can be set with close
or by submitting a form with the "dialog" method from within the dialog.
If not set, it will be null.
Type:
- Overrides:
Methods
(static) alert(message, optionsopt, nullable) → (non-null) {jrt.AlertBox}
Opens an alert dialog box with a message, an optional title and an [Ok] button. The dialogs's return value is always null.
If the message is a string, the '\n' character creates a new paragraph. In this case, HTML tags found in the message are not interpreted (they are considered just text).
If the message is a string array, each string in the array is put in a paragraph and the '\n' character ignored. In this case, HTML tags found in the message are interpreted as HTML.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
message |
string | !Array.<string> | The dialog's message. |
|
options |
jrt.SystemDialogBox.Options |
<optional> <nullable> |
Options object to override default options. |
Returns:
The created dialog instance.
- Type
- jrt.AlertBox
(static) confirm(message, optionsopt, nullable) → (non-null) {jrt.ConfirmBox}
Opens a confirmation dialog box with a message, and optional title, an [OK]
button and a [Cancel] button.
If the buttonTextAlt option is not specified, the return value is true
if the user accepts and false if the user cancels.
If the buttonTextAlt option is specified, a third alternative button will
be shown with the specified text, between the [Ok] and [Cancel]
buttons. In this case, the returned value will be true if the accept button is pressed,
false if the alternative button is pressed, and null if the dialog is canceled.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
message |
string | !Array.<string> | The dialog's message (see |
|
options |
jrt.SystemDialogBox.Options |
<optional> <nullable> |
Options object to override default options. |
Returns:
The created dialog instance.
- Type
- jrt.ConfirmBox
(static) image(src, titleopt, nullable, classNameopt, nullable) → (non-null) {jrt.ImageBox}
Opens a dialog box with the specified image and optional title. The dialog also includes a close button. The dialog will only open if the image is successfully loaded.
This type of dialog box is opened automatically when an internal image link is followed. Such a link is defined by:
- It has the
typeattribute set to an image type. - If contains an
IMGelement. - It does not include the attribute
rel="external".
The opened image URL will be the one linked by the image link or, if the href
attribute is empty, the value of the contained image's src attribute.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
src |
string | ||
title |
string |
<optional> <nullable> |
|
className |
string |
<optional> <nullable> |
Returns:
The created dialog instance.
- Type
- jrt.ImageBox
(static) prompt(message, valueopt, nullable, optionsopt, nullable) → (non-null) {jrt.PromptBox}
Opens a prompt dialog box with a message, an optional title, an input field, an
[Ok] button and a [Cancel] button. The return value is
the input element's value (possibly an empty string) if the user accepts, and null
if the user cancels.
The autofocus option can be:
- "none": The input element does not receive the focus.
- "focus": The input element receives the focus (this is the default).
- "select": The input element receives the focus and the initial value is selected.
If the rows option is specified and it is bigger that 1, then the
prompt box will use a TEXTAREA element (instead of an INPUT
element) with its rows attribute set to the specified value.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
message |
string | !Array.<string> | The dialog's message (see |
|
value |
string |
<optional> <nullable> |
The initial input value (the empty string by default). |
options |
jrt.SystemDialogBox.Options |
<optional> <nullable> |
Options object to override default options. |
Returns:
The created dialog instance.
- Type
- jrt.PromptBox
(static) setDefaultOptions(optionsnon-null)
Overrides the default dialog options with the specified values.
Parameters:
| Name | Type | Description |
|---|---|---|
options |
jrt.SystemDialogBox.Options |
(protected) appendForm(message)
Creates the dialog's form and its common elements.
Parameters:
| Name | Type | Description |
|---|---|---|
message |
string | !Array.<string> |
close(returnValueopt, nullable) → {boolean}
Closes the modal dialog. If no return value is specified, the current return value remains.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
returnValue |
jrt.DialogReturnValue |
<optional> <nullable> |
The return value for the dialog. |
- Overrides:
Returns:
true If the dialog was actually closed.
- Type
- boolean
(protected) handleEvent(enon-null, labelnullable)
This method is called when an event registered with listenToEvent
is triggered.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
e |
Event | The event object. |
|
label |
string |
<nullable> |
The label specified when registering the event. |
- Overrides:
(protected) ignoreEvent(eventType, elementopt, nullable)
Stops listenig to the specified event type on the specified element.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType |
string | The event type to listen to. |
|
element |
Element |
<optional> <nullable> |
The HTML element to stop listening to. Defaults to this element. |
- Overrides:
(protected) listenToEvent(eventType, elementopt, nullable, labelopt, nullable, useCaptureopt)
Sets this object as the event listener for the specified event type and element.
The handleEvent method is called when the event occurs.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
eventType |
string | The event type to listen to. |
|
element |
Element |
<optional> <nullable> |
The HTML element to listen to. Defaults to this element. |
label |
string |
<optional> <nullable> |
Optional label passed to the event handler. |
useCapture |
boolean |
<optional> |
- Overrides:
(protected) processResponse(reqnon-null, status, responsenullable)
Implement this method to process the response received after a call to sendRequest.
The response data type depends on the responseType property specified in the request.
The response status can be "success", "server-error", "type-error" (when the specified response type does not match the received data), "error" (if there is a connection error), "timeout" or "offline". Note that the "offline" status is not reliable in all devices, so an "error" status may be received when offline.
The default implementation does nothing.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
req |
jrt.AjaxRequest | The request object. |
|
status |
string | The response status (see method description). |
|
response |
jrt.AjaxResponse |
<nullable> |
The server response. This will be null on error or timeout. |
- Overrides:
query(selector, baseElement) → (nullable) {HTMLElement}
Returns the first element that matches the specified selector. If no base element is specified, this block is used as base element. Returns null if no element is found.
Parameters:
| Name | Type | Description |
|---|---|---|
selector |
string | The CSS selector. |
baseElement |
HTMLElement | DocumentFragment | Optional base element. |
- Overrides:
Returns:
- Type
- HTMLElement
queryAll(selector, baseElement) → (non-null) {NodeList.<!HTMLElement>}
Returns all elements that match the specified selector. If no base element is specified, this element is used.
Parameters:
| Name | Type | Description |
|---|---|---|
selector |
string | The CSS selector. |
baseElement |
HTMLElement | DocumentFragment | Optional base element. |
- Overrides:
Returns:
- Type
- NodeList.<!HTMLElement>
(protected) sendRequest(reqnon-null)
Sends an asynchronous AJAX request to the URL specified in req'. The supported
methods are "GET" (the default), "POST", "PUT", "PATCH", "DELETE" and "HEAD".
The response will be passed to processResponse.
The expected response type can be specified with the responseType
property in the specified request ("json" by default).
Parameters:
| Name | Type | Description |
|---|---|---|
req |
jrt.AjaxRequest |
- Overrides:
Throws:
-
If any of the request parameters is invalid.
- Type
- Error
Type Definitions
Options
Configurable dialog box options.
Type:
- Object
Properties:
| Name | Type | Description |
|---|---|---|
title |
string | The dialog box title (none by default). |
class |
string | CSS classes to add to the dialog, sparated by spaces (optional). |
showCloseButton |
boolean | Whether to show a close button or not (false by default). The close button has no text. |
translateButtons |
boolean | Whether to translate text in buttons or not (false by default). |
buttonTextOk |
string | Ok button text (defaults to "OK"). |
buttonTextCancel |
string | Cancel button text (defaults to "Cancel"). |
buttonTextAlt |
string | Alternate button text for a confirm box (see |
autofocus |
string | The autofocus mode for a prompt box (see |
rows |
number | Number of rows for a prompt box (see |