mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-12-18 02:41:01 +00:00
8837bd469a
This makes the icon and text a single item, so they don't split across lines, and reduces code and messages. Bug: 47398 Change-Id: If81313b9fe03693dcdc06d5d682f0ef9a9994f76
38 lines
1 KiB
JavaScript
38 lines
1 KiB
JavaScript
( function ( $, mw ) {
|
|
var api = new mw.Api();
|
|
$( document ).on( 'click', '.fancycaptcha-reload', function () {
|
|
var $this = $( this ), $captchaImage;
|
|
|
|
$this.addClass( 'fancycaptcha-reload-loading' );
|
|
|
|
$captchaImage = $( '.fancycaptcha-image' );
|
|
|
|
// AJAX request to get captcha index key
|
|
api.post( {
|
|
action: 'fancycaptchareload',
|
|
format: 'xml'
|
|
}, {
|
|
dataType: 'xml'
|
|
} )
|
|
.done( function ( xmldata ) {
|
|
var imgSrc, captchaIndex;
|
|
captchaIndex = $( xmldata ).find( 'fancycaptchareload' ).attr( 'index' );
|
|
if ( typeof captchaIndex === 'string' ) {
|
|
// replace index key with a new one for captcha image
|
|
imgSrc = $captchaImage.attr( 'src' )
|
|
.replace( /(wpCaptchaId=)\w+/, '$1' + captchaIndex );
|
|
$captchaImage.attr( 'src', imgSrc );
|
|
|
|
// replace index key with a new one for hidden tag
|
|
$( '#wpCaptchaId' ).val( captchaIndex );
|
|
$( '#wpCaptchaWord' ).val( '' ).focus();
|
|
}
|
|
} )
|
|
.always( function () {
|
|
$this.removeClass( 'fancycaptcha-reload-loading' );
|
|
} );
|
|
|
|
return false;
|
|
} );
|
|
} )( jQuery, mediaWiki );
|