Expand all

mw.notification

Library for sending notifications to end users.

Properties

autoHideLimit :numberstatic #

Maximum number of simultaneous notifications to start auto-hide timers for. Only this number of notifications being displayed will be auto-hidden at one time. Any additional notifications in the list will only start counting their timeout for auto-hiding after the previous messages have been closed.

This basically represents the minimal number of notifications the user should be able to process during the default autoHideSeconds time.

Type:

Source:
Maximum number of simultaneous notifications to start auto-hide timers for.

autoHideSeconds :Object.<string, number>static #

Map of predefined auto-hide timeout keys to second values. short is used by default, and other values can be added for use in #notify.

Type:

Properties:

Name Type Description
short number

5 seconds (default)

long number

30 seconds

Source:
Map of predefined auto-hide timeout keys to second values.

defaults :mw.notification.NotificationOptionsstatic #

The defaults for #notify options parameter.

Methods

notify(message, [options]) → {Notification}static #

Display a notification message to the user.

Parameters:

Name Type Attributes Description
message HTMLElement | Array.<HTMLElement> | jQuery | mw.Message | string
options mw.notification.NotificationOptions optional

The options to use for the notification. Options not specified default to the values in #defaults.

Source:

Returns:

Notification object

Type
Notification
Display a notification message to the user.

pause()static #

Pause auto-hide timers for all notifications. Notifications will not auto-hide until resume is called.

Source:
See:
Pause auto-hide timers for all notifications.

resume()static #

Resume any paused auto-hide timers from the beginning. Only the first mw.notification.autoHideLimit timers will be resumed.

Source:
Resume any paused auto-hide timers from the beginning.

Type Definitions

NotificationOptions #

Type:

Properties:

Name Type Description
autoHide boolean

Whether the notification should automatically be hidden after shown. Or if it should persist.

autoHideSeconds string

Key to #autoHideSeconds for number of seconds for timeout of auto-hide notifications.

tag string | null

When a notification is tagged only one message with that tag will be displayed. Trying to display a new notification with the same tag as one already being displayed will cause the other notification to be closed and this new notification to open up inside the same place as the previous notification.

title string | null

Title for the notification. Will be displayed above the content. Usually in bold.

type string | null

The type of the message used for styling. Examples: info, warn, error, success.

visibleTimeout boolean

Whether the autoHide timeout should be based on time the page was visible to user. Or if it should use wall clock time.

id string | false

HTML ID to set on the notification element.

classes string | Array.<string> | false

CSS class names to be set on the notification element.

Source: