mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-09-25 11:16:51 +00:00
Follow-up eb8ba26a
: Make MWNoticesTool#setNotices() display its own popup
Running setNotices( [] ) makes MWNoticesTool run this.destroy() to avoid taking up extra space in the toolbar when not needed. Also, make setNotices() bail earlier. Change-Id: I492fd59a1e15e8f296bf7f03d9b0035c40dafa59
This commit is contained in:
parent
f39c6f5983
commit
ec5590418e
|
@ -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() );
|
||||
}
|
||||
} );
|
||||
}
|
||||
|
|
|
@ -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 );
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue