Constructor
new OO.ui.mixin.GroupElement([config])abstract
#
Any OOUI widget that contains other widgets (such as buttons
or
options
) mixes in GroupElement. Adding, removing, and clearing
items from the group is done through the interface the class provides.
For more information, please see the OOUI documentation on MediaWiki.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
optional |
Configuration options Properties:
|
- Mixes in:
- Source:
Methods
addItems([items], [index]) → {OO.ui.Element}chainable
#
Add items to the group.
Items will be added to the end of the group array unless the optional index
parameter
specifies a different insertion point. Adding an existing item will move it to the end of the
array or the point specified by the index
.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
items |
OO.ui.Element | Array.<OO.ui.Element> |
optional |
Elements to add to the group |
index |
number |
optional |
Index of the insertion point |
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element
clearItems() → {OO.ui.Element}chainable
#
Clear all items from the group.
Cleared items are detached from the DOM, not removed, so that they may be reused. To remove only a subset of items from a group, use the #removeItems method.
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element
findItemFromData(data) → {OO.ui.Element|null
}
#
null
}
#
Find an item by its data.
Only the first item with matching data will be returned. To return all matching items, use the #findItemsFromData method.
Parameters:
Name | Type | Description |
---|---|---|
data |
any | Item data to search for |
- Source:
Returns:
Item with equivalent data, null
if none exists
- Type
-
OO.ui.Element
|
null
findItemsFromData(data) → {Array.<OO.ui.Element>}
#
Find items by their data.
All items with matching data will be returned. To return only the first match, use the #findItemFromData method instead.
Parameters:
Name | Type | Description |
---|---|---|
data |
any | Item data to search for |
- Source:
Returns:
Items with equivalent data
- Type
- Array.<OO.ui.Element>
insertItem(item, index) → {number}protected
#
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.
This method can be extended in child classes to produce different behavior when an item is inserted. For example, inserted items may also be attached to the DOM or may interact with some other nodes in certain ways. Extending this method is allowed, but if overridden, the aggregation of events must be preserved, or behavior of emitted events will be broken.
If you are extending this method, please make sure the parent method is called.
See https://doc.wikimedia.org/oojs/master/OO.EmitterList.html
Parameters:
Name | Type | Description |
---|---|---|
item |
OO.EventEmitter | Object | Item 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.
removeItems(items) → {OO.ui.Element}chainable
#
Remove the specified items from a group.
Removed items are detached (not removed) from the DOM so that they may be reused. To remove all items from a group, you may wish to use the #clearItems method instead.
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<OO.ui.Element> | An array of items to remove |
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element
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:
Events
change(items)
#
A change event is emitted when the set of selected items changes.
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<OO.ui.Element> | Items currently in the group |
- Source: