mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TitleBlacklist
synced 2024-12-04 02:18:42 +00:00
c5f2f1c30b
Bug: T307330 Depends-On: I9680cc416da5b27881aeb3502f506dcb5d4bb71f Change-Id: Iba36a5549b2d987e00665c4fe62db5c4727bcf24
26 lines
986 B
JavaScript
26 lines
986 B
JavaScript
mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|
mw.libs.ve.targetLoader.addPlugin( function () {
|
|
|
|
ve.init.mw.TitleBlacklistSaveErrorHandler = function () {};
|
|
|
|
OO.inheritClass( ve.init.mw.TitleBlacklistSaveErrorHandler, ve.init.mw.SaveErrorHandler );
|
|
|
|
ve.init.mw.TitleBlacklistSaveErrorHandler.static.name = 'titleBlacklist';
|
|
|
|
ve.init.mw.TitleBlacklistSaveErrorHandler.static.matchFunction = function ( data ) {
|
|
return data.errors && data.errors.some( function ( err ) {
|
|
return err.code === 'titleblacklist-forbidden';
|
|
} );
|
|
};
|
|
|
|
ve.init.mw.TitleBlacklistSaveErrorHandler.static.process = function ( data, target ) {
|
|
// Handle errors from Extension:TitleBlacklist
|
|
target.showSaveError( target.extractErrorMessages( data ) );
|
|
// Emit event for tracking. TODO: This is a bad design
|
|
target.emit( 'saveErrorTitleBlacklist' );
|
|
};
|
|
|
|
ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.TitleBlacklistSaveErrorHandler );
|
|
} );
|
|
} );
|