Extends
Constructor
new OO.ui.WindowManager([config])
#
Hierarchy
Window managers are used to open and close windows
and control their
presentation. Managed windows are mutually exclusive. If a new window is opened while a current
window is opening or is opened, the current window will be closed and any on-going
process
will be cancelled. Windows
themselves are persistent and—rather than being torn down when closed—can be repopulated with the
pertinent data and reused.
Over the lifecycle of a window, the window manager makes available three promises: opening
,
opened
, and closing
, which represent the primary stages of the cycle:
Opening: the opening stage begins when the window manager’s #openWindow or a window’s
open
method is used, and the window manager begins to open the window.
- an
opening
event is emitted with anopening
promise - the #getSetupDelay method is called and the returned value is used to time a pause in execution
before the window’s
setup
method is called which executes OO.ui.Window#getSetupProcess. - a
setup
progress notification is emitted from theopening
promise - the #getReadyDelay method is called the returned value is used to time a pause in execution
before the window’s
ready
method is called which executes OO.ui.Window#getReadyProcess. - a
ready
progress notification is emitted from theopening
promise - the
opening
promise is resolved with anopened
promise
Opened: the window is now open.
Closing: the closing stage begins when the window manager's #closeWindow or the
window's close
methods is used, and the window manager begins
to close the window.
- the
opened
promise is resolved withclosing
promise and aclosing
event is emitted - the #getHoldDelay method is called and the returned value is used to time a pause in execution
before the window's
getHoldProcess
method is called on the window and its result executed - a
hold
progress notification is emitted from theclosing
promise - the #getTeardownDelay() method is called and the returned value is used to time a pause in
execution before the window's
getTeardownProcess
method is called on the window and its result executed - a
teardown
progress notification is emitted from theclosing
promise - the
closing
promise is resolved. The window is now closed
See the OOUI documentation on MediaWiki for more information.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
config |
Object |
optional |
Configuration options Properties:
|
- Mixes in:
- Source:
Window managers are used to open and close windows
and control their
presentation.
Properties
defaultSizestatic
#
Symbolic name of the default window size.
The default size is used if the window's requested size is not recognized.
Properties:
Type | Description |
---|---|
string |
- Source:
sizesstatic
#
Map of the symbolic name of each window size and its CSS properties.
Symbolic name must be valid as a CSS class name suffix.
Properties:
Type | Description |
---|---|
Object |
- Source:
Methods
addWindows(windows)
#
Add windows to the window manager.
Windows can be added by reference, symbolic name, or explicitly defined symbolic names. See the [OOUI documentation on MediaWiki][2] for examples. [2]: https://www.mediawiki.org/wiki/OOUI/Windows/Window_managers
This function can be called in two manners:
.addWindows( [ winA, winB, ... ] )
(wherewinA
,winB
are OO.ui.Window objects)
This syntax registers windows under the symbolic names defined in their .static.name
properties. For example, if windowA.constructor.static.name
is 'nameA'
, calling
.openWindow( 'nameA' )
afterwards will open the window windowA
. This syntax requires the
static name to be set, otherwise an exception will be thrown.
This is the recommended way, as it allows for an easier switch to using a window factory.
.addWindows( { nameA: winA, nameB: winB, ... } )
This syntax registers windows under the explicitly given symbolic names. In this example,
calling .openWindow( 'nameA' )
afterwards will open the window windowA
, regardless of what
its .static.name
is set to. The static name is not required to be set.
This should only be used if you need to override the default symbolic names.
Example:
const windowManager = new OO.ui.WindowManager(); $( document.body ).append( windowManager.$element );
// Add a window under the default name: see OO.ui.MessageDialog.static.name windowManager.addWindows( [ new OO.ui.MessageDialog() ] ); // Add a window under an explicit name windowManager.addWindows( { myMessageDialog: new OO.ui.MessageDialog() } );
// Open window by default name windowManager.openWindow( 'message' ); // Open window by explicitly given name windowManager.openWindow( 'myMessageDialog' );
Parameters:
Name | Type | Description |
---|---|---|
windows |
Object.<string, OO.ui.Window> | Array.<OO.ui.Window> | An array of window objects specified by reference, symbolic name, or explicitly defined symbolic names. |
- Source:
Throws:
-
An error is thrown if a window is added by symbolic name, but has neither an explicit nor a statically configured symbolic name.
- Type
- Error
clearWindows() → {jQuery.Promise}
#
Remove all windows from the window manager.
Windows will be closed before they are removed. Note that the window manager, though not in use, will still listen to events. If the window manager will not be used again, you may wish to use the #destroy method instead. To remove just a subset of windows, use the #removeWindows method.
- Source:
Returns:
Promise resolved when all windows are closed and removed
- Type
- jQuery.Promise
closeWindow(win, [data]) → {OO.ui.WindowInstance}
#
Close a window.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
win |
OO.ui.Window | string | Window object or symbolic name of window to close |
|
data |
Object |
optional |
Window closing data |
- Source:
Returns:
A lifecycle object representing this particular opening of the window. For backwards-compatibility, the object is also a Thenable that is resolved when the window is done closing, see T163510.
- Type
- OO.ui.WindowInstance
Fires:
destroy()
#
Destroy the window manager.
- Source:
getClosestScrollableElementContainer() → {HTMLElement}
#
Get closest scrollable container.
- Inherited from:
- Source:
Returns:
Closest scrollable container
- Type
- HTMLElement
getCurrentWindow() → {OO.ui.Window|null
}
#
null
}
#
Get current window.
- Source:
Returns:
Currently opening/opened/closing window
- Type
-
OO.ui.Window
|
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}
#
getHoldDelay(win, [data]) → {number}
#
Get the number of milliseconds to wait after closing has begun before executing the 'hold' process.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
win |
OO.ui.Window | Window being closed |
|
data |
Object |
optional |
Window closing data |
- Source:
Returns:
Milliseconds to wait
- Type
- number
Get the number of milliseconds to wait after closing has begun before executing the 'hold' process.
getReadyDelay(win, [data]) → {number}
#
Get the number of milliseconds to wait after setup has finished before executing the ‘ready’ process.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
win |
OO.ui.Window | Window being opened |
|
data |
Object |
optional |
Window opening data |
- Source:
Returns:
Milliseconds to wait
- Type
- number
Get the number of milliseconds to wait after setup has finished before executing the ‘ready’ process.
getSetupDelay(win, [data]) → {number}
#
Get the number of milliseconds to wait after opening begins before executing the ‘setup’ process.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
win |
OO.ui.Window | Window being opened |
|
data |
Object |
optional |
Window opening data |
- Source:
Returns:
Milliseconds to wait
- Type
- number
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
getTeardownDelay(win, [data]) → {number}
#
Get the number of milliseconds to wait after the ‘hold’ process has finished before executing the ‘teardown’ process.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
win |
OO.ui.Window | Window being closed |
|
data |
Object |
optional |
Window closing data |
- Source:
Returns:
Milliseconds to wait
- Type
- number
Get the number of milliseconds to wait after the ‘hold’ process has finished before executing the ‘teardown’ process.
getWindow(name) → {jQuery.Promise}
#
Get a window by its symbolic name.
If the window is not yet instantiated and its symbolic name is recognized by a factory, it will be instantiated and added to the window manager automatically. Please see the [OOUI documentation on MediaWiki][3] for more information about using factories. [3]: https://www.mediawiki.org/wiki/OOUI/Windows/Window_managers
Parameters:
Name | Type | Description |
---|---|---|
name |
string | Symbolic name of the window |
- Source:
Returns:
Promise resolved with matching window, or rejected with an OO.ui.Error
- Type
- jQuery.Promise
Throws:
hasWindow(win) → {boolean}
#
Check if a window is being managed.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window to check |
- Source:
Returns:
Window is being managed
- Type
- boolean
isClosing(win) → {boolean}
#
Check if window is closing.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window to check |
- Source:
Returns:
Window is closing
- 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
isModal() → {boolean}
#
Check if the window manager is modal, preventing interaction outside the current window
- Source:
Returns:
The window manager is modal
- Type
- boolean
isOpened(win) → {boolean}
#
Check if window is opened.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window to check |
- Source:
Returns:
Window is opened
- Type
- boolean
isOpening(win) → {boolean}
#
Check if window is opening.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window to check |
- Source:
Returns:
Window is opening
- Type
- boolean
isVisible() → {boolean}
#
Check if element is visible.
- Inherited from:
- Source:
Returns:
element is visible
- Type
- boolean
openWindow(win, [data], [lifecycle], [compatOpening]) → {OO.ui.WindowInstance}
#
Open a window.
Parameters:
Name | Type | Attributes | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
win |
OO.ui.Window | string | Window object or symbolic name of window to open |
|||||||||
data |
Object |
optional |
Window opening data Properties:
|
||||||||
lifecycle |
OO.ui.WindowInstance |
optional |
Used internally |
||||||||
compatOpening |
jQuery.Deferred |
optional |
Used internally |
- Source:
Returns:
A lifecycle object representing this particular opening of the window. For backwards-compatibility, then object is also a Thenable that is resolved when the window is done opening, with nested promise for when closing starts. This behaviour is deprecated and is not compatible with jQuery 3, see T163510.
- Type
- OO.ui.WindowInstance
Fires:
removeWindows(names) → {jQuery.Promise}
#
Remove the specified windows from the windows manager.
Windows will be closed before they are removed. If you wish to remove all windows, you may wish to use the #clearWindows method instead. If you no longer need the window manager and want to ensure that it no longer listens to events, use the #destroy method.
Parameters:
Name | Type | Description |
---|---|---|
names |
Array.<string> | Symbolic names of windows to remove |
- Source:
Returns:
Promise resolved when window is closed and removed
- Type
- jQuery.Promise
Throws:
-
An error is thrown if the named windows are not managed by the window manager.
- Type
- Error
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
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
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:
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:
updateWindowSize(win) → {OO.ui.WindowManager}chainable
#
Set dialog size. In general, this method should not be called directly.
Fullscreen mode will be used if the dialog is too wide to fit in the screen.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window to update, should be the current window |
- Source:
Returns:
The manager, for chaining
- Type
- OO.ui.WindowManager
Events
closing(win, closed, data)
#
A 'closing' event is emitted when the window begins to be closed.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window that's being closed |
closed |
jQuery.Promise | A promise resolved with a value when the window is closed
successfully. This promise also emits |
data |
Object | Window closing data |
- Source:
opening(win, opened, data)
#
An 'opening' event is emitted when the window begins to be opened.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window that's being opened |
opened |
jQuery.Promise | A promise resolved with a value when the window is opened
successfully. This promise also emits |
data |
Object | Window opening data |
- Source:
resize(win)
#
A 'resize' event is emitted when a window is resized.
Parameters:
Name | Type | Description |
---|---|---|
win |
OO.ui.Window | Window that was resized |
- Source: