Class: Element

(abstract) .ui.Element(configopt)

(abstract) new Element(configopt)

Each Element represents a rendering in the DOM—a button or an icon, for example, or anything that is visible to a user. Unlike widgets, plain elements usually do not have events connected to them and can't be interacted with.

Parameters:
Name Type Attributes Description
config Object <optional>

Configuration options

Properties
Name Type Attributes Description
classes Array.<string> <optional>

The names of the CSS classes to apply to the element. CSS styles are added to the top level (e.g., the outermost div) of the element. See the OOjs UI documentation on MediaWiki for an example.

id string <optional>

The HTML id attribute used in the rendered tag.

text string <optional>

Text to insert

content Array <optional>

An array of content elements to append (after #text). Strings will be html-escaped; use an OO.ui.HtmlSnippet to append raw HTML. Instances of OO.ui.Element will have their $element appended.

$content jQuery <optional>

Content elements to append (after #text).

$element jQuery <optional>

Wrapper element. Defaults to a new element with #getTagName.

data Mixed <optional>

Custom data of any type or combination of types (e.g., string, number, array, object). Data can also be specified with the #setData method.

Source:

Methods

getClosestScrollableElementContainer() → {HTMLElement}

Get closest scrollable container.

Source:
Returns:

Closest scrollable container

Type
HTMLElement

getData() → {Mixed}

Get element data.

Source:
Returns:

Element data

Type
Mixed

getElementDocument() → {HTMLDocument}

Get the DOM document.

Source:
Returns:

Document object

Type
HTMLDocument

getElementGroup() → {OO.ui.mixin.GroupElement|null}

Get group element is in.

Source:
Returns:

Group element, null if none

Type
OO.ui.mixin.GroupElement | null

getElementId() → {string}

Ensure that the element has an 'id' attribute, setting it to an unique value if it's missing, and return its value.

Source:
Returns:
Type
string

getElementWindow() → {Window}

Get the DOM window.

Source:
Returns:

Window object

Type
Window

getTagName() → {string}

Get the HTML tag name.

Override this method to base the result on instance information.

Source:
Returns:

HTML tag name

Type
string

isElementAttached() → {boolean}

Check if the element is attached to the DOM

Source:
Returns:

The element is attached to the DOM

Type
boolean

isVisible() → {boolean}

Check if element is visible.

Source:
Returns:

element is visible

Type
boolean

(protected) restorePreInfuseState(state)

Restore the pre-infusion dynamic state for this widget.

This method is called after #$element has been inserted into DOM. The parameter is the return value of #gatherPreInfuseState.

Parameters:
Name Type Description
state Object
Source:

scrollElementIntoView(configopt) → {jQuery.Promise}

Scroll element into view.

Parameters:
Name Type Attributes Description
config Object <optional>

Configuration options

Source:
Returns:

Promise which resolves when the scroll is complete

Type
jQuery.Promise

setData(data)

Set element data.

Parameters:
Name Type Description
data Mixed

Element data

Source:

setElementGroup(group)

Set group element is in.

Parameters:
Name Type Description
group OO.ui.mixin.GroupElement | null

Group element, null if none

Source:

setElementId(id)

Set the element has an 'id' attribute.

Parameters:
Name Type Description
id string
Source:

supports(methods) → {boolean}

Check if element supports one or more methods.

Parameters:
Name Type Description
methods string | Array.<string>

Method or list of methods to check

Source:
Returns:

All methods are supported

Type
boolean

toggle(showopt)

Toggle visibility of an element.

Parameters:
Name Type Attributes Description
show boolean <optional>

Make element visible, omit to toggle visibility

Source:
Fires:
  • event:visible

updateThemeClasses()

Update the theme-provided classes.

Source: