Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

gobj-ui: Dialogs and notifications

Dialogs and notifications

Source code: src/shell_modals.js

Every function takes the shell as its first parameter.


Notifications

A notification goes into the layer of the shell and goes away on its own after opts.timeout milliseconds. The default is 5000, and a value of 0 keeps it until somebody closes it. Each one gives {close} back.

yui_shell_show_info(shell, message, opts)

Shows a message of information.

yui_shell_show_warning(shell, message, opts)

Shows a warning.

yui_shell_show_error(shell, message, opts)

Shows an error.


yui_shell_show_modal(shell, content, opts)

Puts an overlay in the layer of the modals. content accepts a string, which the function draws inside a box, or an element, which it draws as it is.

Returns {close}. The caller decides when to close it. A click on the background, the button of close and the Escape key close it too.


Confirmation

Each one gives a promise back. The buttons carry a label that the caller can change.

yui_shell_confirm_ok(shell, message, opts)

Shows a message with one button. The promise gives undefined back. opts.ok_label changes the label.

yui_shell_confirm_yesno(shell, message, opts)

Asks a question with two answers. The promise gives true for yes. opts.yes_label and opts.no_label change the labels.

yui_shell_confirm_yesnocancel(shell, message, opts)

Asks a question with three answers. The promise gives "yes", "no" or "cancel".

Use it when the third answer is a real one. A question such as “play all” has three answers and not two: add, replace, or cancel.

yui_shell_confirm_danger(shell, message, opts)

Asks a destructive question. The promise gives true only when the user presses the red button. opts.confirm_label and opts.cancel_label change the labels, and the defaults are "Delete" and "Cancel".