Wrap reply link in container so it may contain more links in future

For example 'Edit'.

Change-Id: I3d3027724cfd69a6719932bb2cb80fa711010fc4
This commit is contained in:
Ed Sanders 2020-03-06 15:20:42 +00:00 committed by Bartosz Dziewoński
parent 23966cc098
commit 3af3f3ed8c
2 changed files with 13 additions and 10 deletions

View file

@ -13,19 +13,21 @@ var
mw.loader.using( 'ext.discussionTools.ReplyWidgetPlain' );
function setupComment( comment ) {
var $replyLink, widgetPromise, newListItem;
var $replyLinkButtons, $replyLink, widgetPromise, newListItem;
// Is it possible to have a heading nested in a thread?
if ( comment.type !== 'comment' ) {
return;
}
$replyLinkButtons = $( '<span>' )
.addClass( 'dt-init-replylink-buttons' );
// Reply
$replyLink = $( '<a>' )
.addClass( 'dt-init-replylink' )
.addClass( 'dt-init-replylink-reply' )
.text( mw.msg( 'discussiontools-replylink' ) )
.on( 'click', function () {
var $link = $( this );
// TODO: Allow users to use multiple reply widgets simultaneously.
// Currently submitting a reply from one widget would also destroy the other ones.
// eslint-disable-next-line no-jquery/no-class-state
@ -46,7 +48,7 @@ function setupComment( comment ) {
editor_interface: config.useVisualEditor ? 'wikitext-2017' : 'wikitext'
} );
$link.addClass( 'dt-init-replylink-active' );
$replyLinkButtons.addClass( 'dt-init-replylink-active' );
if ( !widgetPromise ) {
widgetPromise = replyWidgetPromise.then( function () {
@ -59,7 +61,7 @@ function setupComment( comment ) {
);
replyWidget.on( 'teardown', function () {
$link.removeClass( 'dt-init-replylink-active' );
$replyLinkButtons.removeClass( 'dt-init-replylink-active' );
$pageContainer.removeClass( 'dt-init-replylink-open' );
modifier.removeListItem( newListItem );
newListItem = null;
@ -67,7 +69,7 @@ function setupComment( comment ) {
return replyWidget;
}, function () {
$link.removeClass( 'dt-init-replylink-active' );
$replyLinkButtons.removeClass( 'dt-init-replylink-active' );
$pageContainer.removeClass( 'dt-init-replylink-open' );
logger( {
@ -96,7 +98,8 @@ function setupComment( comment ) {
} );
} );
modifier.addReplyLink( comment, $replyLink[ 0 ] );
$replyLinkButtons.append( $replyLink );
modifier.addReplyLink( comment, $replyLinkButtons[ 0 ] );
}
function traverseNode( parent ) {

View file

@ -1,4 +1,4 @@
.dt-init-replylink {
.dt-init-replylink-buttons {
user-select: none;
margin-left: 0.25em;
@ -6,7 +6,7 @@
visibility: hidden;
}
.dt-init-replylink-open & {
.dt-init-replylink-open & > a {
color: #72777d;
pointer-events: none;
}