mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-01 02:37:05 +00:00
Trigger a window resize event when toggling sidebar state
Other page elements outside of Vector should be notified that the content area is changing size, in case they need to adjust the size of fixed elements. Triggering window.resize should allow them to adapt without needing to write Vector-specific code. A specific case of this: the floating edit toolbar when VisualEditor is open would be incorrectly sized / aligned if you toggled the sidebar in edit mode. Bug: T300826 Change-Id: I79e0fc67b5e35c2fb975a0a3048184de0d63813e
This commit is contained in:
parent
59c89b2db7
commit
19edeeabe0
|
@ -129,6 +129,17 @@ function saveSidebarState( checkbox ) {
|
|||
return debounce( 1000, function () {
|
||||
api = api || new mw.Api();
|
||||
api.saveOption( SIDEBAR_PREFERENCE_NAME, checkbox.checked ? 1 : 0 );
|
||||
|
||||
// Trigger a resize event so other parts of the page can adapt:
|
||||
var event;
|
||||
if ( typeof Event === 'function' ) {
|
||||
event = new Event( 'resize' );
|
||||
} else {
|
||||
// IE11
|
||||
event = window.document.createEvent( 'UIEvents' );
|
||||
event.initUIEvent( 'resize', true, false, window, 0 );
|
||||
}
|
||||
window.dispatchEvent( event );
|
||||
} );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue