jenkins-bot has submitted this change and it was merged.

Change subject: Alpha: Allow commenting on talk topics
......................................................................


Alpha: Allow commenting on talk topics

* Add default styling for em tag
* Create TalkSectionOverlay

Change-Id: I731ff792d3a009503e530272f85c2dfedde03b74
---
M MobileFrontend.i18n.php
M includes/Resources.php
M javascripts/modules/talk.js
A javascripts/modules/talk/TalkSectionOverlay.js
M less/common/mf-common.less
M stylesheets/common/mf-common.css
M templates/talkSection.html
7 files changed, 93 insertions(+), 6 deletions(-)

Approvals:
  Jdlrobson: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/MobileFrontend.i18n.php b/MobileFrontend.i18n.php
index e9052e6..bdbd83a 100644
--- a/MobileFrontend.i18n.php
+++ b/MobileFrontend.i18n.php
@@ -270,6 +270,9 @@
        'mobile-frontend-talk-add-overlay-subject-placeholder' => 'Topic 
subject',
        'mobile-frontend-talk-add-overlay-content-placeholder' => 'What is on 
your mind?',
        'mobile-frontend-talk-edit-summary' => 'New talk section: $1',
+       'mobile-frontend-talk-reply-success' => 'Your reply was successfully 
saved to the talk page.',
+       'mobile-frontend-talk-reply-info' => 'Note your reply will be 
automatically signed with your username.',
+       'mobile-frontend-talk-reply' => 'Reply',
 );
 
 /** Message documentation (Message documentation)
@@ -690,6 +693,9 @@
        'mobile-frontend-talk-add-overlay-subject-placeholder' => 'Placeholder 
text to prompt user to add a talk page topic subject',
        'mobile-frontend-talk-add-overlay-content-placeholder' => 'Placeholder 
text to prompt user to add content to talk page content',
        'mobile-frontend-talk-edit-summary' => 'Edit summary when creating a 
new talk section ($1 is name of section)',
+       'mobile-frontend-talk-reply-success' => 'Toast message when you have 
saved a reply successfully.',
+       'mobile-frontend-talk-reply-info' => 'Inform the user their talk reply 
will be automatically signed.',
+       'mobile-frontend-talk-reply' => 'Reply heading',
 );
 
 /** Achinese (Acèh)
diff --git a/includes/Resources.php b/includes/Resources.php
index 29959c7..aa49bf2 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -296,6 +296,7 @@
                        'javascripts/modules/editor/EditorOverlay.js',
                        'javascripts/modules/editor/editor.js',
                        'javascripts/modules/mf-toggle-dynamic.js',
+                       'javascripts/modules/talk/TalkSectionOverlay.js',
                        'javascripts/modules/talk.js',
                        'javascripts/common/user.js',
                        'javascripts/modules/search-pageimages.js',
@@ -318,6 +319,9 @@
                        'mobile-frontend-talk-add-overlay-content-placeholder',
                        'mobile-frontend-talk-edit-summary',
                        'mobile-frontend-talk-add-overlay-submit',
+                       'mobile-frontend-talk-reply-success',
+                       'mobile-frontend-talk-reply',
+                       'mobile-frontend-talk-reply-info',
 
                        // user.js
                        'mobile-frontend-user-cta',
diff --git a/javascripts/modules/talk.js b/javascripts/modules/talk.js
index d577d9c..e38fcf9 100644
--- a/javascripts/modules/talk.js
+++ b/javascripts/modules/talk.js
@@ -2,6 +2,7 @@
 
        var
                Overlay = M.require( 'Overlay' ),
+               TalkSectionOverlay = M.require( 
'modules/talk/TalkSectionOverlay' ),
                api = M.require( 'api' ),
                leadHeading = mw.msg( 
'mobile-frontend-talk-overlay-lead-header' ),
                TalkSectionAddOverlay = Overlay.extend( {
@@ -101,12 +102,14 @@
                                        var id = parseFloat( $( this ).data( 
'id' ), 10 ),
                                                leadSection = {
                                                        content: page.lead,
+                                                       id: 0,
                                                        heading: leadHeading
                                                },
                                                section = id === 0 ? 
leadSection : page.getSubSection( id ),
-                                               childOverlay = new Overlay( {
-                                                       content: 
M.template.get( 'talkSection' ).render( section ),
-                                                       parent: self
+                                               childOverlay = new 
TalkSectionOverlay( {
+                                                       parent: self,
+                                                       title: page.title,
+                                                       section: section
                                                } );
                                        childOverlay.show();
                                } );
diff --git a/javascripts/modules/talk/TalkSectionOverlay.js 
b/javascripts/modules/talk/TalkSectionOverlay.js
new file mode 100644
index 0000000..804e1bc
--- /dev/null
+++ b/javascripts/modules/talk/TalkSectionOverlay.js
@@ -0,0 +1,59 @@
+( function( M ) {
+
+var
+       Overlay = M.require( 'Overlay' ),
+       popup = M.require( 'notifications' ),
+       api = M.require( 'api' ),
+       TalkSectionOverlay = Overlay.extend( {
+               template: M.template.get( 'talkSection' ),
+               defaults: {
+                       closeMsg: mw.msg( 'mobile-frontend-overlay-escape' ),
+                       reply: mw.msg( 'mobile-frontend-talk-reply' ),
+                       confirmMsg: mw.msg( 'mobile-frontend-editor-confirm' ),
+                       licenseMsg: mw.msg( 'mobile-frontend-editor-license' ),
+                       info: mw.msg( 'mobile-frontend-talk-reply-info' )
+               },
+               postRender: function( options ) {
+                       var self = this, $comment = this.$( '.comment' );
+                       this._super( options );
+                       this.$( '.loading' ).remove();
+                       if ( !M.isLoggedIn() || mw.config.get( 'wgMFMode' ) !== 
'alpha' ) {
+                               $comment.remove();
+                       } else {
+                               $comment.find( 'button' ).on( 'click', 
function() {
+                                       var $textarea = self.$( 'textarea' ),
+                                               val = $textarea.val();
+                                       $comment.hide();
+                                       self.$( '.loading' ).show();
+                                       // sign and add newline to front
+                                       val = '\n\n' + val + ' ~~~~';
+                                       api.getToken().done( function( token ) {
+                                               api.post( {
+                                                       action: 'edit',
+                                                       title: options.title,
+                                                       section: 
options.section.id,
+                                                       token: token,
+                                                       appendtext: val
+                                               } ).done( function( data ) {
+                                                       self.$( '.loading' 
).hide();
+                                                       $comment.show();
+                                                       if ( data.error ) {
+                                                               
$textarea.addClass( 'error' );
+                                                       } else {
+                                                               self.hide();
+                                                               
self.parent.hide();
+                                                               popup.show( 
mw.msg( 'mobile-frontend-talk-reply-success' ), 'toast' );
+                                                               // invalidate 
the cache
+                                                               
M.history.invalidateCachedPage( options.title );
+                                                       }
+                                               } );
+                                       } );
+                               } );
+                       }
+               }
+       } );
+
+       M.define( 'modules/talk/TalkSectionOverlay', TalkSectionOverlay );
+
+}( mw.mobileFrontend ) );
+
diff --git a/less/common/mf-common.less b/less/common/mf-common.less
index 5b42819..80b30d3 100644
--- a/less/common/mf-common.less
+++ b/less/common/mf-common.less
@@ -261,6 +261,7 @@
        list-style: decimal inside;
 }
 
+em,
 i {
        font-style: italic;
 }
diff --git a/stylesheets/common/mf-common.css b/stylesheets/common/mf-common.css
index 16ad285..e943f22 100644
--- a/stylesheets/common/mf-common.css
+++ b/stylesheets/common/mf-common.css
@@ -217,6 +217,7 @@
 ol {
   list-style: decimal inside;
 }
+em,
 i {
   font-style: italic;
 }
diff --git a/templates/talkSection.html b/templates/talkSection.html
index 20db434..7e2e906 100644
--- a/templates/talkSection.html
+++ b/templates/talkSection.html
@@ -1,5 +1,18 @@
+<div class="header">
+       <button class="cancel">{{closeMsg}}</button>
+</div>
 <div class="content">
-<h2>{{heading}}</h2>
+       <h2>{{section.heading}}</h2>
 
-{{{content}}}
-</div>
\ No newline at end of file
+       {{{section.content}}}
+       <div class="loading"></div>
+       <div class="comment">
+               <h3>{{reply}}</h3>
+               <p>
+                       <em>{{info}}</em>
+                       <em>{{{licenseMsg}}}</em>
+               </p>
+               <textarea></textarea>
+               <button>{{confirmMsg}}</button>
+       </div>
+</div>

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I731ff792d3a009503e530272f85c2dfedde03b74
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: JGonera <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to