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 |
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
Fires:
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.
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
Fires:
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.
- Inherited from:
- Source:
Returns:
Closest scrollable container
- Type
- HTMLElement
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 |
- Source:
Returns:
Tab panel closest to the specified
- Type
-
OO.ui.TabPanelLayout
|
null
getCurrentTabPanel() → {OO.ui.TabPanelLayout|undefined
}
#
undefined
}
#
Get the current tab panel.
- Source:
Returns:
Current tab panel, if found
- Type
-
OO.ui.TabPanelLayout
|
undefined
getCurrentTabPanelName() → {string|null
}
#
null
}
#
Get the symbolic name of the current tab panel.
- Source:
Returns:
Symbolic name of the current tab panel
- Type
-
string
|
null
getData() → {any}
#
Get element data.
- Inherited from:
- Source:
Returns:
Element data
- Type
- any
getElementDocument() → {HTMLDocument}
#
getElementGroup() → {OO.ui.mixin.GroupElement|null
}
#
null
}
#
Get group element is in.
- Inherited from:
- 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.
- 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}
#
getMenuPosition() → {string}
#
Get menu position.
- Inherited from:
- Source:
Returns:
Menu position
- Type
- string
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 |
- Source:
Returns:
Tab panel, if found
- Type
-
OO.ui.TabPanelLayout
|
undefined
getTabs() → {OO.ui.TabSelectWidget}
#
Get the tabs widget.
- Source:
Returns:
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
isElementAttached() → {boolean}
#
Check if the element is attached to the DOM
- Inherited from:
- Source:
Returns:
The element is attached to the DOM
- Type
- boolean
isMenuVisible() → {boolean}
#
Check if menu is visible
- Inherited from:
- Source:
Returns:
Menu is visible
- Type
- boolean
isVisible() → {boolean}
#
Check if element is visible.
- Inherited from:
- Source:
Returns:
element is visible
- Type
- boolean
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 |
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
Fires:
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 |
- Inherited from:
- Source:
Returns:
Promise which resolves when the scroll is complete
- Type
- jQuery.Promise
selectFirstSelectableTabPanel() → {OO.ui.IndexLayout}chainable
#
Select the first selectable tab panel.
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.IndexLayout
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 |
- Inherited from:
- Source:
Returns:
The element, for chaining
- Type
- OO.ui.Element
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
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
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 |
- Inherited from:
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.MenuLayout
setTabPanel(name)
#
Set the current tab panel by symbolic name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Symbolic name of tab panel |
- Source:
Fires:
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
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:
Returns:
The element, for chaining
- Type
- OO.ui.Element
Fires:
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
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.