diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js index 2054cefedd..67e8c538d5 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWTransclusionDialog.js @@ -225,28 +225,24 @@ ve.ui.MWTransclusionDialog.prototype.setMode = function ( mode ) { if ( !modeCssClasses[mode] ) { mode = 'multiple'; } - this.mode = mode; - single = mode === 'single'; - if ( this.$content ) { - for ( name in modeCssClasses ) { - this.$content.toggleClass( modeCssClasses[name], name === mode ); + + if ( this.mode !== mode ) { + this.mode = mode; + single = mode === 'single'; + if ( this.$content ) { + for ( name in modeCssClasses ) { + this.$content.toggleClass( modeCssClasses[name], name === mode ); + } } + this.setSize( single ? 'medium' : 'large' ); + this.bookletLayout.toggleOutline( !single ); + this.updateTitle(); + this.updateModeActionLabel(); + + // HACK blur any active input so that its dropdown will be hidden and won't end + // up being mispositioned + this.$content.find( 'input:focus' ).blur(); } - this.setSize( single ? 'medium' : 'large' ); - this.bookletLayout.toggleOutline( !single ); - this.updateTitle(); - - this.actions.forEach( { actions: [ 'mode' ] }, function ( action ) { - action.setLabel( - single ? - ve.msg( 'visualeditor-dialog-transclusion-multiple-mode' ) : - ve.msg( 'visualeditor-dialog-transclusion-single-mode' ) - ); - } ); - - // HACK blur any active input so that its dropdown will be hidden and won't end - // up being mispositioned - this.$content.find( 'input:focus' ).blur(); }; /** @@ -261,6 +257,19 @@ ve.ui.MWTransclusionDialog.prototype.updateTitle = function () { } }; +/** + * Update the label for the 'mode' action + */ +ve.ui.MWTransclusionDialog.prototype.updateModeActionLabel = function () { + this.actions.forEach( { actions: [ 'mode' ] }, function ( action ) { + action.setLabel( + this.mode === 'single' ? + ve.msg( 'visualeditor-dialog-transclusion-multiple-mode' ) : + ve.msg( 'visualeditor-dialog-transclusion-single-mode' ) + ); + } ); +}; + /** * Add a part to the transclusion. * @@ -344,6 +353,7 @@ ve.ui.MWTransclusionDialog.prototype.getSetupProcess = function ( data ) { return ve.ui.MWTransclusionDialog.super.prototype.getSetupProcess.call( this, data ) .next( function () { this.setMode( 'single' ); + this.updateModeActionLabel(); this.actions.setAbilities( { mode: false } ); }, this ); };