mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-11 17:00:49 +00:00
VE: Convert to SaveErrorHandler
Change-Id: I18386a72146e1179c8656e3c9c01a256ec2096d6 Depends-On: I036ee32847cc3b25a1cc478247cfe54599781098
This commit is contained in:
parent
15eba91749
commit
057db3d77a
|
@ -72,7 +72,7 @@
|
|||
"styles": "ext.confirmEdit.editPreview.ipwhitelist.styles.css"
|
||||
},
|
||||
"ext.confirmEdit.visualEditor": {
|
||||
"scripts": "ve-confirmedit/ve.init.ConfirmEdit.init.js"
|
||||
"scripts": "ve-confirmedit/ve.init.mw.CaptchaSaveErrorHandler.js"
|
||||
}
|
||||
},
|
||||
"VisualEditorPluginModules": [
|
||||
|
|
|
@ -6,21 +6,28 @@
|
|||
// 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.
|
||||
mw.libs.ve.targetLoader.addPlugin( function () {
|
||||
ve.init.mw.saveErrorHandlerRegistry.register( 'confirmEditCaptchas', function ( editApi, target ) {
|
||||
var $captchaImg, msg, question,
|
||||
captchaInput, $captchaDiv, $captchaParagraph,
|
||||
captchaData = editApi.captcha;
|
||||
|
||||
if ( !(
|
||||
captchaData && (
|
||||
ve.init.mw.CaptchaSaveErrorHandler = function () {};
|
||||
|
||||
OO.inheritClass( ve.init.mw.CaptchaSaveErrorHandler, ve.init.mw.SaveErrorHandler );
|
||||
|
||||
ve.init.mw.CaptchaSaveErrorHandler.static.name = 'confirmEditCaptchas';
|
||||
|
||||
ve.init.mw.CaptchaSaveErrorHandler.static.matchFunction = function ( editApi ) {
|
||||
var captchaData = editApi.captcha;
|
||||
|
||||
return !!( captchaData && (
|
||||
captchaData.url ||
|
||||
captchaData.type === 'simple' ||
|
||||
captchaData.type === 'math' ||
|
||||
captchaData.type === 'question'
|
||||
)
|
||||
) ) {
|
||||
return false;
|
||||
}
|
||||
) );
|
||||
};
|
||||
|
||||
ve.init.mw.CaptchaSaveErrorHandler.static.process = function ( editApi, target ) {
|
||||
var $captchaImg, msg, question,
|
||||
captchaInput, $captchaDiv, $captchaParagraph,
|
||||
captchaData = editApi.captcha;
|
||||
|
||||
captchaInput = new OO.ui.TextInputWidget( { classes: [ 've-ui-saveDialog-captchaInput' ] } );
|
||||
|
||||
|
@ -106,7 +113,8 @@ mw.libs.ve.targetLoader.addPlugin( function () {
|
|||
|
||||
// Emit event for tracking. TODO: This is a bad design
|
||||
target.emit( 'saveErrorCaptcha' );
|
||||
};
|
||||
|
||||
ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.CaptchaSaveErrorHandler );
|
||||
|
||||
return true;
|
||||
} );
|
||||
} );
|
Loading…
Reference in a new issue