jenkins-bot has submitted this change and it was merged.
Change subject: Hygiene: Make add talk discussion a route.
......................................................................
Hygiene: Make add talk discussion a route.
Bug: 71076
Change-Id: I0ba931bfd20bb083c8f226f8f39ad711f6d88a2e
---
M javascripts/modules/talk/TalkOverlay.js
M javascripts/modules/talk/TalkSectionAddOverlay.js
M javascripts/modules/talk/talk.js
M less/Overlay.less
M templates/OverlayHeader.hogan
M tests/qunit/modules/talk/test_TalkOverlay.js
6 files changed, 21 insertions(+), 38 deletions(-)
Approvals:
Jhernandez: Looks good to me, approved
jenkins-bot: Verified
diff --git a/javascripts/modules/talk/TalkOverlay.js
b/javascripts/modules/talk/TalkOverlay.js
index 0fbc16c..4dbdb92 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' ),
- TalkSectionAddOverlay = M.require(
'modules/talk/TalkSectionAddOverlay' ),
TalkSectionOverlay = M.require(
'modules/talk/TalkSectionOverlay' ),
user = M.require( 'user' ),
/**
@@ -30,6 +29,7 @@
leadHeading: mw.msg(
'mobile-frontend-talk-overlay-lead-header' ),
headerButtonsListClassName: 'overlay-action',
headerButtons: [ {
+ href: '#/talk/new',
className: 'add continue hidden',
msg: mw.msg(
'mobile-frontend-talk-add-overlay-submit' )
} ],
@@ -123,38 +123,13 @@
/**
* Shows the add topic button to logged in users.
* Ensures the overlay refreshes when a discussion is
added.
- * FIXME: Make this a link in the template.
* @method
- * @param {Object} options for the overlay
*/
- _setupAddDiscussionButton: function ( options ) {
- var $add = this.$( 'button.add' ),
- self = this;
-
+ _setupAddDiscussionButton: function () {
+ var $add = this.$( '.overlay-action .add' );
+ M.on( 'talk-discussion-added', $.proxy( this,
'_loadContent', this.options ) );
if ( !user.isAnon() ) {
$add.removeClass( 'hidden' );
- $add.click( function () {
- var overlay = new
TalkSectionAddOverlay( {
- title: options.title
- } );
- // Hide discussion list to
disable scrolling - bug 70989
- // FIXME: Kill when
OverlayManager is used for TalkSectionAdd
- self.$board.hide();
- overlay.on(
'talk-discussion-added', function () {
- // reload the content
- self._loadContent(
options );
- } ).on( 'hide', function () {
- // re-enable
TalkOverlay (it's closed by hide event (in Overlay)
- // from
TalkSectionAddOverlay)
- self.show();
- // FIXME: Kill when
OverlayManager is used for TalkSectionAdd
- self.$board.show();
- } ).show();
- // When closing this overlay,
also close the child section overlay
- self.on( 'hide', function () {
- overlay.remove();
- } );
- } );
} else {
$add.remove();
}
diff --git a/javascripts/modules/talk/TalkSectionAddOverlay.js
b/javascripts/modules/talk/TalkSectionAddOverlay.js
index 18f67db..436673a 100644
--- a/javascripts/modules/talk/TalkSectionAddOverlay.js
+++ b/javascripts/modules/talk/TalkSectionAddOverlay.js
@@ -46,7 +46,6 @@
postRender: function ( options ) {
var self = this;
Overlay.prototype.postRender.call( this, options );
- this.$( '.back' ).on( 'click', $.proxy( self, 'hide' )
);
this.confirm = this.$( 'button.confirm-save' );
this.confirm.on( 'click', function () {
if ( !$( this ).prop( 'disabled' ) ) {
@@ -54,7 +53,7 @@
if ( status === 'ok' ) {
M.pageApi.invalidatePage( self.title );
toast.show( mw.msg(
'mobile-frontend-talk-topic-feedback' ), 'toast' );
- self.emit(
'talk-discussion-added' );
+ M.emit(
'talk-discussion-added' );
self.hide();
}
} ).fail( function ( error ) {
diff --git a/javascripts/modules/talk/talk.js b/javascripts/modules/talk/talk.js
index 7b20ac8..49a5613 100644
--- a/javascripts/modules/talk/talk.js
+++ b/javascripts/modules/talk/talk.js
@@ -3,16 +3,20 @@
M.assertMode( [ 'beta', 'alpha', 'app' ] );
- M.overlayManager.add( /^\/talk$/, function () {
+ M.overlayManager.add( /^\/talk\/?(.*)$/, function ( id ) {
var result = $.Deferred(),
talkOptions = {
title: talkPrefix + M.getCurrentPage().title
};
M.loadModule( 'mobile.talk.overlays' ).done( function () {
- var TalkOverlay = M.require( 'modules/talk/TalkOverlay'
);
-
- result.resolve( new TalkOverlay( talkOptions ) );
+ var Overlay;
+ if ( id === 'new' ) {
+ Overlay = M.require(
'modules/talk/TalkSectionAddOverlay' );
+ } else {
+ Overlay = M.require( 'modules/talk/TalkOverlay'
);
+ }
+ result.resolve( new Overlay( talkOptions ) );
} );
return result;
} );
diff --git a/less/Overlay.less b/less/Overlay.less
index 1b3c11f..f6c2556 100644
--- a/less/Overlay.less
+++ b/less/Overlay.less
@@ -170,7 +170,9 @@
}
.overlay-action {
+ a,
button {
+ display: inline-block;
width: auto !important;
padding: 0 1.2em;
font-weight: bold;
@@ -226,6 +228,7 @@
width: @headerHeight;
}
+ .overlay-action a,
button {
width: @headerHeight;
border-radius: 0;
diff --git a/templates/OverlayHeader.hogan b/templates/OverlayHeader.hogan
index 2e1ea26..4efb619 100644
--- a/templates/OverlayHeader.hogan
+++ b/templates/OverlayHeader.hogan
@@ -7,7 +7,9 @@
{{#headerButtons}}
<div class="{{headerButtonsListClassName}}">
{{#headerButtons}}
- <button class="{{className}}">{{msg}}</button>
+ {{^href}}<button{{/href}}
+ {{#href}}<a href="{{href}}"{{/href}}
+
class="{{className}}">{{msg}}{{^href}}</button>{{/href}}{{#href}}</a>{{/href}}
{{/headerButtons}}
</div>
{{/headerButtons}}
diff --git a/tests/qunit/modules/talk/test_TalkOverlay.js
b/tests/qunit/modules/talk/test_TalkOverlay.js
index add0361..8197357 100644
--- a/tests/qunit/modules/talk/test_TalkOverlay.js
+++ b/tests/qunit/modules/talk/test_TalkOverlay.js
@@ -37,14 +37,14 @@
assert.strictEqual( page.getSubSections().length, 0, 'Discussions
reloaded, still no sections' );
// check whether there is an Add discussion button
- assert.strictEqual( overlay.$( 'button.add' ).length, 0, 'There is no
"Add discussion" button' );
+ assert.strictEqual( overlay.$( '.add' ).length, 0, 'There is no "Add
discussion" button' );
} );
QUnit.test( '#TalkOverlay (logged in)', 2, function( assert ) {
mw.config.set( 'wgUserName', 'FlorianSW' );
var overlay = new TalkOverlay( { title: 'Talk:No exist' } );
- assert.ok( overlay.$( 'button.add' ).length > 0, 'There is an "Add
discussion" button' );
+ assert.ok( overlay.$( '.add' ).length > 0, 'There is an "Add
discussion" button' );
assert.strictEqual( $.trim( overlay.$( '.content-header' ).text() ),
mw.msg( 'mobile-frontend-talk-explained-empty' ),
'Check the header knows it is empty.' );
--
To view, visit https://gerrit.wikimedia.org/r/171959
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0ba931bfd20bb083c8f226f8f39ad711f6d88a2e
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Awjrichards <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits