Expand all

OO.ui.IndexLayout

Extends

Constructor

new OO.ui.IndexLayout([config]) #

IndexLayouts contain tab panel layouts as well as tabs that allow users to easily navigate through the tab panels and select which one to display. By default, only one tab panel is displayed at a time. When a user navigates to a new tab panel, the index layout automatically focuses on the first focusable element, unless the default setting is changed.

TODO: This class is similar to BookletLayout, we may want to refactor to reduce duplication

Example

// Example of a IndexLayout that contains two TabPanelLayouts.

    function TabPanelOneLayout( name, config ) {
        TabPanelOneLayout.super.call( this, name, config );
        this.$element.append( '<p>First tab panel</p>' );
    }
    OO.inheritClass( TabPanelOneLayout, OO.ui.TabPanelLayout );
    TabPanelOneLayout.prototype.setupTabItem = function () {
        this.tabItem.setLabel( 'Tab panel one' );
    };

    const tabPanel1 = new TabPanelOneLayout( 'one' ),
        tabPanel2 = new OO.ui.TabPanelLayout( 'two', { label: 'Tab panel two' } );

    tabPanel2.$element.append( '<p>Second tab panel</p>' );

    const index = new OO.ui.IndexLayout();

    index.addTabPanels( [ tabPanel1, tabPanel2 ] );
    $( document.body ).append( index.$element );

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Properties:
Name Type Attributes Default Description
contentPanel OO.ui.StackLayout optional

Content stack (see MenuLayout)

continuous boolean optional
false

Show all tab panels, one after another

autoFocus boolean optional
true

Focus on the first focusable element when a new tab panel is displayed. Disabled on mobile.

framed boolean optional
true

Render the tabs with frames

openMatchedPanels boolean optional
true

Automatically switch to a panel when the browser's find-in-page feature matches content there, in browsers that support it.

Source:

IndexLayouts contain tab panel layouts as well as tabs that allow users to easily navigate through the tab panels and select which one to display.

Properties

$content #

Content DOM node

Properties:

Type Description
jQuery
Inherited from:
Source:
Content DOM node

$menu #

Menu DOM node

Properties:

Type Description
jQuery
Inherited from:
Source:
Menu DOM node

Methods

addTabPanels(tabPanels, index) → {OO.ui.IndexLayout}chainable #

Add tab panels to the index layout.

When tab panels are added with the same names as existing tab panels, the existing tab panels will be automatically removed before the new tab panels are added.

Parameters:

Name Type Description
tabPanels Array.<OO.ui.TabPanelLayout>

Tab panels to add

index number

Index of the insertion point

Source:

Fires:

Returns:

The layout, for chaining

Type
OO.ui.IndexLayout
Add tab panels to the index layout.

clearContentPanel() #

Clear the content panel.

Inherited from:
Source:
Clear the content panel.

clearMenuPanel() #

Clear the menu panel.

Inherited from:
Source:
Clear the menu panel.

clearTabPanels() → {OO.ui.IndexLayout}chainable #

Clear all tab panels from the index layout.

To remove only a subset of tab panels from the index, use the #removeTabPanels method.

Source:

Fires:

Returns:

The layout, for chaining

Type
OO.ui.IndexLayout
Clear all tab panels from the index layout.

focus([itemIndex]) #

Focus the first input in the current tab panel.

If no tab panel is selected, the first selectable tab panel will be selected. If the focus is already in an element on the current tab panel, nothing will happen.

Parameters:

Name Type Attributes Description
itemIndex number optional

A specific item to focus on

Source:
Focus the first input in the current tab panel.

focusFirstFocusable() #

Find the first focusable input in the index layout and focus on it.

Source:

Find the first focusable input in the index layout and focus on it.

getClosestScrollableElementContainer() → {HTMLElement} #

Get closest scrollable container.

Inherited from:
Source:

Returns:

Closest scrollable container

Type
HTMLElement
Get closest scrollable container.

