diff --git a/modules/CommentDetails.js b/modules/CommentDetails.js index 9629c3d69..7f4e520c4 100644 --- a/modules/CommentDetails.js +++ b/modules/CommentDetails.js @@ -5,10 +5,13 @@ * @constructor * @param {string} pageName Page name the reply is being saved to * @param {number} oldId Revision ID of page at time of editing + * @param {Object.} notices Edit notices for the page where the reply is being saved. + * Keys are message names; values are HTML to display. */ -function CommentDetails( pageName, oldId ) { +function CommentDetails( pageName, oldId, notices ) { this.pageName = pageName; this.oldId = oldId; + this.notices = notices; } OO.initClass( CommentDetails ); diff --git a/modules/NewTopicController.js b/modules/NewTopicController.js index 2731a883f..8d672a143 100644 --- a/modules/NewTopicController.js +++ b/modules/NewTopicController.js @@ -9,6 +9,7 @@ function NewTopicController( $pageContainer, $replyLink, parser ) { padded: true, framed: true } ); + this.$notices = $( '
' ).addClass( 'ext-discussiontools-ui-newTopic-notices' ); this.sectionTitle = new OO.ui.TextInputWidget( { // Wrap in a

element to inherit heading font styles @@ -23,7 +24,7 @@ function NewTopicController( $pageContainer, $replyLink, parser ) { } ); this.prevTitleText = ''; - this.container.$element.append( this.sectionTitleField.$element ); + this.container.$element.append( this.$notices, this.sectionTitleField.$element ); // HeadingItem representing the heading being added, so that we can pretend we're replying to it var comment = new HeadingItem( { @@ -67,6 +68,24 @@ NewTopicController.prototype.setup = function ( mode ) { NewTopicController.prototype.setupReplyWidget = function ( replyWidget, data ) { NewTopicController.super.prototype.setupReplyWidget.call( this, replyWidget, data ); + this.$notices.empty(); + for ( var noticeName in this.replyWidget.commentDetails.notices ) { + if ( + // Ignored because we have a custom warning for non-logged-in users. + noticeName === 'anoneditwarning' || + // Ignored because it contains mostly instructions for signing comments using tildes. + // (Does not appear in VE notices right now, but just in case.) + noticeName === 'talkpagetext' + ) { + continue; + } + var noticeItem = this.replyWidget.commentDetails.notices[ noticeName ]; + var $noticeElement = $( '
' ) + .addClass( 'ext-discussiontools-ui-replyWidget-notice' ) + .html( typeof noticeItem === 'string' ? noticeItem : noticeItem.message ); + this.$notices.append( $noticeElement ); + } + var title = this.replyWidget.storage.get( this.replyWidget.storagePrefix + '/title' ); if ( title && !this.sectionTitle.getValue() ) { // Don't overwrite if the user has already typed something in while the widget was loading. diff --git a/modules/controller.js b/modules/controller.js index d2d545d00..2d61791ee 100644 --- a/modules/controller.js +++ b/modules/controller.js @@ -208,7 +208,7 @@ function checkCommentOnPage( pageName, oldId, comment ) { } ] } ).promise(); } - return new CommentDetails( pageName, oldId ); + return new CommentDetails( pageName, oldId, metadata.notices ); } ); } diff --git a/modules/dt.ui.NewTopicController.less b/modules/dt.ui.NewTopicController.less index f4e54e965..ef7b87fb0 100644 --- a/modules/dt.ui.NewTopicController.less +++ b/modules/dt.ui.NewTopicController.less @@ -5,6 +5,16 @@ margin-top: 2em; } + .ext-discussiontools-ui-newTopic-notices { + // Ensure that the form is visible below the notice in case of large notices and small screens + max-height: 75vh; + overflow: auto; + } + + .ext-discussiontools-ui-newTopic-notices + .oo-ui-fieldLayout { + margin-top: 0; + } + h2&-sectionTitle { max-width: none; // This element is a

- override unwanted heading styles