Dialog

dialogs~ Dialog

new Dialog()

Description:
  • A class for a Dialog box.

    An instance of a Dialog can be accessed indirectly by use of
    one of the showXxx methods.

Source:
Example

Show a basic simple OK Dialog box

  dialogs.showOk("Here's a nice OK dialog box!");

Methods

buttonJq(name) → {JQuery|null}

Description:
  • Return the button DOM for the given name.

Source:
Parameters:
Name Type Description
name String

The name of the button.

Returns:

the Button's jQuery DOM object or null if nothing found.

Type
JQuery | null

cancel(handleropt) → {module:dialogs~Dialog}

Description:
  • Add a 'cancel' handler to the Dialog or if no handler is specified,
    simulate clicking the Dialog's 'cancel' button.

Source:
See:
Parameters:
Name Type Attributes Description
handler function <optional>

if specified, the handler to be invoked
when the Dialog's 'cancel' button is clicked. The first argument of the
function callback is the Dialog instance.

Returns:
Type
module:dialogs~Dialog

click(name) → {module:dialogs~Dialog}

Description:
  • Click one of the Dialog's buttons.

Source:
Example

Show a Dialog with an OK button and click it 2 seconds later

var dlg = dialogs.showOk("This is an OK Dialog")
setTimeout(function () {
  dlg.click("ok")
}, 2000);
Parameters:
Name Type Description
name String

The name of the Dialog button to click.

Returns:
Type
module:dialogs~Dialog

close(nameopt, failopt) → {module:dialogs~Dialog}

Description:
  • Close the Dialog. This will remove the Dialog box from the screen.

Source:
Example

Open a Dialog and close it after 2 seconds

var dlg = dialogs.showOk("A notification");

setTimeout(function () {
  dlg.close();
}, 2000);
Parameters:
Name Type Attributes Description
name String <optional>

The name of the button used to close the dialog box.
This parameter is designed to be called from the Dialog JS framework itself.

fail * <optional>

optional failure reason. If truthy, the dialog's promise
will be rejected with this failure reason; otherwise, the promise will be
resolved.

Returns:
Type
module:dialogs~Dialog

content() → {JQuery}

Description:
  • If this dialog has content, return the jQuery DOM wrapper for it.

Source:
Returns:

The DOM wrapper for the content. This wrapper will
be empty if the dialog is shown with no content.

Type
JQuery

disableButton(name) → {module:dialogs~Dialog}

Description:
  • Disable a button.

Source:
Parameters:
Name Type Description
name String

The name of the button.

Returns:
Type
module:dialogs~Dialog

enableButton(name) → {module:dialogs~Dialog}

Description:
  • Enable a button.

Source:
Parameters:
Name Type Description
name String

The name of the button.

Returns:
Type
module:dialogs~Dialog
Description:
  • If this dialog has a header, return the jQuery DOM wrapper for it.

Source:
Since:
  • Niagara 4.12
Returns:

The DOM wrapper for the header. This wrapper will
be empty if the dialog is shown with no header.

Type
JQuery

hide() → {module:dialogs~Dialog}

Description:
  • Hide the Dialog without closing it. The preferred method
    to use is close.

Source:
Example

Hide a dialog box after 2 seconds

dialogs.showYesNo("Meeting alert! Do you want to be reminded in 10 seconds?")
       .yes(function (dialog) {
         dialog.hide();
           setTimeout(function () {
           dialog.show();
         }, 10000);
         return false;
       });
Returns:
Type
module:dialogs~Dialog

hideButton(name) → {module:dialogs~Dialog}

Description:
  • Hide a button.

Source:
Parameters:
Name Type Description
name String

The name of the button.

Returns:
Type
module:dialogs~Dialog

isClosed() → {Boolean}

Description:
  • Return true if the Dialog is closed and removed from the DOM.

Source:
Returns:

Return true if the Dialog has been closed.

