jenkins-bot has submitted this change and it was merged.
Change subject: Make WikiGrok A and B use same code for Thanks step
......................................................................
Make WikiGrok A and B use same code for Thanks step
Moving Thanks to its own template so that it can be easily shared. This
also makes the other templates cleaner and easier to read and reduces
the total amount of code by 20 lines or so.
Bug: T86613
Change-Id: I9cf089a7c14b5db4adb02b6639c4973ca1091920
---
M includes/Resources.php
M javascripts/modules/wikigrok/WikiGrokDialog.js
M javascripts/modules/wikigrok/WikiGrokDialogB.js
M javascripts/modules/wikigrok/WikiGrokDialogC.js
M templates/modules/wikigrok/WikiGrokDialog.hogan
M templates/modules/wikigrok/WikiGrokDialogB.hogan
A templates/modules/wikigrok/WikiGrokThanks.hogan
7 files changed, 35 insertions(+), 55 deletions(-)
Approvals:
Phuedx: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/Resources.php b/includes/Resources.php
index ab116e0..c7be4f9 100644
--- a/includes/Resources.php
+++ b/includes/Resources.php
@@ -1087,6 +1087,7 @@
'Error.hogan' =>
'templates/modules/wikigrok/WikiGrokError.hogan',
'Dialog.hogan' =>
'templates/modules/wikigrok/WikiGrokDialog.hogan',
'WikiGrokMoreInfo/content.hogan' =>
'templates/modules/wikigrok/WikiGrokMoreInfo.hogan',
+ 'Thanks.hogan' =>
'templates/modules/wikigrok/WikiGrokThanks.hogan',
),
'scripts' => array(
'javascripts/modules/wikigrok/WikiGrokDialog.js',
diff --git a/javascripts/modules/wikigrok/WikiGrokDialog.js
b/javascripts/modules/wikigrok/WikiGrokDialog.js
index b42f88d..1bbb387 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialog.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialog.js
@@ -26,7 +26,6 @@
* @cfg {Object} defaults Default options hash.
* @cfg {Boolean} defaults.beginQuestions Whether to show
questions.
* @cfg {String} defaults.taskToken Task token used in schemas.
- * @cfg {Boolean} defaults.thankUser Whether to show the thanks
message.
* @cfg {String} defaults.closeMsg Text for the button in an
overlay that, when clicked,
* dismisses the overlay.
* @cfg {String} defaults.contentMsg Message that tells what to
do, it's the message
@@ -39,9 +38,9 @@
defaults: {
beginQuestions: false,
taskToken: mw.user.generateRandomSessionId(),
- thankUser: false,
closeMsg: mw.msg( 'mobile-frontend-overlay-close' ),
contentMsg: 'Improve Wikipedia by tagging information
on this page',
+ tellMoreMsg: 'Tell me more',
// Other ideas:
// Can you help improve Wikipedia?
// Play a game to help Wikipedia!
@@ -57,6 +56,8 @@
}
],
spinner: icons.spinner().toHtmlString(),
+ // FIXME: Split first 2 steps into separate templates
so that we don't have to
+ // include HTML in the notice messages.
noticeMsg: '<a class="wg-notice-link"
href="#/wikigrok/about">Tell me more</a>',
isDrawer: false
},
@@ -255,7 +256,7 @@
};
this.apiWikiGrokResponse.recordClaims( [ claim ]
).done( function () {
- self.thankUser( options, true );
+ self.postRecordClaims( options, true );
} ).fail( function () {
self.handleError(
'no-response-cannot-record-user-input' );
} );
@@ -276,23 +277,33 @@
},
/**
- * Show a thank you message to the user for their contribution.
+ * Show a thank you message to the user for their contribution.
Also log event.
* @method
* @param {Object} options
- * @param {Boolean} claimAttempted has the user attempted to
answer or
+ * @param {Boolean} answerAttempted has the user attempted to
answer or
* just responded with 'not sure'?
*/
- thankUser: function ( options, claimAttempted ) {
+ postRecordClaims: function ( options, answerAttempted ) {
+ var self = this;
+
+ // Remember that the user completed WikiGrok for this
page so that we don't
+ // show it again later.
this.rememberWikiGrokContribution();
- options.thankUser = true;
- if ( claimAttempted ) {
+ // Choose an appropriate thanks message.
+ if ( answerAttempted ) {
options.contentMsg = 'You just made Wikipedia a
little better, thanks!';
} else {
options.contentMsg = 'That\'s OK, thanks for
taking the time.';
}
- // Re-render with new content for 'Thanks' step
+ // Re-render with new content for 'Thanks' step.
+ this.template = mw.template.get(
'mobile.wikigrok.dialog', 'Thanks.hogan' );
this.render( options );
- this.$( '.wg-notice' ).hide();
+ // Hide thanks dialog when the user reads more about
WikiGrok.
+ this.$( '.wg-link .tell-more' ).on( 'click', function
() {
+ self.hide();
+ self.log( 'widget-click-moreinfo' );
+ } );
+ // Log the successful completion of WikiGrok task
this.log( 'widget-impression-success' );
},
@@ -383,21 +394,11 @@
postRender: function ( options ) {
var self = this;
- self.$( '.wg-link' ).hide();
-
// If you're wondering where the DOM insertion happens,
look in wikigrokeval.js.
// Initialize all the buttons and links
- // ...for final 'Thanks' step
- if ( options.thankUser ) {
- self.$( '.wg-buttons' ).hide();
- self.$( '.wg-link' ).show();
- this.$( '.wg-link .tell-more' ).on( 'click',
function () {
- self.hide();
- self.log( 'widget-click-moreinfo' );
- } );
// ...for intermediate 'Question' step
- } else if ( options.beginQuestions ) {
+ if ( options.beginQuestions ) {
this.$( '.wg-buttons .yes' ).on( 'click',
function () {
self.log( 'widget-click-submit' );
options.claimIsCorrect = true;
@@ -405,7 +406,7 @@
} );
this.$( '.wg-buttons .not-sure' ).on( 'click',
function () {
self.log( 'widget-click-submit' );
- self.thankUser( options, false );
+ self.postRecordClaims( options, false );
} );
this.$( '.wg-buttons .no' ).on( 'click',
function () {
self.log( 'widget-click-submit' );
diff --git a/javascripts/modules/wikigrok/WikiGrokDialogB.js
b/javascripts/modules/wikigrok/WikiGrokDialogB.js
index 333d3f9..b8ad899 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialogB.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialogB.js
@@ -14,9 +14,7 @@
WikiGrokDialogB = WikiGrokDialog.extend( {
version: 'b',
template: mw.template.get( 'mobile.wikigrok.dialog.b',
'Dialog.hogan' ),
- defaults: $.extend( WikiGrokDialog.prototype.defaults, {
- thanksMsg: 'You just made Wikipedia a little better,
thanks!'
- } ),
+
/** @inheritdoc */
initialize: function () {
var self = this;
@@ -105,18 +103,6 @@
}
},
/**
- * Thank the user for their contribution. Also log this event.
- * @method
- */
- postRecordClaims: function () {
- var self = this;
-
- self.$( '.wg-content, .tags, .footer, .spinner'
).hide();
- self.$( '.wg-thanks-content' ).removeClass( 'hidden' );
- self.$( '.wg-link' ).show();
- self.log( 'widget-impression-success' );
- },
- /**
* Show suggestions to the user.
* Also record claims when the user hits the save button.
* FIXME: Please refactor
@@ -151,19 +137,12 @@
self.$( '.tags' ).hide();
self.$( '.spinner' ).show();
- self.apiWikiGrokResponse.recordClaims( answers
).always( function () {
- self.postRecordClaims();
+ self.apiWikiGrokResponse.recordClaims( answers
).done( function () {
+ self.postRecordClaims( options, true );
} ).fail( function () {
self.handleError(
'no-response-cannot-record-user-input' );
} );
self.log( 'widget-click-submit' );
- self.rememberWikiGrokContribution();
- } );
-
- // hide this Dialog when the user reads more about
Wikigrok
- this.$( '.tell-more' ).on( 'click', function () {
- self.hide();
- self.log( 'widget-click-moreinfo' );
} );
},
/**
@@ -172,7 +151,7 @@
postRender: function ( options ) {
var self = this;
- self.$( '.tags, .wg-link, .footer, .spinner' ).hide();
+ self.$( '.tags, .footer, .spinner' ).hide();
// show the welcome screen once
if ( !options.beginQuestions ) {
diff --git a/javascripts/modules/wikigrok/WikiGrokDialogC.js
b/javascripts/modules/wikigrok/WikiGrokDialogC.js
index 55eb5c5..c53b2c9 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialogC.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialogC.js
@@ -31,7 +31,7 @@
responseText,
responseCount;
- self.$( '.wg-content, .wg-thanks-content, .wg-link,
.footer' ).hide();
+ self.$( '.wg-content, .footer' ).hide();
self.$( '.spinner' ).show();
// Count responses if local storage supported
diff --git a/templates/modules/wikigrok/WikiGrokDialog.hogan
b/templates/modules/wikigrok/WikiGrokDialog.hogan
index 4697eaf..4780720 100644
--- a/templates/modules/wikigrok/WikiGrokDialog.hogan
+++ b/templates/modules/wikigrok/WikiGrokDialog.hogan
@@ -1,8 +1,5 @@
<div class="pane content">
<p class="wg-content">{{contentMsg}}</p>
- <p class="wg-link">
- <a href="#/wikigrok/about" class="mw-ui-button
mw-ui-progressive mw-ui-block tell-more">Tell me more</a>
- </p>
<p class="wg-buttons">
{{#buttons}}
<button class="{{classes}}">{{label}}</button>
diff --git a/templates/modules/wikigrok/WikiGrokDialogB.hogan
b/templates/modules/wikigrok/WikiGrokDialogB.hogan
index f6dd156..ab4b044 100644
--- a/templates/modules/wikigrok/WikiGrokDialogB.hogan
+++ b/templates/modules/wikigrok/WikiGrokDialogB.hogan
@@ -1,10 +1,6 @@
<!-- note English language only! -->
<div class="pane content">
<p class="wg-content">{{contentMsg}}</p>
- <p class="wg-thanks-content hidden">{{thanksMsg}}</p>
- <p class="wg-link">
- <a href="#/wikigrok/about" class="mw-ui-button
mw-ui-progressive mw-ui-block tell-more">Tell me more</a>
- </p>
<p class="wg-buttons">
{{#buttons}}
<button class="{{classes}}">{{label}}</button>
diff --git a/templates/modules/wikigrok/WikiGrokThanks.hogan
b/templates/modules/wikigrok/WikiGrokThanks.hogan
new file mode 100644
index 0000000..8ba573f
--- /dev/null
+++ b/templates/modules/wikigrok/WikiGrokThanks.hogan
@@ -0,0 +1,6 @@
+<div class="pane content">
+ <p class="wg-content">{{contentMsg}}</p>
+ <p class="wg-link">
+ <a href="#/wikigrok/about" class="mw-ui-button
mw-ui-progressive mw-ui-block tell-more">{{tellMoreMsg}}</a>
+ </p>
+</div>
--
To view, visit https://gerrit.wikimedia.org/r/184542
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9cf089a7c14b5db4adb02b6639c4973ca1091920
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Kaldari <[email protected]>
Gerrit-Reviewer: Bmansurov <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Jhernandez <[email protected]>
Gerrit-Reviewer: Phuedx <[email protected]>
Gerrit-Reviewer: Robmoen <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits