( function ( mw, M, $ ) {
var popup = M.require( 'toast' ),
SchemaMobileWebClickTracking = M.require( 'loggingSchemas/SchemaMobileWebClickTracking' ),
schema = new SchemaMobileWebClickTracking( {}, 'MobileWebDiffClickTracking' );
/**
* Create a thank button for a given edit
*
* @param {String} name The username of the user who made the edit
* @param {String} revision The revision the user created
* @param {String} gender The gender of the user who made the edit
*/
function thankUser( name, revision, gender ) {
var d = $.Deferred();
( new mw.Api() ).postWithToken( 'edit', {
action: 'thank',
rev: revision,
source: 'mobilediff'
} ).done( function () {
popup.show( mw.msg( 'thanks-thanked-notice', name, gender ) );
d.resolve();
} )
.fail( function ( errorCode ) {
switch ( errorCode ) {
case 'invalidrevision':
popup.show( mw.msg( 'thanks-error-invalidrevision' ) );
break;
case 'ratelimited':
popup.show( mw.msg( 'thanks-error-ratelimited', gender ) );
break;
default:
popup.show( mw.msg( 'thanks-error-undefined' ) );
}
d.reject();
} );
return d;
}
/**
* Create a thank button for a given edit
*
* @param {String} name The username of the user who made the edit
* @param {String} rev The revision the user created
* @param {String} gender The gender of the user who made the edit
*/
function createThankLink( name, rev, gender ) {
var thankImg = mw.config.get( 'wgExtensionAssetsPath' ) + '/Thanks/WhiteSmiley.png',
thankImgTag = '',
$thankBtn;
// Don't make thank button for self
if ( name !== mw.config.get( 'wgUserName' ) ) {
// See if user has already been thanked for this edit
if ( mw.config.get( 'wgThanksAlreadySent' ) ) {
$thankBtn = $( '