getClosestTabPanel(tabPanel) → {OO.ui.TabPanelLayout|null} #

Get the tab panel closest to the specified tab panel.

Parameters:

Name Type Description
tabPanel OO.ui.TabPanelLayout

Tab panel to use as a reference point

Source:

Returns:

Tab panel closest to the specified

Type
OO.ui.TabPanelLayout | null
Get the tab panel closest to the specified tab panel.

getCurrentTabPanel() → {OO.ui.TabPanelLayout|undefined} #

Get the current tab panel.

Source:

Returns:

Current tab panel, if found

Type
OO.ui.TabPanelLayout | undefined
Get the current tab panel.

getCurrentTabPanelName() → {string|null} #

Get the symbolic name of the current tab panel.

Source:

Returns:

Symbolic name of the current tab panel

Type
string | null
Get the symbolic name of the current tab panel.

getData() → {any} #

Get element data.

Inherited from:
Source:

Returns:

Element data

Type
any
Get element data.

getElementDocument() → {HTMLDocument} #

Get the DOM document.

Inherited from:
Source:

Returns:

Document object

Type
HTMLDocument
Get the DOM document.

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

Get group element is in.

Inherited from:
Source:

Returns:

Group element, null if none

Type
OO.ui.mixin.GroupElement | null
Get group element is in.

getElementId() → {string} #

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

Inherited from:
Source:

Returns:

Type
string

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

getElementWindow() → {Window} #

Get the DOM window.

Inherited from:
Source:

Returns:

Window object

Type
Window
Get the DOM window.

getMenuPosition() → {string} #

Get menu position.

Inherited from:
Source:

Returns:

Menu position

Type
string
Get menu position.

getTabPanel(name) → {OO.ui.TabPanelLayout|undefined} #

Get a tab panel by its symbolic name.

Parameters:

Name Type Description
name string

Symbolic name of tab panel

Source:

Returns:

Tab panel, if found

Type
OO.ui.TabPanelLayout | undefined
Get a tab panel by its symbolic name.

getTabs() → {OO.ui.TabSelectWidget} #

Get the tabs widget.

Source:

Returns:

Tabs widget

Type
OO.ui.TabSelectWidget
Get the tabs widget.

getTagName() → {string} #

Get the HTML tag name.

Override this method to base the result on instance information.

Inherited from:
Source:

Returns:

HTML tag name

Type
string
Get the HTML tag name.

isElementAttached() → {boolean} #

Check if the element is attached to the DOM

Inherited from:
Source:

Returns:

The element is attached to the DOM

Type
boolean
Check if the element is attached to the DOM

isMenuVisible() → {boolean} #

Check if menu is visible

Inherited from:
Source:

Returns:

Menu is visible

Type
boolean
Check if menu is visible

isVisible() → {boolean} #

Check if element is visible.

Inherited from:
Source:

Returns:

element is visible

Type
boolean
Check if element is visible.

onStackLayoutBeforeMatch(event) #

Handle beforematch events triggered by the browser's find-in-page feature

Parameters:

Name Type Description
event Event

'beforematch' event

Source:
Handle beforematch events triggered by the browser's find-in-page feature

removeTabPanels(tabPanels) → {OO.ui.IndexLayout}chainable #

Remove the specified tab panels from the index layout.

To remove all tab panels from the index, you may wish to use the #clearTabPanels method instead.

Parameters:

Name Type Description
tabPanels Array.<OO.ui.TabPanelLayout>

An array of tab panels to remove

Source:

Fires:

Returns:

The layout, for chaining

Type
OO.ui.IndexLayout
Remove the specified tab panels from the index layout.

resetScroll() → {OO.ui.Layout}chainable #

Reset scroll offsets

Inherited from:
Source:

Returns:

The layout, for chaining

Type
OO.ui.Layout
Reset scroll offsets

restorePreInfuseState(state)protected #

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
Inherited from:
Source:
Restore the pre-infusion dynamic state for this widget.

