Expand all

abstract OO.ui.mixin.LabelElement

Constructor

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

LabelElement is often mixed into other classes to generate a label, which helps identify the function of an interface element. See the OOUI documentation on MediaWiki for more information.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
$label jQuery optional

The label element created by the class. If this configuration is omitted, the label element will use a generated <span>.

label jQuery | string | function | OO.ui.HtmlSnippet optional

The label text. The label can be specified as a plaintext string, a jQuery selection of elements, or a function that will produce a string in the future. See the [OOUI documentation on MediaWiki][2] for examples. [2]: https://www.mediawiki.org/wiki/OOUI/Widgets/Icons,_Indicators,_and_Labels#Labels

invisibleLabel boolean optional
false

Whether the label should be visually hidden (but still accessible to screen-readers).

Source:

LabelElement is often mixed into other classes to generate a label, which helps identify the function of an interface element.

Properties

labelstatic #

The label text. The label can be specified as a plaintext string, a function that will produce a string (will be resolved on construction time), or null for no label. The static value will be overridden if a label is specified with the #label config option.

Properties:

Type Description
string | function | null
Source:
The label text.

Methods

highlightQuery(text, query, [compare], [combineMarks]) → {jQuery}static #

Highlight the first occurrence of the query in the given text

Parameters:

Name Type Attributes Default Description
text string

Text

query string

Query to find

compare function optional

Optional string comparator, e.g. Intl.Collator().compare

combineMarks boolean optional
false

Pull combining marks into highlighted text

Source:

Returns:

Text with the first match of the query sub-string wrapped in highlighted span

Type
jQuery
Highlight the first occurrence of the query in the given text

getLabel() → {jQuery|string|null} #

Get the label's value as provided via #setLabel or the "label" config. Note this is not necessarily the same as the label's visible content when #setLabelContent was used.

Source:

Returns:

Label nodes; text; or null for no label

Type
jQuery | string | null
Get the label's value as provided via #setLabel or the "label" config.

setHighlightedQuery(text, query, [compare], [combineMarks]) → {OO.ui.Element}chainable #

Set the label as plain text with a highlighted query

Parameters:

Name Type Attributes Default Description
text string

Text label to set

query string

Substring of text to highlight

compare function optional

Optional string comparator, e.g. Intl.Collator().compare

combineMarks boolean optional
false

Pull combining marks into highlighted text

Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Set the label as plain text with a highlighted query

setInvisibleLabel([invisibleLabel]) → {OO.ui.Element}chainable #

Set whether the label should be visually hidden (but still accessible to screen-readers).

Parameters:

Name Type Attributes Default Description
invisibleLabel boolean optional
false
Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Set whether the label should be visually hidden (but still accessible to screen-readers).

setLabel(label) → {OO.ui.Element}chainable #

Replace both the visible content of the label (same as #setLabelContent) as well as the value returned by #getLabel, without touching the label's wrapper element. This is the same as using the "label" config on construction time.

An empty string will result in the label being hidden. A string containing only whitespace will be converted to a single &nbsp;.

To change the wrapper element, use #setLabelElement or the "$label" config.

Parameters:

Name Type Description
label jQuery | string | OO.ui.HtmlSnippet | function | null

Label nodes; text; a function that returns nodes or text; or null for no label

Source:

Returns:

The element, for chaining

Type
OO.ui.Element

Replace both the visible content of the label (same as #setLabelContent) as well as the value returned by #getLabel, without touching the label's wrapper element.

setLabelElement($label) → {OO.ui.mixin.LabelElement}chainable #

Replace the wrapper element (an empty <span> by default) with another one (e.g. an <a href="…">), without touching the label's content. This is the same as using the "$label" config on construction time.

If an element is already set, it will be cleaned up before setting up the new element.

Parameters:

Name Type Description
$label jQuery

Element to use as label

Source:

Returns:

The element, for chaining

Type
OO.ui.mixin.LabelElement
Replace the wrapper element (an empty <span> by default) with another one (e.g.

setLabelId(id) → {OO.ui.mixin.LabelElement}chainable #

Set the 'id' attribute of the label element.

Parameters:

Name Type Description
id string
Source:

Returns:

The element, for chaining

Type
OO.ui.mixin.LabelElement
Set the 'id' attribute of the label element.

Events

labelChange() #