Merge "Load notices when switching, just don't show them"

This commit is contained in:
jenkins-bot 2017-04-20 21:05:40 +00:00 committed by Gerrit Code Review
commit dd6113bb76
2 changed files with 20 additions and 15 deletions

View file

@ -747,10 +747,12 @@ ve.init.mw.DesktopArticleTarget.prototype.loadFail = function ( code, errorDetai
* @inheritdoc
*/
ve.init.mw.DesktopArticleTarget.prototype.surfaceReady = function () {
var surface = this.getSurface(),
var redirectMetaItems,
editNotices = this.getEditNotices(),
actionTools = this.actionsToolbar.tools,
surface = this.getSurface(),
surfaceReadyTime = ve.now(),
target = this,
redirectMetaItems;
target = this;
if ( !this.activating ) {
// Activation was aborted before we got here. Do nothing
@ -799,6 +801,14 @@ ve.init.mw.DesktopArticleTarget.prototype.surfaceReady = function () {
this.setFakeRedirectInterface( null );
}
// Set edit notices, will be shown after meta dialog.
if ( editNotices.length ) {
actionTools.notices.setNotices( this.getEditNotices() );
} else {
actionTools.notices.destroy();
actionTools.notices = null;
}
this.setupUnloadHandlers();
if ( !this.suppressNormalStartupDialogs ) {
this.maybeShowWelcomeDialog();
@ -1543,19 +1553,21 @@ ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () {
target = this;
if ( this.welcomeDialogPromise ) {
// Pop out the notices when the welcome dialog is closed
this.welcomeDialogPromise
.always( function () {
var popup;
// Pop out the notices when the welcome dialog is closed
if (
target.switched &&
!mw.user.options.get( 'visualeditor-hidevisualswitchpopup' )
) {
// Show "switched" popup
popup = new mw.libs.ve.SwitchPopupWidget( 'visual' );
target.actionsToolbar.tools.editModeSource.toolGroup.$element.append( popup.$element );
popup.toggle( true );
} else {
target.actionsToolbar.tools.notices.setNotices( target.getEditNotices() );
} else if ( target.actionsToolbar.tools.notices ) {
// Show notices
target.actionsToolbar.tools.notices.getPopup().toggle( true );
}
} );
}

View file

@ -65,19 +65,14 @@ ve.ui.MWNoticesPopupTool.static.autoAddToGroup = false;
/* Methods */
/**
* Set notices to display, and either destroy the tool (if none to display) or open the popup.
* Set notices to display
*
* @param {string[]} notices
* @param {string[]} notices A (non-empty) list of notices
*/
ve.ui.MWNoticesPopupTool.prototype.setNotices = function ( notices ) {
var tool = this,
count = notices.length;
if ( !count ) {
this.destroy();
return;
}
this.popup.setLabel( ve.msg(
'visualeditor-editnotices-tool',
mw.language.convertNumber( count )
@ -101,8 +96,6 @@ ve.ui.MWNoticesPopupTool.prototype.setNotices = function ( notices ) {
} );
this.popup.$body.append( this.$items );
this.popup.toggle( true );
};
/**