mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Thanks
synced 2024-11-15 02:54:23 +00:00
Use jquery.confirmable instead of jquery.ui.dialog
Change-Id: Id75fd57954edb9341d25ba754dd64279a28deb54
This commit is contained in:
parent
e3f6fd6aad
commit
c1e4c568cc
|
@ -92,7 +92,7 @@ $wgResourceModules['ext.thanks.revthank'] = array(
|
|||
'thanks-error-undefined',
|
||||
'thanks-error-invalidrevision',
|
||||
'thanks-error-ratelimited',
|
||||
'thanks-confirmation',
|
||||
'thanks-confirmation2',
|
||||
'ok',
|
||||
'cancel',
|
||||
),
|
||||
|
@ -100,7 +100,7 @@ $wgResourceModules['ext.thanks.revthank'] = array(
|
|||
'mediawiki.jqueryMsg',
|
||||
'mediawiki.api',
|
||||
'user.tokens',
|
||||
'jquery.ui.dialog',
|
||||
'jquery.confirmable',
|
||||
'ext.thanks',
|
||||
),
|
||||
'localBasePath' => $dir . '/modules',
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
"thanks-error-invalidrevision": "Revision ID is not valid.",
|
||||
"thanks-error-ratelimited": "{{GENDER:$1|You}}'ve exceeded your rate limit. Please wait some time and try again.",
|
||||
"thanks-thank-tooltip": "{{GENDER:$1|Send}} a thank you notification to this {{GENDER:$2|user}}",
|
||||
"thanks-confirmation": "Do you want to {{GENDER:$1|thank}} $2 for this edit?",
|
||||
"thanks-confirmation2": "{{GENDER:$1|Send}} thanks for this edit?",
|
||||
"thanks-thanked-notice": "$1 was notified that you liked {{GENDER:$2|his|her|their}} edit.",
|
||||
"thanks": "Send thanks",
|
||||
"thanks-form-revid": "Revision ID for edit",
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
"thanks-error-undefined": "Error message that is displayed when the thank action fails.\n{{Identical|Please try again}}",
|
||||
"thanks-error-invalidrevision": "Error message that is displayed when the revision ID is not valid",
|
||||
"thanks-error-ratelimited": "Error message that is displayed when user exceeds rate limit. Parameters:\n* $1 - gender",
|
||||
"thanks-thank-tooltip": "Tooltip that appears when a user hovers over the \"thank\" link. Parameters\n* $1 - The user sending the thanks. Can be used for GENDER support.\n* $2 - The user receiving the thanks. Can be used for GENDER support",
|
||||
"thanks-confirmation": "A confirmation message to make sure the user actually wants to send thanks to another user.\n\nParameters:\n* $1 - the user sending the thanks. Can be used for GENDER.\n* $2 - the username of the recipient. Can NOT be used for GENDER.",
|
||||
"thanks-thank-tooltip": "Tooltip that appears when a user hovers over the \"thank\" link. Parameters:\n* $1 - The user sending the thanks. Can be used for GENDER support.\n* $2 - The user receiving the thanks. Can be used for GENDER support",
|
||||
"thanks-confirmation2": "A confirmation message to make sure the user actually wants to send thanks to another user. Parameters:\n* $1 - The user sending the thanks. Can be used for GENDER.",
|
||||
"thanks-thanked-notice": "{{doc-singularthey}}\nPop-up message that is displayed after a user has thanked another user for their edit.\n\nParameters:\n* $1 - the username of the user that was thanked\n* $2 - the gender of the user that was thanked\nSee also:\n* {{msg-mw|Flow-thanks-thanked-notice}}",
|
||||
"thanks": "{{doc-special|Thanks|unlisted=1}}\nThe special page contains the form to thank for the edit.",
|
||||
"thanks-form-revid": "Label for form field where the user inputs the revision ID.",
|
||||
|
|
|
@ -11,36 +11,9 @@
|
|||
} );
|
||||
};
|
||||
|
||||
var confirmThanks = function( $thankLink ) {
|
||||
var recipient = $thankLink.parent().find( '.mw-userlink' ).text();
|
||||
if ( recipient === '' ) { // for Diff view
|
||||
recipient = $thankLink.parents( '.diff-ntitle' ).find( '.mw-userlink' ).text();
|
||||
}
|
||||
var $dialog = $( '<div>' ).msg( 'thanks-confirmation', mw.user, recipient );
|
||||
$dialog.dialog( {
|
||||
autoOpen: false,
|
||||
width: 400,
|
||||
modal: true,
|
||||
resizable: false,
|
||||
buttons: [
|
||||
{
|
||||
text: mw.msg( 'ok' ),
|
||||
'class': 'ui-button-green',
|
||||
click: function() {
|
||||
$( this ).dialog( "close" );
|
||||
sendThanks( $thankLink );
|
||||
}
|
||||
},
|
||||
{
|
||||
text: mw.msg( 'cancel' ),
|
||||
click: function() { $( this ).dialog( "close" ); }
|
||||
}
|
||||
]
|
||||
} );
|
||||
$dialog.dialog( 'open' );
|
||||
};
|
||||
|
||||
var sendThanks = function( $thankLink ) {
|
||||
// $thankLink is the element with the data-revision-id attribute
|
||||
// $thankElement is the element to be removed on success
|
||||
var sendThanks = function( $thankLink, $thankElement ) {
|
||||
var source;
|
||||
if ( mw.config.get( 'wgAction' ) === 'history' ) {
|
||||
source = 'history';
|
||||
|
@ -54,8 +27,8 @@
|
|||
'token' : mw.user.tokens.values.editToken
|
||||
} )
|
||||
.done( function( data ) {
|
||||
$thankLink.before( mw.message( 'thanks-thanked', mw.user ).escaped() );
|
||||
$thankLink.remove();
|
||||
$thankElement.before( mw.message( 'thanks-thanked', mw.user ).escaped() );
|
||||
$thankElement.remove();
|
||||
mw.thanks.thanked.push( $thankLink );
|
||||
} )
|
||||
.fail( function( errorCode, details ) {
|
||||
|
@ -81,13 +54,22 @@
|
|||
$( document ).ready( reloadThankedState );
|
||||
}
|
||||
|
||||
$( 'a.mw-thanks-thank-link' ).click( function( e ) {
|
||||
var $thankLink = $( this );
|
||||
e.preventDefault();
|
||||
$( function() {
|
||||
if ( mw.config.get( 'thanks-confirmation-required' ) ) {
|
||||
confirmThanks( $thankLink );
|
||||
$( 'a.mw-thanks-thank-link' ).confirmable( {
|
||||
i18n: { confirm: mw.msg( 'thanks-confirmation2', mw.user ) },
|
||||
handler: function ( e ) {
|
||||
var $thankLink = $( this );
|
||||
e.preventDefault();
|
||||
sendThanks( $thankLink, $thankLink.closest( '.jquery-confirmable-wrapper' ) );
|
||||
}
|
||||
} );
|
||||
} else {
|
||||
sendThanks( $thankLink );
|
||||
$( 'a.mw-thanks-thank-link' ).click( function ( e ) {
|
||||
var $thankLink = $( this );
|
||||
e.preventDefault();
|
||||
sendThanks( $thankLink, $thankLink );
|
||||
} );
|
||||
}
|
||||
} );
|
||||
|
||||
|
|
Loading…
Reference in a new issue