Popups: Confirmation Window

Method confirm() shows new confirmation window.

Syntax

AWN.confirm([message,onOk,onCancel,options])

Parameters

message - optional

Defines message of the confirmation window. Can be any valid HTML or text string.

onOk - optional

Defines Function, which will be executed on click to ‘OK’ button.

onCancel - optional

Defines Function, which will be executed on click to ‘Cancel’ button.
If false was passed, ‘Cancel’ button will be hidden.

options - optional

Instance of Options, which will override globals for this call

Return value

A new HTMLElement instance

Behaviour

Confirmation window can be closed by clicking on one of two buttons.

Also you can use Esc key to close it. Focus will be set on OK button on opening by default.

Focus will be trapped inside window, so user can use Tab (Shift+Tab) key only to switch between one of two buttons.

Examples

Use defaults

new AWN().confirm()

Use custom


  let notifier = new AWN();
  let onOk = () => {notifier.info('You pressed OK')};
  let onCancel = () => {notifier.info('You pressed Cancel')};
  notifier.confirm(
    'Are you sure?',
    onOk,
    onCancel,
    {
      labels: {
        confirm: 'Dangerous action'
      }
    }
  )

No cancel button


  let notifier = new AWN();
  let onOk = () => {notifier.info('You pressed OK')};
  notifier.confirm(
    'Your notification message',
    onOk,
    false,
    {
      labels: {
        confirm: 'Simple notification'
      }
    }
  )