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:
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 |
Attach the item to the Dom in its intended position, based on the given index.
clearItems() → {mw.echo.ui.SortedListWidget}chainable
#
Clear all items
Fires:
Returns:
findItemFromData(data) → {OO.ui.Element|null
}
#
null
}
#
Get an item by its data.
Parameters:
Name | Type | Description |
---|---|---|
data |
string | Item data to search for |
Returns:
Item with equivalent data, null
if none exists
- Type
-
OO.ui.Element
|
null
getItemFromId(id) → {OO.ui.Element|null
}
#
null
}
#
Get an item by its id.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | Item id to search for |
Returns:
Item with equivalent data, null
if none exists
- Type
-
OO.ui.Element
|
null
getTimestamp() → {string}
#
Get the timestamp of the list by taking the latest notification timestamp.
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 |
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 |
Throws:
-
If item is not in the list
- Type
- Error
Returns:
The index the item was moved to
- Type
- number
onItemSortChange()
#
- Source:
removeItems(items) → {mw.echo.ui.SortedListWidget}chainable
#
Remove items.
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<OO.EventEmitter> | Items to remove |