Expand all

mw.echo.ui.SortedListWidget

Extends

Constructor

new mw.echo.ui.SortedListWidget(sortingCallback, [config]) #

Sorted list widget. This is a group widget that sorts its items according to a given sorting callback.

Parameters:

Name Type Attributes Description
sortingCallback function

Callback that compares two items.

config Object optional

Configuration options

Mixes in:
Source:
Sorted 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

Source:

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

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

Clear all items

Source:

Fires:

Returns:

Type
mw.echo.ui.SortedListWidget
Clear all items

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

Get an item by its data.

Parameters:

Name Type Description
data string

Item data to search for

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

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.

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

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

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.

onItemSortChange() #

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

Remove items.

Parameters:

Name Type Description
items Array.<OO.EventEmitter>

Items to remove

Source:

Fires:

Returns:

Type
mw.echo.ui.SortedListWidget
Remove items.

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

Source:
Set the group element.