core/notification

Notification manager for in-page notifications in Moodle.

Source:
Since:
  • 2.9
License:
  • http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Members

(static, constant) saveCancelPromise

Source:

Add all of the supplied notifications.

Methods

(static) addNotification(notification) → {Promise}

Source:

Add a notification to the page.

Note: This does not cause the notification to be added to the session.

Parameters:
Name Type Description
notification Notification

The notification to add.

Returns:
Type
Promise

(static) alert(title, message, cancelText) → {Promise}

Source:

Alert dialogue.

Parameters:
Name Type Description
title String | Promise
message String | Promise
cancelText String | Promise
Returns:
Type
Promise

(static) confirm(title, question, saveLabel, noLabel, saveCallback, cancelCallback) → {Promise}

Source:

The confirm has now been replaced with a save and cancel dialogue.

Parameters:
Name Type Description
title String | Promise
question String | Promise
saveLabel String | Promise
noLabel String | Promise
saveCallback String | Promise
cancelCallback String | Promise
Returns:
Type
Promise

(static) exception(ex)

Source:

Wrap M.core.exception.

Parameters:
Name Type Description
ex Error

(static) fetchNotifications() → {Promise}

Source:

Poll the server for any new notifications.

Returns:
Type
Promise

(static) init(contextId, notificationList)

Source:

Initialise the page for the suppled context, and displaying the supplied notifications.

Parameters:
Name Type Description
contextId Number
notificationList Array.<Notification>

(static) saveCancel(title, question, saveLabel, saveCallback, cancelCallback, options) → {Promise}

Source:

The Save and Cancel dialogue helper.

Parameters:
Name Type Description
title String | Promise
question String | Promise
saveLabel String | Promise
saveCallback String | Promise
cancelCallback String | Promise
options Object
Properties
Name Type Attributes Default Description
triggerElement HTMLElement <optional>
null

The element that triggered the modal (will receive the focus after hidden)

Returns:
Type
Promise

(inner) addNotifications(notifications) → {Promise}

Source:

Add all of the supplied notifications.

Parameters:
Name Type Description
notifications Array.<Notification>

The list of notificaitons

Returns:
Type
Promise

Type Definitions

Notification

Source:
Properties:
Name Type Description
message string

The body of the notification

type string

The type of notification to add (error, warning, info, success).

closebutton Boolean

Whether to show the close button.

announce Boolean

Whether to announce to screen readers.

A notification object displayed to a user.

Type:
  • Object