Type
Boolean

isHidden() → {Dialog}

Description:
  • Return true if the Dialog is hidden.

Source:
Returns:

Return true if the Dialog has been hidden.

Type
Dialog

jq() → {JQuery}

Description:
  • Return the internal jQuery wrapped DOM element for the entire Dialog.

Source:
Returns:

the Dialog's jQuery DOM object.

Type
JQuery

no(handleropt) → {module:dialogs~Dialog}

Description:
  • Add a 'no' handler to the Dialog or if no handler is specified,
    simulate clicking the Dialog's 'no' button. The first argument of the
    function callback is the Dialog instance.

Source:
See:
Parameters:
Name Type Attributes Description
handler function <optional>

if specified, the handler to be invoked
when the Dialog's 'no' button is clicked.

Returns:
Type
module:dialogs~Dialog

ok(handleropt) → {module:dialogs~Dialog}

Description:
  • Add a 'ok' handler to the Dialog or if no handler is specified,
    simulate clicking the Dialog's 'ok' button.

Source:
See:
Parameters:
Name Type Attributes Description
handler function <optional>

if specified, the handler to be invoked
when the Dialog's 'ok' button is clicked. The first argument of the
function callback is the Dialog instance.

Returns:
Type
module:dialogs~Dialog

on(name, handler) → {module:dialogs~Dialog}

Description:
  • Add a callback handler for a button via its name. This callback
    handler will be invoked when the button is clicked.

    Any handler function can return a Promise. This
    can control when and if the Dialog box closes after the handler
    has been invoked. It should be noted that multiple handlers
    can be registered on a button.

    • If the handlers return nothing, the Dialog will be closed after
      all the Handlers have been invoked.
    • If one or more handlers return a Promise, the Dialog
      will only close after all the Promises have been resolved.
    • If one of the Promises is rejected, the Dialog will not close.
Source:
See:
Example

Register a function be to be called when the 'foo' button is clicked.

dialogs.show({
  content: "Show some stuff",
  buttons: [
    {
      name: "foo",
      handler: function () {
        alert("First annoying alert!");
      }
    }
  ]
}).on("foo", function () {
  alert("This will also be called when foo button is clicked.");
});
Parameters:
Name Type Description
name String

The name of the button to register the handler on.

handler function

The handler of the function to be
invoked when the button is clicked. When invoked, the first argument of the
handler is the Dialog instance.

Returns:
Type
module:dialogs~Dialog

promise() → {Promise}

Description:
  • Return a promise for the dialog that will be resolved when the dialog closes.
    This is useful when wanting to use dialogs in a promise chain when creating a user interface.

Source:
Returns:

The promise to be resolved.

Type
Promise

show() → {module:dialogs~Dialog}

Description:
  • Show the Dialog.

Source:
Example

Create a blank dialog box and then show it.

  dialogs.make("A dialog box with no buttons!")
         .show();
Returns:
Type
module:dialogs~Dialog

showButton(name) → {module:dialogs~Dialog}

Description:
  • Show a button.

Source:
Parameters:
Name Type Description
name String

The name of the button.

Returns:
Type
module:dialogs~Dialog

toBack() → {module:dialogs~Dialog}

Description:
  • Move the Dialog to the back.

Source:
Returns:
Type
module:dialogs~Dialog

toFront() → {module:dialogs~Dialog}

Description:
  • Move the Dialog to the front.

Source:
Returns:
Type
module:dialogs~Dialog

yes(handleropt) → {module:dialogs~Dialog}

Description:
  • Add a 'yes' handler to the Dialog or if no handler is specified,
    simulate clicking the Dialog's 'yes' button.

Source:
See:
Parameters:
Name Type Attributes Description
handler function <optional>

if specified, the handler to be invoked
when the Dialog's 'yes' button is clicked. The first argument of the
function callback is the Dialog instance.

Returns:
Type
module:dialogs~Dialog