Extends
Constructor
new OO.ui.BookletLayout([config])
#
BookletLayouts contain page layouts
as well as
an outline
that allows users to easily navigate
through the pages and select which one to display. By default, only one page is
displayed at a time and the outline is hidden. When a user navigates to a new page,
the booklet layout automatically focuses on the first focusable element, unless the
default setting is changed. Optionally, booklets can be configured to show
controls
for adding, moving, and removing items.
Example
// Example of a BookletLayout that contains two PageLayouts.
function PageOneLayout( name, config ) {
PageOneLayout.super.call( this, name, config );
this.$element.append( '<p>First page</p><p>(This booklet has an outline, displayed on ' +
'the left)</p>' );
}
OO.inheritClass( PageOneLayout, OO.ui.PageLayout );
PageOneLayout.prototype.setupOutlineItem = function () {
this.outlineItem.setLabel( 'Page One' );
};
function PageTwoLayout( name, config ) {
PageTwoLayout.super.call( this, name, config );
this.$element.append( '<p>Second page</p>' );
}
OO.inheritClass( PageTwoLayout, OO.ui.PageLayout );
PageTwoLayout.prototype.setupOutlineItem = function () {
this.outlineItem.setLabel( 'Page Two' );
};
const page1 = new PageOneLayout( 'one' ),
page2 = new PageTwoLayout( 'two' );
const booklet = new OO.ui.BookletLayout( {
outlined: true
} );
booklet.addPages( [ page1, page2 ] );
$( document.body ).append( booklet.$element );
Parameters:
Name | Type | Attributes | Description | |||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
optional |
Configuration options Properties:
|
- Source:
BookletLayouts contain page layouts
as well as
an outline
that allows users to easily navigate
through the pages and select which one to display.
Properties
Methods
addPages(pages, index) → {OO.ui.BookletLayout}chainable
#
Add pages to the booklet layout
When pages are added with the same names as existing pages, the existing pages will be automatically removed before the new pages are added.
Parameters:
Name | Type | Description |
---|---|---|
pages |
Array.<OO.ui.PageLayout> | Pages to add |
index |
number | Index of the insertion point |
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.BookletLayout
Fires:
Add pages to the booklet layout
When pages are added with the same names as existing pages, the existing pages will be automatically removed before the new pages are added.
clearContentPanel()
#
Clear the content panel.
- Inherited from:
- Source:
clearMenuPanel()
#
Clear the menu panel.
- Inherited from:
- Source:
clearPages() → {OO.ui.BookletLayout}chainable
#
Clear all pages from the booklet layout.
To remove only a subset of pages from the booklet, use the #removePages method.
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.BookletLayout
Fires:
findClosestPage(page) → {OO.ui.PageLayout|null
}
#
null
}
#
Find the page closest to the specified page.
Parameters:
Name | Type | Description |
---|---|---|
page |
OO.ui.PageLayout | Page to use as a reference point |
- Source:
Returns:
Page closest to the specified page
- Type
-
OO.ui.PageLayout
|
null
focus([itemIndex])
#
Focus the first input in the current page.
If no page is selected, the first selectable page will be selected. If the focus is already in an element on the current page, 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 booklet layout and focus on it.
- Source:
Find the first focusable input in the booklet layout and focus on it.
getClosestScrollableElementContainer() → {HTMLElement}
#
Get closest scrollable container.
- Inherited from:
- Source:
Returns:
Closest scrollable container
- Type
- HTMLElement
getCurrentPage() → {OO.ui.PageLayout|undefined
}
#
undefined
}
#
getCurrentPageName() → {string|null
}
#
null
}
#
Get the symbolic name of the current page.
- Source:
Returns:
Symbolic name of the current page
- 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
getOutline() → {OO.ui.OutlineSelectWidget|null
}
#
null
}
#
Get the outline widget.
If the booklet is not outlined, the method will return null
.
- Source:
Returns:
Outline widget, or null if the booklet is not outlined
- Type
-
OO.ui.OutlineSelectWidget
|
null
getOutlineControls() → {OO.ui.OutlineControlsWidget|null
}
#
null
}
#
Get the outline controls widget.
If the outline is not editable, the method will return null
.
- Source:
Returns:
The outline controls widget.
- Type
-
OO.ui.OutlineControlsWidget
|
null
getPage(name) → {OO.ui.PageLayout|undefined
}
#
undefined
}
#
Get a page by its symbolic name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Symbolic name of page |
- Source:
Returns:
Page, if found
- Type
-
OO.ui.PageLayout
|
undefined
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
isEditable() → {boolean}
#
Check if booklet has editing controls.
- Source:
Returns:
Booklet is editable
- Type
- boolean
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
isOutlined() → {boolean}
#
Check if booklet has an outline.
- Source:
Returns:
Booklet has an outline
- Type
- boolean
isOutlineVisible() → {boolean}
#
Check if booklet has a visible outline.
- Source:
Returns:
Outline is visible
- Type
- boolean
isVisible() → {boolean}
#
Check if element is visible.
- Inherited from:
- Source:
Returns:
element is visible
- Type
- boolean
removePages(pages) → {OO.ui.BookletLayout}chainable
#
Remove the specified pages from the booklet layout.
To remove all pages from the booklet, you may wish to use the #clearPages method instead.
Parameters:
Name | Type | Description |
---|---|---|
pages |
Array.<OO.ui.PageLayout> | An array of pages to remove |
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.BookletLayout
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
selectFirstSelectablePage() → {OO.ui.BookletLayout}chainable
#
Select the first selectable page.
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.BookletLayout
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
setPage(name)
#
Set the current page by symbolic name.
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Symbolic name of page |
- 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
toggleOutline([show]) → {OO.ui.BookletLayout}chainable
#
Hide or show the outline.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
show |
boolean |
optional |
Show outline, omit to invert current state |
- Source:
Returns:
The layout, for chaining
- Type
- OO.ui.BookletLayout
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(page, index)
#
An 'add' event is emitted when pages are added
to the booklet layout.
Parameters:
Name | Type | Description |
---|---|---|
page |
Array.<OO.ui.PageLayout> | Added pages |
index |
number | Index pages were added at |
- Source:
added
to the booklet layout.
remove(pages)
#
set(page)
#
A 'set' event is emitted when a page is set
to be displayed by the
booklet layout.
Parameters:
Name | Type | Description |
---|---|---|
page |
OO.ui.PageLayout | Current page |
- Source:
A 'set' event is emitted when a page is set
to be displayed by the
booklet layout.