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 3bf42d885b..a656b1b6ae 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js @@ -1598,7 +1598,7 @@ ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () { if ( this.welcomeDialogPromise ) { this.welcomeDialogPromise .always( function () { - var noticesTool, popup, notices; + var popup; // Pop out the notices when the welcome dialog is closed if ( target.switched && @@ -1608,12 +1608,7 @@ ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () { target.actionsToolbar.tools.editModeSource.toolGroup.$element.append( popup.$element ); popup.toggle( true ); } else { - notices = target.getEditNotices(); - if ( notices.length ) { - noticesTool = target.actionsToolbar.tools.notices; - noticesTool.setNotices( notices ); - noticesTool.getPopup().toggle( true ); - } + target.actionsToolbar.tools.notices.setNotices( target.getEditNotices() ); } } ); } diff --git a/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js b/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js index b0dbef1bfa..799fd68928 100644 --- a/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js +++ b/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js @@ -65,7 +65,7 @@ ve.ui.MWNoticesPopupTool.static.autoAddToGroup = false; /* Methods */ /** - * Set notices to display. + * Set notices to display, and either destroy the tool (if none to display) or open the popup. * * @param {string[]} notices */ @@ -73,6 +73,10 @@ ve.ui.MWNoticesPopupTool.prototype.setNotices = function ( notices ) { var tool = this, count = notices.length; + if ( !count ) { + this.destroy(); + } + this.popup.setLabel( ve.msg( 'visualeditor-editnotices-tool', mw.language.convertNumber( count ) @@ -89,6 +93,7 @@ ve.ui.MWNoticesPopupTool.prototype.setNotices = function ( notices ) { .addClass( 've-ui-mwNoticesPopupTool-item' ) .append( $.parseHTML( itemHtml ) ); + // Ensure that any links in the notices open in a new tab/window $node.find( 'a' ).attr( 'target', '_blank' ); tool.$items.append( $node ); @@ -96,9 +101,7 @@ ve.ui.MWNoticesPopupTool.prototype.setNotices = function ( notices ) { this.popup.$body.append( this.$items ); - if ( !count ) { - this.destroy(); - } + this.popup.toggle( true ); }; /**