scrollElementIntoView([config]) → {jQuery.Promise} #

Scroll element into view.

Parameters:

Name Type Attributes Description
config Object optional

Configuration options

Inherited from:
Source:

Returns:

Promise which resolves when the scroll is complete

Type
jQuery.Promise
Scroll element into view.

selectFirstSelectableTabPanel() → {OO.ui.IndexLayout}chainable #

Select the first selectable tab panel.

Source:

Returns:

The layout, for chaining

Type
OO.ui.IndexLayout
Select the first selectable tab panel.

setContentPanel(contentPanel) #

Set the content panel.

Parameters:

Name Type Description
contentPanel OO.ui.PanelLayout

Content panel

Inherited from:
Source:
Set the content panel.

setData(data) → {OO.ui.Element}chainable #

Set element data.

Parameters:

Name Type Description
data any

Element data

Inherited from:
Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Set element data.

setElementGroup(group) → {OO.ui.Element}chainable #

Set group element is in.

Parameters:

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

Group element, null if none

Inherited from:
Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Set group element is in.

setElementId(id) → {OO.ui.Element}chainable #

Set the element has an 'id' attribute.

Parameters:

Name Type Description
id string
Inherited from:
Source:

Returns:

The element, for chaining

Type
OO.ui.Element
Set the element has an 'id' attribute.

setMenuPanel(menuPanel) #

Set the menu panel.

Parameters:

Name Type Description
menuPanel OO.ui.PanelLayout

Menu panel

Inherited from:
Source:
Set the menu panel.

setMenuPosition(position) → {OO.ui.MenuLayout}chainable #

Set menu position.

Parameters:

Name Type Description
position string

Position of menu, either top, after, bottom or before

Inherited from:
Source:

Returns:

The layout, for chaining

Type
OO.ui.MenuLayout
Set menu position.

setTabPanel(name) #

Set the current tab panel by symbolic name.

Parameters:

Name Type Description
name string

Symbolic name of tab panel

Source:

Fires:

Set the current tab panel by symbolic name.

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

Inherited from:
Source:

Returns:

All methods are supported

Type
boolean
Check if element supports one or more methods.

toggle([show]) → {OO.ui.Element}chainable #

Toggle visibility of an element.

Parameters:

Name Type Attributes Description
show boolean optional

Make element visible, omit to toggle visibility

Inherited from:
Source:

Fires:

Returns:

The element, for chaining

Type
OO.ui.Element
Toggle visibility of an element.

toggleMenu([showMenu]) → {OO.ui.MenuLayout}chainable #

Toggle menu.

Parameters:

Name Type Attributes Description
showMenu boolean optional

Show menu, omit to toggle

Inherited from:
Source:

Returns:

The layout, for chaining

Type
OO.ui.MenuLayout
Toggle menu.

updateThemeClasses() #

Update the theme-provided classes.

This is called in element mixins and widget classes any time state changes. Updating is debounced, minimizing overhead of changing multiple attributes and guaranteeing that theme updates do not occur within an element's constructor

Inherited from:
Source:
Update the theme-provided classes.

Events

add(tabPanel, index) #

An 'add' event is emitted when tab panels are added to the index layout.

Parameters:

Name Type Description
tabPanel Array.<OO.ui.TabPanelLayout>

Added tab panels

index number

Index tab panels were added at

Source:
An 'add' event is emitted when tab panels are added to the index layout.

remove(tabPanel) #

A 'remove' event is emitted when tab panels are cleared or removed from the index.

Parameters:

Name Type Description
tabPanel Array.<OO.ui.TabPanelLayout>

Removed tab panels

Source:

A 'remove' event is emitted when tab panels are cleared or removed from the index.

set(tabPanel) #

A 'set' event is emitted when a tab panel is set to be displayed by the index layout.

Parameters:

Name Type Description
tabPanel OO.ui.TabPanelLayout

Current tab panel

Source:

A 'set' event is emitted when a tab panel is set to be displayed by the index layout.