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:
|
- 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
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 |
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
Fires:
- Source:
clearContentPanel()
#
Clear the content panel.
- Inherited from:
- Source:
clearMenuPanel()
#
Clear the menu panel.
- Inherited from:
- Source:
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.
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
Fires:
- Source:
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:
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.
Returns:
Closest scrollable container
- Type
- HTMLElement
- Inherited from:
- Source:
getClosestTabPanel(tabPanel) → {OO.ui.TabPanelLayout|null}
#
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 |
Returns:
Tab panel closest to the specified
- Type
-
OO.ui.TabPanelLayout
|
null
- Source:
getCurrentTabPanel() → {OO.ui.TabPanelLayout|undefined}
#
undefined}
#
Get the current tab panel.
Returns:
Current tab panel, if found
- Type
-
OO.ui.TabPanelLayout
|
undefined
- Source:
getCurrentTabPanelName() → {string|null}
#
null}
#
Get the symbolic name of the current tab panel.
Returns:
Symbolic name of the current tab panel
- Type
-
string
|
null
- Source:
getData() → {any}
#
Get element data.
Returns:
Element data
- Type
- any
- Inherited from:
- Source:
getElementDocument() → {HTMLDocument}
#
getElementGroup() → {OO.ui.mixin.GroupElement|null}
#
null}
#
Get group element is in.
Returns:
Group element, null if none
- Type
-
OO.ui.mixin.GroupElement
|
null
- Inherited from:
- Source:
getElementId() → {string}
#
Ensure that the element has an 'id' attribute, setting it to an unique value if it's missing, and return its value.
Returns:
- Type
- string
- Inherited from:
- Source:
Ensure that the element has an 'id' attribute, setting it to an unique value if it's missing, and return its value.
getElementWindow() → {Window}
#
getMenuPosition() → {string}
#
Get menu position.
Returns:
Menu position
- Type
- string
- Inherited from:
- Source:
getTabPanel(name) → {OO.ui.TabPanelLayout|undefined}
#
undefined}
#
Get a tab panel by its symbolic name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Symbolic name of tab panel |
Returns:
Tab panel, if found
- Type
-
OO.ui.TabPanelLayout
|
undefined
- Source:
getTabs() → {OO.ui.TabSelectWidget}
#
Get the tabs widget.
Returns:
Tabs widget
- Source:
getTagName() → {string}
#
Get the HTML tag name.
Override this method to base the result on instance information.
Returns:
HTML tag name
- Type
- string
- Inherited from:
- Source:
isElementAttached() → {boolean}
#
Check if the element is attached to the DOM
Returns:
The element is attached to the DOM
- Type
- boolean
- Inherited from:
- Source:
isMenuVisible() → {boolean}
#
Check if menu is visible
Returns:
Menu is visible
- Type
- boolean
- Inherited from:
- Source:
isVisible() → {boolean}
#
Check if element is visible.
Returns:
element is visible
- Type
- boolean
- Inherited from:
- Source:
onStackLayoutBeforeMatch(event)
#
Handle beforematch events triggered by the browser's find-in-page feature
Parameters:
| Name | Type | Description |
|---|---|---|
event |
Event | 'beforematch' event |
- Source:
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 |
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
Fires:
- Source:
resetScroll() → {OO.ui.Layout}chainable
#
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:
scrollElementIntoView([config]) → {jQuery.Promise}
#
Scroll element into view.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
config |
Object |
optional |
Configuration options |
Returns:
Promise which resolves when the scroll is complete
- Type
- jQuery.Promise
- Inherited from:
- Source:
selectFirstSelectableTabPanel() → {OO.ui.IndexLayout}chainable
#
Select the first selectable tab panel.
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
- Source:
setContentPanel(contentPanel)
#
Set the content panel.
Parameters:
| Name | Type | Description |
|---|---|---|
contentPanel |
OO.ui.PanelLayout | Content panel |
- Inherited from:
- Source:
setData(data) → {OO.ui.Element}chainable
#
Set element data.
Parameters:
| Name | Type | Description |
|---|---|---|
data |
any | Element data |
Returns:
The element, for chaining
- Type
- OO.ui.Element
- Inherited from:
- Source:
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 |
Returns:
The element, for chaining
- Type
- OO.ui.Element
- Inherited from:
- Source:
setElementId(id) → {OO.ui.Element}chainable
#
Set the element has an 'id' attribute.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
The element, for chaining
- Type
- OO.ui.Element
- Inherited from:
- Source:
setMenuPanel(menuPanel)
#
Set the menu panel.
Parameters:
| Name | Type | Description |
|---|---|---|
menuPanel |
OO.ui.PanelLayout | Menu panel |
- Inherited from:
- Source:
setMenuPosition(position) → {OO.ui.MenuLayout}chainable
#
Set menu position.
Parameters:
| Name | Type | Description |
|---|---|---|
position |
string | Position of menu, either |
Returns:
The layout, for chaining
- Type
- OO.ui.MenuLayout
- Inherited from:
- Source:
setTabPanel(name)
#
Set the current tab panel by symbolic name.
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | Symbolic name of tab panel |
Fires:
- 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 |
Returns:
All methods are supported
- Type
- boolean
- Inherited from:
- Source:
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 |
Returns:
The element, for chaining
- Type
- OO.ui.Element
Fires:
- Inherited from:
- Source:
toggleMenu([showMenu]) → {OO.ui.MenuLayout}chainable
#
Toggle menu.
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
showMenu |
boolean |
optional |
Show menu, omit to toggle |
Returns:
The layout, for chaining
- Type
- OO.ui.MenuLayout
- Inherited from:
- Source:
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:
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:
added to the index layout.
remove(tabPanel)
#
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.