mediawiki-extensions-SpamBl.../modules/ve-spamblacklist/ve.init.mw.SpamBlacklistSaveErrorHandler.js
Bartosz Dziewoński a4229f339e ve.init.mw.SpamBlacklistSaveErrorHandler: Update to receive entire response
Change-Id: Ifadf23d572a77e082edaa80e6c97792f8c1af4d3
Depends-On: I818d916275b8451af6910ddaa7cd4d7c653085ee
2018-12-07 14:17:55 -05:00

26 lines
939 B
JavaScript

mw.libs.ve.targetLoader.addPlugin( function () {
ve.init.mw.SpamBlacklistSaveErrorHandler = function () {};
OO.inheritClass( ve.init.mw.SpamBlacklistSaveErrorHandler, ve.init.mw.SaveErrorHandler );
ve.init.mw.SpamBlacklistSaveErrorHandler.static.name = 'spamBlacklist';
ve.init.mw.SpamBlacklistSaveErrorHandler.static.matchFunction = function ( data ) {
return !!ve.getProp( data, 'visualeditoredit', 'edit', 'spamblacklist' );
};
ve.init.mw.SpamBlacklistSaveErrorHandler.static.process = function ( data, target ) {
// Handle spam blacklist error from Extension:SpamBlacklist
target.showSaveError(
$( $.parseHTML( ve.getProp( data, 'visualeditoredit', 'edit', 'sberrorparsed' ) ) ),
false // prevents reapply
);
// Emit event for tracking. TODO: This is a bad design
target.emit( 'saveErrorSpamBlacklist' );
};
ve.init.mw.saveErrorHandlerFactory.register( ve.init.mw.SpamBlacklistSaveErrorHandler );
} );