Merge "Support QuestyCaptcha and (kind of) MathCaptcha"

This commit is contained in:
jenkins-bot 2014-04-30 21:34:04 +00:00 committed by Gerrit Code Review
commit 48d025aead
3 changed files with 20 additions and 4 deletions

View file

@ -704,10 +704,12 @@ $wgResourceModules += array(
'hidetoc',
'captcha-edit',
// Only used if FancyCaptcha is installed and triggered on save
'captcha-label',
'fancycaptcha-edit',
'colon-separator',
// Only used if FancyCaptcha is installed and triggered on save
'fancycaptcha-edit',
// Only used if QuestyCaptcha is installed and triggered on save
'questycaptcha-edit'
),
'targets' => array( 'desktop', 'mobile' ),
),

View file

@ -556,13 +556,22 @@ ve.init.mw.ViewPageTarget.prototype.onSaveErrorCaptcha = function ( editApi ) {
$captchaDiv.append(
$( '<img>' ).attr( 'src', editApi.captcha.url )
);
} else if ( editApi.captcha.type === 'simple' ) { // SimpleCaptcha
} else if ( editApi.captcha.type === 'simple' || editApi.captcha.type === 'math' ) {
// SimpleCaptcha and MathCaptcha
$captchaParagraph.append(
mw.message( 'captcha-edit' ).parse(),
'<br>',
document.createTextNode( editApi.captcha.question )
);
} else if ( editApi.captcha.type === 'question' ) {
// QuestyCaptcha
$captchaParagraph.append(
mw.message( 'questycaptcha-edit' ).parse(),
'<br>',
editApi.captcha.question
);
}
$captchaDiv.append( this.captcha.input.$element );
this.showSaveError( $captchaDiv, false );
this.events.trackSaveError( 'captcha' );

View file

@ -662,7 +662,12 @@ ve.init.mw.Target.prototype.onSaveError = function ( doc, saveData, jqXHR, statu
// "question" or "fancy" type of captcha. They all expose differently named properties in the
// API for different things in the UI. At this point we only support the SimpleCaptcha and FancyCaptcha
// which we very intuitively detect by the presence of a "url" property.
if ( editApi && editApi.captcha && ( editApi.captcha.url || editApi.captcha.type === 'simple' ) ) {
if ( editApi && editApi.captcha && (
editApi.captcha.url ||
editApi.captcha.type === 'simple' ||
editApi.captcha.type === 'math' ||
editApi.captcha.type === 'question'
) ) {
this.emit( 'saveErrorCaptcha', editApi );
return;
}