mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 18:39:52 +00:00
Merge "Clean up toggleSidebar by splitting out 'auto'"
This commit is contained in:
commit
6cdd1f6ebf
|
@ -275,16 +275,13 @@ ve.ui.MWTransclusionDialog.prototype.getPageFromPart = function ( part ) {
|
|||
};
|
||||
|
||||
/**
|
||||
* Set if the dialog is expanded and the sidebar visible, or collapsed.
|
||||
* Automatically expand or collapse the sidebar according to default logic.
|
||||
*
|
||||
* @param {boolean|string} [toggle=true] True or false to expand or collapse the sidebar, or
|
||||
* 'auto' to auto-detect based on the dialog's current content.
|
||||
* @private
|
||||
*/
|
||||
ve.ui.MWTransclusionDialog.prototype.toggleSidebar = function ( toggle ) {
|
||||
var showSidebar = toggle !== false;
|
||||
ve.ui.MWTransclusionDialog.prototype.autoExpandSidebar = function () {
|
||||
var showSidebar;
|
||||
|
||||
if ( toggle === 'auto' ) {
|
||||
if ( this.useInlineDescriptions ) {
|
||||
var isSmallScreen = $( window ).width() <= this.constructor.static.smallScreenMaxWidth;
|
||||
showSidebar = !isSmallScreen;
|
||||
|
@ -293,15 +290,25 @@ ve.ui.MWTransclusionDialog.prototype.toggleSidebar = function ( toggle ) {
|
|||
} else {
|
||||
showSidebar = !this.isSingleTemplateTransclusion();
|
||||
}
|
||||
|
||||
this.toggleSidebar( showSidebar );
|
||||
};
|
||||
|
||||
/**
|
||||
* Set if the sidebar is visible (which means the dialog is expanded), or collapsed.
|
||||
*
|
||||
* @param {boolean} showSidebar
|
||||
* @private
|
||||
*/
|
||||
ve.ui.MWTransclusionDialog.prototype.toggleSidebar = function ( showSidebar ) {
|
||||
if ( this.isSidebarExpanded === showSidebar ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( this.isSidebarExpanded !== showSidebar ) {
|
||||
this.isSidebarExpanded = showSidebar;
|
||||
if ( this.$content ) {
|
||||
this.$content
|
||||
.toggleClass( 've-ui-mwTransclusionDialog-collapsed', !showSidebar )
|
||||
.toggleClass( 've-ui-mwTransclusionDialog-expanded', showSidebar );
|
||||
}
|
||||
this.ignoreNextWindowResizeEvent = true;
|
||||
this.setSize( showSidebar ? ( this.useInlineDescriptions ? 'larger' : 'large' ) : 'medium' );
|
||||
this.bookletLayout.toggleOutline( showSidebar );
|
||||
|
@ -311,7 +318,6 @@ ve.ui.MWTransclusionDialog.prototype.toggleSidebar = function ( toggle ) {
|
|||
// HACK blur any active input so that its dropdown will be hidden and won't end
|
||||
// up being mispositioned
|
||||
this.$content.find( 'input:focus' ).trigger( 'blur' );
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -482,7 +488,7 @@ ve.ui.MWTransclusionDialog.prototype.resetDialog = function () {
|
|||
this.transclusionModel
|
||||
.addPart( new ve.dm.MWTemplatePlaceholderModel( this.transclusionModel ), 0 )
|
||||
.done( function () {
|
||||
target.toggleSidebar( 'auto' );
|
||||
target.autoExpandSidebar();
|
||||
target.updateModeActionState();
|
||||
} );
|
||||
};
|
||||
|
@ -570,7 +576,7 @@ ve.ui.MWTransclusionDialog.prototype.getSetupProcess = function ( data ) {
|
|||
}
|
||||
|
||||
this.updateModeActionState();
|
||||
this.toggleSidebar( 'auto' );
|
||||
this.autoExpandSidebar();
|
||||
}, this );
|
||||
};
|
||||
|
||||
|
@ -579,7 +585,7 @@ ve.ui.MWTransclusionDialog.prototype.getSetupProcess = function ( data ) {
|
|||
*/
|
||||
ve.ui.MWTransclusionDialog.prototype.onWindowResize = function () {
|
||||
if ( !this.ignoreNextWindowResizeEvent ) {
|
||||
this.toggleSidebar( 'auto' );
|
||||
this.autoExpandSidebar();
|
||||
}
|
||||
this.ignoreNextWindowResizeEvent = false;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue