Jforrester has uploaded a new change for review. (
https://gerrit.wikimedia.org/r/343107 )
Change subject: Follow-up eb8ba26a: Make MWNoticesTool#setNotices() display its
own popup
......................................................................
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
---
M modules/ve-mw/init/targets/ve.init.mw.DesktopArticleTarget.js
M modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js
2 files changed, 9 insertions(+), 11 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/07/343107/1
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 3bf42d8..a656b1b 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 @@
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 @@
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 b0dbef1..799fd68 100644
--- a/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js
+++ b/modules/ve-mw/ui/tools/ve.ui.MWPopupTool.js
@@ -65,13 +65,17 @@
/* 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
*/
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',
@@ -89,6 +93,7 @@
.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 @@
this.popup.$body.append( this.$items );
- if ( !count ) {
- this.destroy();
- }
+ this.popup.toggle( true );
};
/**
--
To view, visit https://gerrit.wikimedia.org/r/343107
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I492fd59a1e15e8f296bf7f03d9b0035c40dafa59
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Jforrester <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits