mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-12 09:09:25 +00:00
Merge "Move around code that sets up edit notices to ensure it runs after we receive the notices to display"
This commit is contained in:
commit
8370b98e3f
|
@ -1418,6 +1418,7 @@ ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () {
|
||||||
if ( this.welcomeDialogPromise ) {
|
if ( this.welcomeDialogPromise ) {
|
||||||
this.welcomeDialogPromise
|
this.welcomeDialogPromise
|
||||||
.always( function () {
|
.always( function () {
|
||||||
|
var noticesTool;
|
||||||
// Pop out the notices when the welcome dialog is closed
|
// Pop out the notices when the welcome dialog is closed
|
||||||
if (
|
if (
|
||||||
target.switched &&
|
target.switched &&
|
||||||
|
@ -1425,7 +1426,9 @@ ve.init.mw.DesktopArticleTarget.prototype.maybeShowMetaDialog = function () {
|
||||||
) {
|
) {
|
||||||
target.actionsToolbar.tools.editModeSource.getPopup().toggle( true );
|
target.actionsToolbar.tools.editModeSource.getPopup().toggle( true );
|
||||||
} else {
|
} else {
|
||||||
target.actionsToolbar.tools.notices.getPopup().toggle( true );
|
noticesTool = target.actionsToolbar.tools.notices;
|
||||||
|
noticesTool.setNotices( target.getEditNotices() );
|
||||||
|
noticesTool.getPopup().toggle( true );
|
||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,36 +40,13 @@ OO.inheritClass( ve.ui.MWPopupTool, OO.ui.PopupTool );
|
||||||
* @param {Object} [config]
|
* @param {Object} [config]
|
||||||
*/
|
*/
|
||||||
ve.ui.MWNoticesPopupTool = function VeUiMWNoticesPopupTool( toolGroup, config ) {
|
ve.ui.MWNoticesPopupTool = function VeUiMWNoticesPopupTool( toolGroup, config ) {
|
||||||
var tool = this,
|
|
||||||
items = toolGroup.getToolbar().getTarget().getEditNotices(),
|
|
||||||
count = items.length,
|
|
||||||
title = ve.msg(
|
|
||||||
'visualeditor-editnotices-tool',
|
|
||||||
mw.language.convertNumber( count )
|
|
||||||
);
|
|
||||||
|
|
||||||
// Parent constructor
|
// Parent constructor
|
||||||
ve.ui.MWNoticesPopupTool.super.call( this, title, toolGroup, config );
|
ve.ui.MWNoticesPopupTool.super.call(
|
||||||
|
this,
|
||||||
// Properties
|
ve.msg( 'visualeditor-editnotices-tooltip' ),
|
||||||
this.$items = $( '<div>' ).addClass( 've-ui-mwNoticesPopupTool-items' );
|
toolGroup,
|
||||||
|
config
|
||||||
// Initialization
|
);
|
||||||
items.forEach( function ( itemHtml ) {
|
|
||||||
var $node = $( '<div>' )
|
|
||||||
.addClass( 've-ui-mwNoticesPopupTool-item' )
|
|
||||||
.append( $.parseHTML( itemHtml ) );
|
|
||||||
|
|
||||||
$node.find( 'a' ).attr( 'target', '_blank' );
|
|
||||||
|
|
||||||
tool.$items.append( $node );
|
|
||||||
} );
|
|
||||||
|
|
||||||
this.popup.$body.append( this.$items );
|
|
||||||
|
|
||||||
if ( !count ) {
|
|
||||||
this.$element = $( [] );
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Inheritance */
|
/* Inheritance */
|
||||||
|
@ -87,6 +64,39 @@ ve.ui.MWNoticesPopupTool.static.autoAddToGroup = false;
|
||||||
|
|
||||||
/* Methods */
|
/* Methods */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set notices to display.
|
||||||
|
*
|
||||||
|
* @param {string[]} notices
|
||||||
|
*/
|
||||||
|
ve.ui.MWNoticesPopupTool.prototype.setNotices = function ( notices ) {
|
||||||
|
var tool = this,
|
||||||
|
count = notices.length;
|
||||||
|
|
||||||
|
this.popup.setLabel( ve.msg(
|
||||||
|
'visualeditor-editnotices-tool',
|
||||||
|
mw.language.convertNumber( count )
|
||||||
|
) );
|
||||||
|
|
||||||
|
this.$items = $( '<div>' ).addClass( 've-ui-mwNoticesPopupTool-items' );
|
||||||
|
|
||||||
|
notices.forEach( function ( itemHtml ) {
|
||||||
|
var $node = $( '<div>' )
|
||||||
|
.addClass( 've-ui-mwNoticesPopupTool-item' )
|
||||||
|
.append( $.parseHTML( itemHtml ) );
|
||||||
|
|
||||||
|
$node.find( 'a' ).attr( 'target', '_blank' );
|
||||||
|
|
||||||
|
tool.$items.append( $node );
|
||||||
|
} );
|
||||||
|
|
||||||
|
this.popup.$body.append( this.$items );
|
||||||
|
|
||||||
|
if ( !count ) {
|
||||||
|
this.$element = $( [] );
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the tool title.
|
* Get the tool title.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue