Jdlrobson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/171981
Change subject: Enable routing on TalkSectionOverlay
......................................................................
Enable routing on TalkSectionOverlay
Bug: 71075
Change-Id: Ie5dd5b0e66cd192e32dc9288732d16ed49948eec
---
M javascripts/modules/talk/TalkOverlay.js
M javascripts/modules/talk/TalkSectionOverlay.js
M javascripts/modules/talk/talk.js
M templates/modules/talk/talk.hogan
4 files changed, 46 insertions(+), 69 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend
refs/changes/81/171981/1
diff --git a/javascripts/modules/talk/TalkOverlay.js
b/javascripts/modules/talk/TalkOverlay.js
index 4dbdb92..b70bef7 100644
--- a/javascripts/modules/talk/TalkOverlay.js
+++ b/javascripts/modules/talk/TalkOverlay.js
@@ -4,7 +4,6 @@
var
Overlay = M.require( 'Overlay' ),
Page = M.require( 'Page' ),
- TalkSectionOverlay = M.require(
'modules/talk/TalkSectionOverlay' ),
user = M.require( 'user' ),
/**
* Overlay for talk page
@@ -46,9 +45,6 @@
this._loadContent( options );
}
this._setupAddDiscussionButton( options );
- if ( this.page ) {
- this._setupSectionLinks();
- }
this._showHidden( '.initial-header' );
},
@@ -133,38 +129,6 @@
} else {
$add.remove();
}
- },
- /**
- * Setups the headings as links that when clicked open
an overlay with the talk
- * page content.
- * FIXME: Make this a link in the template.
- * @method
- */
- _setupSectionLinks: function () {
- var childOverlay, self = this,
- page = this.page;
-
- // FIXME: Use Router instead for this
- this.$( '.page-list a' ).on( 'click', function
() {
- var id = parseFloat( $( this ).data(
'id' ), 10 ),
- section = page.getSubSection(
id );
-
- if ( section ) {
- childOverlay = new
TalkSectionOverlay( {
- parent: self,
- title: page.title,
- section: section
- } );
- // Hide discussion list to
disable scrolling - bug 70989
- // FIXME: Kill when
OverlayManager is used for TalkSections
- self.$board.hide();
- childOverlay.show();
- }
- // When closing this overlay, also
close the child section overlay
- self.on( 'hide', function () {
- childOverlay.remove();
- } );
- } );
}
} );
diff --git a/javascripts/modules/talk/TalkSectionOverlay.js
b/javascripts/modules/talk/TalkSectionOverlay.js
index dcdb18b..1ede88e 100644
--- a/javascripts/modules/talk/TalkSectionOverlay.js
+++ b/javascripts/modules/talk/TalkSectionOverlay.js
@@ -4,6 +4,7 @@
popup = M.require( 'toast' ),
api = M.require( 'api' ),
user = M.require( 'user' ),
+ Page = M.require( 'Page' ),
TalkSectionOverlay;
/**
@@ -17,40 +18,42 @@
content: mw.template.get( 'mobile.talk.overlays',
'Section/content.hogan' )
},
defaults: {
+ title: undefined,
+ section: undefined,
reply: mw.msg( 'mobile-frontend-talk-reply' ),
confirmMsg: mw.msg( 'mobile-frontend-editor-save' ),
info: mw.msg( 'mobile-frontend-talk-reply-info' )
},
- // FIXME: Use Router for TalkSectionOverlay
- hide: function () {
- if ( this.$board ) {
- this.$board.show();
- }
- this.remove();
- },
- initialize: function ( options ) {
- // If terms of use is enabled, include it in the
licensing message
- if ( $( '#footer-places-terms-use' ).length > 0 ) {
- options.licenseMsg = mw.msg(
-
'mobile-frontend-editor-licensing-with-terms',
- $( '#footer-places-terms-use' ).html(),
- mw.config.get( 'wgMFLicenseLink' )
- );
- } else {
- options.licenseMsg = mw.msg(
- 'mobile-frontend-editor-licensing',
- mw.config.get( 'wgMFLicenseLink' )
- );
- }
- this.$board = options.parent.$board;
- Overlay.prototype.initialize.apply( this, arguments );
- },
+ /**
+ * Fetches the talk topics of the page specified in
options.title
+ * if options.section is not defined.
+ * @inheritdoc
+ */
postRender: function ( options ) {
+ var self = this;
+
+ Overlay.prototype.postRender.apply( this, arguments );
+ if ( !options.section ) {
+ M.pageApi.getPage( options.title ).done(
function ( pageData ) {
+ var page = new Page( pageData );
+ options.section = page.getSubSection(
options.id );
+ self.render( options );
+ } );
+ } else {
+ this.$( '.loading' ).remove();
+ this._enableComments( options.title, options.id
);
+ }
+ },
+ /**
+ * Enables comments on the current rendered talk topic
+ * @method
+ * @param {String} title of the talk page with `Talk` prefix to
post to
+ * @param {Integer} id of the sub section to open
+ */
+ _enableComments: function ( title, id ) {
var self = this, $comment = this.$( '.comment' ),
$textarea = $comment.find( 'textarea' );
- Overlay.prototype.postRender.apply( this, arguments );
- this.$( '.back' ).on( 'click', $.proxy( self, 'hide' )
);
- this.$( '.loading' ).remove();
+
if ( user.isAnon() || !M.isAlphaGroupMember() ) {
$comment.remove();
} else {
@@ -67,8 +70,8 @@
api.getTokenWithEndpoint().done( function ( token ) {
api.post( {
action: 'edit',
- title:
options.title,
- section:
options.section.id,
+ title: title,
+ section: id,
token: token,
appendtext: val
} ).done( function (
data ) {
@@ -78,10 +81,9 @@
$textarea.addClass( 'error' );
} else {
self.hide();
-
options.parent.hide();
popup.show( mw.msg( 'mobile-frontend-talk-reply-success' ), 'toast' );
//
invalidate the cache
-
M.pageApi.invalidatePage( options.title );
+
M.pageApi.invalidatePage( title );
}
} );
} );
diff --git a/javascripts/modules/talk/talk.js b/javascripts/modules/talk/talk.js
index 49a5613..5829da9 100644
--- a/javascripts/modules/talk/talk.js
+++ b/javascripts/modules/talk/talk.js
@@ -1,5 +1,6 @@
( function ( M, $ ) {
- var talkPrefix = mw.config.get( 'wgFormattedNamespaces' )[
mw.config.get( 'wgNamespaceNumber' ) + 1 ] + ':';
+ var licenseLink = mw.config.get( 'wgMFLicenseLink' ),
+ talkPrefix = mw.config.get( 'wgFormattedNamespaces' )[
mw.config.get( 'wgNamespaceNumber' ) + 1 ] + ':';
M.assertMode( [ 'beta', 'alpha', 'app' ] );
@@ -9,10 +10,20 @@
title: talkPrefix + M.getCurrentPage().title
};
+ if ( $( '#footer-places-terms-use' ).length > 0 ) {
+ talkOptions.licenseMsg = mw.msg(
'mobile-frontend-editor-licensing-with-terms',
+ $( '#footer-places-terms-use' ).html(),
licenseLink );
+ } else {
+ talkOptions.licenseMsg = mw.msg(
'mobile-frontend-editor-licensing', licenseLink );
+ }
+
M.loadModule( 'mobile.talk.overlays' ).done( function () {
var Overlay;
if ( id === 'new' ) {
Overlay = M.require(
'modules/talk/TalkSectionAddOverlay' );
+ } else if ( id ) {
+ talkOptions.id = id;
+ Overlay = M.require(
'modules/talk/TalkSectionOverlay' );
} else {
Overlay = M.require( 'modules/talk/TalkOverlay'
);
}
diff --git a/templates/modules/talk/talk.hogan
b/templates/modules/talk/talk.hogan
index 3bef980..298ce20 100644
--- a/templates/modules/talk/talk.hogan
+++ b/templates/modules/talk/talk.hogan
@@ -5,7 +5,7 @@
<ul class="page-list">
{{#headings}}
<li>
- <a data-id="{{id}}">{{line}}</a>
+ <a data-id="{{id}}"
href="#/talk/{{id}}">{{line}}</a>
</li>
{{/headings}}
</ul>
--
To view, visit https://gerrit.wikimedia.org/r/171981
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie5dd5b0e66cd192e32dc9288732d16ed49948eec
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits