Expand all

abstract OO.ui.mixin.IconElement

Constructor

new OO.ui.mixin.IconElement([config])abstract #

IconElement is often mixed into other classes to generate an icon. Icons are graphics, about the size of normal text. They are used to aid the user in locating a control or to convey information in a space-efficient way. See the OOUI documentation on MediaWiki for a list of icons included in the library.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
$icon jQuery optional

The icon element created by the class. If this configuration is omitted, the icon element will use a generated <span>. To use a different HTML tag, or to specify that the icon element be set to an existing icon instead of the one generated by this class, set a value using a jQuery selection. For example:

 // Use a <div> tag instead of a <span>
$icon: $( '<div>' )
// Use an existing icon element instead of the one generated by the class
$icon: this.$element
// Use an icon element from a child widget
$icon: this.childwidget.$element
icon Object | string optional
''

The symbolic name of the icon (e.g., ‘remove’ or ‘menu’), or a map of symbolic names. A map is used for i18n purposes and contains a default icon name and additional names keyed by language code. The default name is used when no icon is keyed by the user's language.

Example of an i18n map:

{ default: 'bold-a', en: 'bold-b', de: 'bold-f' }

See the [OOUI documentation on MediaWiki][2] for a list of icons included in the library. [2]: https://www.mediawiki.org/wiki/OOUI/Widgets/Icons,_Indicators,_and_Labels#Icons

Source:
IconElement is often mixed into other classes to generate an icon.

Properties

iconstatic #

The symbolic name of the icon (e.g., ‘remove’ or ‘menu’), or a map of symbolic names. A map is used for i18n purposes and contains a default icon name and additional names keyed by language code. The default name is used when no icon is keyed by the user's language.

Example of an i18n map:

{ default: 'bold-a', en: 'bold-b', de: 'bold-f' }

Note: the static property will be overridden if the #icon configuration is used.

Properties:

Type Description
Object | string
Source:
The symbolic name of the icon (e.g., ‘remove’ or ‘menu’), or a map of symbolic names.

iconTitlestatic #

The icon title, displayed when users move the mouse over the icon. The value can be text, a function that returns title text, or null for no title.

The static property will be overridden if the #iconTitle configuration is used.

Properties:

Type Description
string | function | null
Source:
The icon title, displayed when users move the mouse over the icon.

Methods

getIcon() → {string} #

Get the symbolic name of the icon.

Source:

Returns:

Icon name

Type
string
Get the symbolic name of the icon.

setIcon(icon) → {OO.ui.Element}chainable #

Set icon by symbolic name (e.g., ‘remove’ or ‘menu’). Use null to remove an icon. The icon parameter can also be set to a map of icon names. See the #icon config setting for an example.

Parameters:

Name Type Description
icon Object | string | null

A symbolic icon name, a map of icon names keyed by language code, or null to remove the icon.

Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Set icon by symbolic name (e.g., ‘remove’ or ‘menu’).

setIconElement($icon) #

Set the icon element. This method is used to retarget an icon mixin so that its functionality applies to the specified icon element instead of the one created by the class. If an icon element is already set, the mixin’s effect on that element is removed. Generated CSS classes and mixin methods will no longer affect the element.

Parameters:

Name Type Description
$icon jQuery

Element to use as icon

Source:
Set the icon element.