mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-15 10:59:42 +00:00
Merge "Simplify ext.thanks.mobilediff.js"
This commit is contained in:
commit
e614e62948
|
@ -37,43 +37,41 @@
|
||||||
* @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' ) ) {
|
||||||
// See if user has already been thanked for this edit
|
return null;
|
||||||
if ( mw.config.get( 'wgThanksAlreadySent' ) ) {
|
|
||||||
$thankBtn = $( '<button>' )
|
|
||||||
.addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive thanked' )
|
|
||||||
.prop( 'disabled', true )
|
|
||||||
.text( mw.message( 'thanks-button-thanked', mw.user ).text() )
|
|
||||||
.prepend( $thankImg );
|
|
||||||
} else {
|
|
||||||
$thankBtn = $( '<button>' )
|
|
||||||
.addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive' )
|
|
||||||
.text( mw.message( 'thanks-button-thank', mw.user, gender ).text() )
|
|
||||||
.prepend( $thankImg )
|
|
||||||
.on( 'click', function () {
|
|
||||||
var $this = $( this );
|
|
||||||
if ( !$this.hasClass( 'thanked' ) ) {
|
|
||||||
thankUser( name, rev, gender ).done( function () {
|
|
||||||
$this.addClass( 'thanked' ).prop( 'disabled', true )
|
|
||||||
.text( mw.message( 'thanks-button-thanked', mw.user, gender ).text() )
|
|
||||||
.prepend( $thankImg );
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
} );
|
|
||||||
}
|
|
||||||
return $thankBtn;
|
|
||||||
}
|
}
|
||||||
|
// See if user has already been thanked for this edit
|
||||||
|
if ( mw.config.get( 'wgThanksAlreadySent' ) ) {
|
||||||
|
return $( '<button>' )
|
||||||
|
.addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive thanked' )
|
||||||
|
.prop( 'disabled', true )
|
||||||
|
.text( mw.message( 'thanks-button-thanked', mw.user ).text() )
|
||||||
|
.prepend( $thankImg );
|
||||||
|
}
|
||||||
|
return $( '<button>' )
|
||||||
|
.addClass( 'mw-mf-action-button mw-ui-button mw-ui-progressive' )
|
||||||
|
.text( mw.message( 'thanks-button-thank', mw.user, gender ).text() )
|
||||||
|
.prepend( $thankImg )
|
||||||
|
.on( 'click', function () {
|
||||||
|
var $this = $( this );
|
||||||
|
if ( !$this.hasClass( 'thanked' ) ) {
|
||||||
|
thankUser( name, rev, gender ).done( function () {
|
||||||
|
$this.addClass( 'thanked' ).prop( 'disabled', true )
|
||||||
|
.text( mw.message( 'thanks-button-thanked', mw.user, gender ).text() )
|
||||||
|
.prepend( $thankImg );
|
||||||
|
} );
|
||||||
|
}
|
||||||
|
} );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue