From c02c52953769a10cbaba16b4c130e8684b268ce1 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Thu, 20 Apr 2017 18:47:51 +0100 Subject: [PATCH] Load notices when switching, just don't show them Previously we completely disabled the loading of notices when switching, instead of just not showing them (so they don't clash with the "switched" popup). Bug: T162812 Change-Id: I3f8e787630e196cee1dbb1aa449b3558b74fcd04 --- .../ve.init.mw.DesktopArticleTarget.js | 24 ++++++++++++++----- modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js | 11 ++------- 2 files changed, 20 insertions(+), 15 deletions(-) diff --git a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js index 9403616d7e..d0bcc363ed 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -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 ); } } ); } diff --git a/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js b/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js index 7759cf9124..71968d1da0 100644 --- a/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js +++ b/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js @@ -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 ); }; /**