Merge "Simplify ext.thanks.mobilediff.js"

This commit is contained in:
jenkins-bot 2018-02-12 17:19:40 +00:00 committed by Gerrit Code Review
commit e614e62948

View file

@ -37,27 +37,28 @@
* @param {string} name The username of the user who made the edit * @param {string} name The username of the user who made the edit
* @param {string} rev The revision the user created * @param {string} rev The revision the user created
* @param {string} gender The gender of the user who made the edit * @param {string} gender The gender of the user who made the edit
* @return {html} The HTML of the button. * @return {jQuery|null} The HTML of the button.
*/ */
function createThankLink( name, rev, gender ) { function createThankLink( name, rev, gender ) {
var $thankBtn, var $thankImg = $( '<img>' ).attr( {
$thankImg = $( '<img>' ).attr( {
width: 25, width: 25,
height: 20, height: 20,
src: mw.config.get( 'wgExtensionAssetsPath' ) + '/Thanks/WhiteSmiley.png' src: mw.config.get( 'wgExtensionAssetsPath' ) + '/Thanks/WhiteSmiley.png'
} ).addClass( 'mw-mf-action-button-icon' ); } ).addClass( 'mw-mf-action-button-icon' );
// Don't make thank button for self // Don't make thank button for self
if ( name !== mw.config.get( 'wgUserName' ) ) { if ( name === mw.config.get( 'wgUserName' ) ) {
return null;
}
// See if user has already been thanked for this edit // See if user has already been thanked for this edit
if ( mw.config.get( 'wgThanksAlreadySent' ) ) { if ( mw.config.get( 'wgThanksAlreadySent' ) ) {
$thankBtn = $( '<button>' ) return $( '<button>' )
.addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive thanked' ) .addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive thanked' )
.prop( 'disabled', true ) .prop( 'disabled', true )
.text( mw.message( 'thanks-button-thanked', mw.user ).text() ) .text( mw.message( 'thanks-button-thanked', mw.user ).text() )
.prepend( $thankImg ); .prepend( $thankImg );
} else { }
$thankBtn = $( '<button>' ) return $( '<button>' )
.addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive' ) .addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive' )
.text( mw.message( 'thanks-button-thank', mw.user, gender ).text() ) .text( mw.message( 'thanks-button-thank', mw.user, gender ).text() )
.prepend( $thankImg ) .prepend( $thankImg )
@ -72,9 +73,6 @@
} }
} ); } );
} }
return $thankBtn;
}
}
/** /**
* Initialise a thank button in the given container. * Initialise a thank button in the given container.