mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-15 19:09:52 +00:00
Merge "Story 1604: Remember mobile thanks"
This commit is contained in:
commit
f635813b98
|
@ -194,9 +194,10 @@ class ThanksHooks {
|
|||
* Add thanks button to SpecialMobileDiff page
|
||||
* @param &$output OutputPage object
|
||||
* @param $ctx MobileContext object
|
||||
* @param $revisions Array of the two revisions that are being compared in the diff
|
||||
* @return bool true in all cases
|
||||
*/
|
||||
public static function onBeforeSpecialMobileDiffDisplay( &$output, $ctx ) {
|
||||
public static function onBeforeSpecialMobileDiffDisplay( &$output, $ctx, $revisions ) {
|
||||
// If the Echo and MobileFrontend extensions are installed and the user is
|
||||
// logged in, show a 'Thank' link.
|
||||
if ( class_exists( 'EchoNotifier' )
|
||||
|
@ -204,6 +205,13 @@ class ThanksHooks {
|
|||
&& $output->getUser()->isLoggedIn()
|
||||
) {
|
||||
$output->addModules( array( 'ext.thanks.mobilediff' ) );
|
||||
$rev = $revisions[1];
|
||||
if ( $rev ) {
|
||||
if ( $output->getRequest()->getSessionData( 'thanks-thanked-' . $rev->getId() ) ) {
|
||||
// User already sent thanks for this revision
|
||||
$output->addJsConfigVars( 'wgThanksAlreadySent', true );
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -41,25 +41,32 @@
|
|||
* @param gender String The gender of the user who made the edit
|
||||
*/
|
||||
function createThankLink( name, rev, gender ) {
|
||||
var thankImg = mw.config.get( 'wgExtensionAssetsPath' ) + '/Thanks/WhiteSmiley.png';
|
||||
var thankImg = mw.config.get( 'wgExtensionAssetsPath' ) + '/Thanks/WhiteSmiley.png',
|
||||
thankImgTag = '<img width="25" height="20" src="' + thankImg + '" class="mw-mf-action-button-icon"/>',
|
||||
$thankBtn;
|
||||
// Don't make thank button for self
|
||||
if ( name !== mw.config.get( 'wgUserName' ) ) {
|
||||
return $( '<button class="mw-mf-action-button">' )
|
||||
.html( '<img width="25" height="20" src="' + thankImg + '" class="mw-mf-action-button-icon"/>' +
|
||||
mw.message( 'thanks-button-thank', mw.user ).escaped()
|
||||
)
|
||||
.on( 'click', function() {
|
||||
var $thankLink = $( this );
|
||||
schema.log( 'diff-thank', name );
|
||||
if ( !$thankLink.hasClass( 'thanked' ) ) {
|
||||
thankUser( name, rev, gender ).done( function() {
|
||||
$thankLink.addClass( 'thanked' ).attr( 'disabled', true );
|
||||
$thankLink.html( '<img width="25" height="20" src="' + thankImg + '" class="mw-mf-action-button-icon"/>' +
|
||||
mw.message( 'thanks-button-thanked', mw.user ).escaped()
|
||||
);
|
||||
} );
|
||||
}
|
||||
} );
|
||||
// See if user has already been thanked for this edit
|
||||
if ( mw.config.get( 'wgThanksAlreadySent' ) ) {
|
||||
$thankBtn = $( '<button class="mw-mf-action-button thanked">' )
|
||||
.attr( 'disabled', true )
|
||||
.html( thankImgTag + mw.message( 'thanks-button-thanked', mw.user ).escaped() );
|
||||
} else {
|
||||
$thankBtn = $( '<button class="mw-mf-action-button">' )
|
||||
.html( thankImgTag + mw.message( 'thanks-button-thank', mw.user ).escaped()
|
||||
)
|
||||
.on( 'click', function() {
|
||||
var $this = $( this );
|
||||
schema.log( 'diff-thank', name );
|
||||
if ( !$this.hasClass( 'thanked' ) ) {
|
||||
thankUser( name, rev, gender ).done( function() {
|
||||
$this.addClass( 'thanked' ).attr( 'disabled', true )
|
||||
.html( thankImgTag + mw.message( 'thanks-button-thanked', mw.user ).escaped() );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
}
|
||||
return $thankBtn;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue