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:
|
- 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:
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
getLabel() → {jQuery|string|null
}
#
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
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
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
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
.
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
<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
Events
labelChange()
#
- Source: