Expand all

mw.echo.ui.NotificationsListWidget

Extends

Constructor

new mw.echo.ui.NotificationsListWidget(controller, manager, [config]) #

Notifications list widget. All of its items must be of the mw.echo.ui.NotificationItem type.

Parameters:

Name Type Attributes Description
controller mw.echo.Controller

Echo notifications controller

manager mw.echo.dm.ModelManager

Model manager

config Object optional

Configuration object marked as read when they are seen.

Source:
Notifications list widget.

Methods

attachItemToDom(item, index) #

Attach the item to the Dom in its intended position, based on the given index.

Parameters:

Name Type Description
item OO.EventEmitter

Item

index number

Index to insert the item into

Inherited from:
Source:

Attach the item to the Dom in its intended position, based on the given index.

attachModel(modelId, model) #

Attach a model to the widget

Parameters:

Name Type Description
modelId string

Symbolic name for the model

model mw.echo.dm.SortedList

Notifications list model

Source:
Attach a model to the widget

checkForEmptyNotificationsList() #

Check if the list of notifications is empty and udpate the placeholder widget as needed.

Source:

Check if the list of notifications is empty and udpate the placeholder widget as needed.

clearItems() → {mw.echo.ui.SortedListWidget}chainable #

Clear all items

detachModel(modelId) #

Detach a model from the widget

Parameters:

Name Type Description
modelId string

Notifications list model

Source:
Detach a model from the widget

findItemFromData(data) → {OO.ui.Element|null} #

Get an item by its data.

Parameters:

Name Type Description
data string

Item data to search for

Inherited from:
Source:

Returns:

Item with equivalent data, null if none exists

Type
OO.ui.Element | null
Get an item by its data.

getItemFromId(id) → {OO.ui.Element|null} #

Get an item by its id.

Parameters:

Name Type Description
id number

Item id to search for

Inherited from:
Source:

Returns:

Item with equivalent data, null if none exists

Type
OO.ui.Element | null
Get an item by its id.

getTimestamp() → {string} #

Get the timestamp of the list by taking the latest notification timestamp.

Inherited from:
Source:

Returns:

Latest timestamp

Type
string

Get the timestamp of the list by taking the latest notification timestamp.

insertItem(item, index) → {number}private #

Utility method to insert an item into the list, and connect it to aggregate events.

Don't call this directly unless you know what you're doing. Use #addItems instead.

Parameters:

Name Type Description
item OO.EventEmitter

Items to add

index number

Index to add items at

Inherited from:
Source:

Returns:

The index the item was added at

Type
number

Utility method to insert an item into the list, and connect it to aggregate events.

moveItem(item, index) → {number}private #

Move an item from its current position to a new index.

The item is expected to exist in the list. If it doesn't, the method will throw an exception.

Parameters:

Name Type Description
item OO.EventEmitter

Items to add

index number

Index to move the item to

Inherited from:
Source:

Throws:

If item is not in the list

Type
Error

Returns:

The index the item was moved to

Type
number
Move an item from its current position to a new index.

removeItems(items) → {mw.echo.ui.SortedListWidget}chainable #

Remove items.

Parameters:

Name Type Description
items Array.<OO.EventEmitter>

Items to remove

Inherited from:
Source:

Fires:

Returns:

Type
mw.echo.ui.SortedListWidget
Remove items.

resetDataFromModel(models) #

Respond to model manager update event. This event means we are repopulating the entire list and the associated models within it.

Parameters:

Name Type Description
models Object

Object of new models to populate the list.

Source:

Fires:

Respond to model manager update event.

resetInitiallyUnseenItems() #

Reset the 'initiallyUnseen' state of all items

Source:
Reset the 'initiallyUnseen' state of all items

resetLoadingOption([label], [link]) #

Reset the loading 'dummy' option widget

Parameters:

Name Type Attributes Description
label string optional

Label for the option widget

link string optional

Link for the option widget

Source:

Fires:

Reset the loading 'dummy' option widget

setGroupElement($group) #

Set the group element.

If an element is already set, items will be moved to the new element.

Parameters:

Name Type Description
$group jQuery

Element to use as group

Inherited from:
Source:
Set the group element.

Events

modified() #

The content of this list has changed. This event is to state that not only has the content changed but the actual DOM has been manipulated.

Source:
The content of this list has changed.