Catrope has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/231708

Change subject: Make the reply link for the last post work
......................................................................

Make the reply link for the last post work

The reply link for the last post points to the ID of the
topic, not the ID of the post, so it needs to be handled
differently. It also needs to hook into the (initially collapsed)
ReplyWidget that's already present at the bottom of each topic.

Bug: T109143
Change-Id: I26b030656c2a80d7b2508654a02fd8a1805ce375
---
M modules/flow-initialize.js
M modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
2 files changed, 13 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/08/231708/1

diff --git a/modules/flow-initialize.js b/modules/flow-initialize.js
index d1e50f8..ef5c3e8 100644
--- a/modules/flow-initialize.js
+++ b/modules/flow-initialize.js
@@ -223,6 +223,7 @@
                                                $topic.removeClass( 
'flow-api-inprogress' );
                                        } );
                                } );
+                               replyWidget.$element.data( 'self', replyWidget 
);
 
                                // Replace the reply form with the new editor 
widget
                                $( this ).replaceWith( replyWidget.$element );
@@ -238,13 +239,16 @@
                                        $topic = $( this ).closest( 
'.flow-topic' ),
                                        placeholder = mw.msg( 
'flow-reply-topic-title-placeholder', $topic.find( '.flow-topic-title' 
).text().trim() ),
                                        replyTo = $( this ).data( 'postId' ),
-                                       $targetPost = $( '#flow-post-' + 
replyTo ),
-                                       $existingWidget = $targetPost.children( 
'.flow-replies' ).find( '.flow-ui-replyWidget' );
+                                       // replyTo can refer to a post ID or a 
topic ID
+                                       // For posts, the ReplyWidget should go 
in .flow-replies
+                                       // For topics, it's directly inside the 
topic
+                                       $targetContainer = $( '#flow-post-' + 
replyTo + ' .flow-replies, #flow-topic-' + replyTo ),
+                                       $existingWidget = 
$targetContainer.children( '.flow-ui-replyWidget' );
 
                                // Check that there's not already a reply 
widget existing in the same place
                                if ( $existingWidget.length > 0 ) {
                                        // Focus the existing reply widget
-                                       $existingWidget.data( 'self' ).toggle( 
true );
+                                       $existingWidget.data( 'self' 
).activateEditor();
                                        $existingWidget.data( 'self' ).focus();
                                        return false;
                                }
@@ -257,7 +261,7 @@
                                replyWidget.$element.data( 'self', replyWidget 
);
 
                                // Add reply form below the post being replied 
to (WRT max depth)
-                               $targetPost.children( '.flow-replies' ).append( 
replyWidget.$element );
+                               $targetContainer.append( replyWidget.$element );
                                replyWidget.activateEditor();
 
                                replyWidget
diff --git a/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js 
b/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
index 5279c71..bb4d4aa 100644
--- a/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
+++ b/modules/flow/ui/widgets/mw.flow.ui.ReplyWidget.js
@@ -87,8 +87,6 @@
         */
        mw.flow.ui.ReplyWidget.prototype.onTriggerFocusIn = function () {
                this.activateEditor();
-               this.triggerInput.setValue( '' );
-               this.triggerInput.toggle( false );
        };
 
        /**
@@ -152,6 +150,11 @@
         * Force activation of the editor
         */
        mw.flow.ui.ReplyWidget.prototype.activateEditor = function () {
+               if ( this.triggerInput ) {
+                       this.triggerInput.setValue( '' );
+                       this.triggerInput.toggle( false );
+               }
+               this.toggle( true );
                this.anonWarning.toggle( true );
                this.editor.toggle( true );
                this.editor.activate();

-- 
To view, visit https://gerrit.wikimedia.org/r/231708
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I26b030656c2a80d7b2508654a02fd8a1805ce375
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Catrope <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to