Class: Dialog

sync.api. Dialog


new Dialog()

A dialog window with custom content.

Classes

SizeChangedEvent

Members


<static> ButtonConfiguration :string

Button configurations for a dialog.
Type:
  • string
Properties:
Name Type Default Description
OK_CANCEL string ok_cancel An OK and a Cancel button. This is the default configuration.
OK string ok Only an OK button.
CANCEL string cancel Only a cancel button
CLOSE string close Only a close button
YES_NO string yes_no A Yes and a No buttons

<static> EventType :string

Event types generated by the dialog.
Type:
  • string
Properties:
Name Type Default Description
SIZE_CHANGED string size_changed Generated when the dialog size changed.
See sync.api.Dialog.SizeChangedEvent for more details.

Methods


dispose()

Disposes all the resources associated with the dialog, un-registers all the listeners and removes it from the DOM.

focus()

Focuses the dialog window.

getElement()

Returns the HTML element that represents the content of the dialog window, So that custom content can be added to it.
Returns:
The element of the dialog.
Type
HTMLElement

getEventTarget()

Getter for the dialog event target.
Returns:
Type
goog.events.EventTarget

hide()

Hides the dialog window.

isVisible()

Returns true if the dialog is visible.

onSelect(callback)

Sets the callback to be called when a button is pressed. It is called only once - the next time the dialog is shown, you will need to register an onSelect callback again.
Parameters:
Name Type Description
callback sync.api.Dialog~onSelectCallback the callback used when the user chooses an option on the dialog.

setBackgroundElementOpacity(opacity)

Sets the opacity of the background mask.
Parameters:
Name Type Description
opacity number Background mask opacity. The default value is 0.5 (50% opacity).
Since:
  • 21.1

setButtonConfiguration(config)

Sets the button configuration of the dialog.
Parameters:
Name Type Description
config sync.api.Dialog.ButtonConfiguration The button configuration

setContentPreferredSize(width, height)

Sets the preferred size for this dialog content.
Parameters:
Name Type Description
width number The preferred width.
height number The preferred height.

setHasTitleCloseButton(hasTitleCloseButton)

Sets whether the dialog should have a close button in the title bar. This works only for non-modal dialogs, see sync.api.Dialog.setModal().
Parameters:
Name Type Description
hasTitleCloseButton boolean Whether this dialog should have a title close button.
Since:
  • 21.1

setModal(modal)

Makes the dialog modal/non-modal. The dialog is modal by default.
Parameters:
Name Type Description
modal boolean true if the dialog should be made modal.

setPosition(x, y)

Set the position of this dialog.
Parameters:
Name Type Description
x number Left position or coordinate.
y number Top position.
Since:
  • 21.1

setPreferredSize(width, height)

Sets the preferred size for this dialog.
Parameters:
Name Type Description
width number The preferred width.
height number The preferred height.

setResizable(resizable)

Sets the resizable flag for this dialog.
Parameters:
Name Type Description
resizable boolean If true, this dialog should become resizable.

setTitle(title)

Sets the title of the dialog window.
Parameters:
Name Type Description
title string The title of the dialog window.

show()

Shows the dialog window.

Type Definitions


onSelectCallback(key, event)

A callback that receives the key of the button that was pressed, and the select event itself.
Parameters:
Name Type Description
key string The key of the selected button.
event goog.events.Event The select event, which you can preventDefault() in order to keep the dialog open.
Returns:
If the callback returns a {Promise}, the dialog is switched to a 'waiting' state until the promise resolves and only then it is hidden. If the promise rejects, the dialog remains open.
Type
Promise