mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/ConfirmEdit
synced 2024-11-23 15:56:50 +00:00
build: Switch eslint to ES6 mode, and make pass
Change-Id: Ic29ad198519a7455909b8ee32fa891c7881e4bb5
This commit is contained in:
parent
003fd5778f
commit
2f9beac0fa
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"root": true,
|
||||
"extends": [
|
||||
"wikimedia/client-es5",
|
||||
"wikimedia/client",
|
||||
"wikimedia/jquery",
|
||||
"wikimedia/mediawiki"
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* eslint-disable no-jquery/no-global-selector */
|
||||
$( document ).on( 'click', '.fancycaptcha-reload', function () {
|
||||
var $this = $( this ),
|
||||
const $this = $( this ),
|
||||
$root = $this.closest( '.fancycaptcha-captcha-container' ),
|
||||
$captchaImage = $root.find( '.fancycaptcha-image' );
|
||||
|
||||
|
@ -8,8 +8,8 @@ $( document ).on( 'click', '.fancycaptcha-reload', function () {
|
|||
|
||||
// AJAX request to get captcha index key
|
||||
new mw.Api().post( { action: 'fancycaptchareload' } ).done( function ( data ) {
|
||||
var captchaIndex = data.fancycaptchareload.index,
|
||||
imgSrc;
|
||||
const captchaIndex = data.fancycaptchareload.index;
|
||||
let imgSrc;
|
||||
if ( typeof captchaIndex === 'string' ) {
|
||||
// replace index key with a new one for captcha image
|
||||
imgSrc = $captchaImage.attr( 'src' ).replace( /(wpCaptchaId=)\w+/, '$1' + captchaIndex );
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* eslint-env node */
|
||||
module.exports = function ( grunt ) {
|
||||
var messagesDirs = grunt.file.readJSON( 'extension.json' ).MessagesDirs;
|
||||
const messagesDirs = grunt.file.readJSON( 'extension.json' ).MessagesDirs;
|
||||
|
||||
var subExtensions = [
|
||||
const subExtensions = [
|
||||
'QuestyCaptcha',
|
||||
'ReCaptchaNoCaptcha',
|
||||
'FancyCaptcha',
|
||||
|
|
|
@ -8,8 +8,8 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|||
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.name = 'confirmEditNoCaptchaReCaptcha';
|
||||
|
||||
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.getReadyPromise = function () {
|
||||
var onLoadFn = 'onRecaptchaLoadCallback' + Date.now(),
|
||||
deferred, config, scriptURL, params;
|
||||
const onLoadFn = 'onRecaptchaLoadCallback' + Date.now();
|
||||
let deferred, config, scriptURL, params;
|
||||
|
||||
if ( !this.readyPromise ) {
|
||||
deferred = $.Deferred();
|
||||
|
@ -27,13 +27,13 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|||
};
|
||||
|
||||
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.matchFunction = function ( data ) {
|
||||
var captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
|
||||
const captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
|
||||
|
||||
return !!( captchaData && captchaData.type === 'recaptchanocaptcha' );
|
||||
};
|
||||
|
||||
ve.init.mw.NoCaptchaReCaptchaSaveErrorHandler.static.process = function ( data, target ) {
|
||||
var self = this,
|
||||
const self = this,
|
||||
config = mw.config.get( 'wgConfirmEditConfig' ),
|
||||
siteKey = config.reCaptchaSiteKey,
|
||||
$container = $( '<div>' );
|
||||
|
|
|
@ -7,8 +7,8 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|||
ve.init.mw.HCaptchaSaveErrorHandler.static.name = 'confirmEditHCaptcha';
|
||||
|
||||
ve.init.mw.HCaptchaSaveErrorHandler.static.getReadyPromise = function () {
|
||||
var onLoadFn = 'onHcaptchaLoadCallback' + Date.now(),
|
||||
deferred, scriptURL, params;
|
||||
const onLoadFn = 'onHcaptchaLoadCallback' + Date.now();
|
||||
let deferred, scriptURL, params;
|
||||
|
||||
if ( !this.readyPromise ) {
|
||||
deferred = $.Deferred();
|
||||
|
@ -25,13 +25,13 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|||
};
|
||||
|
||||
ve.init.mw.HCaptchaSaveErrorHandler.static.matchFunction = function ( data ) {
|
||||
var captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
|
||||
const captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
|
||||
|
||||
return !!( captchaData && captchaData.type === 'hcaptcha' );
|
||||
};
|
||||
|
||||
ve.init.mw.HCaptchaSaveErrorHandler.static.process = function ( data, target ) {
|
||||
var self = this,
|
||||
const self = this,
|
||||
siteKey = require( './config.json' ).hCaptchaSiteKey,
|
||||
$container = $( '<div>' );
|
||||
|
||||
|
|
|
@ -38,14 +38,13 @@ OO.inheritClass( mw.libs.confirmEdit.CaptchaInputWidget, OO.ui.TextInputWidget )
|
|||
/* Methods */
|
||||
|
||||
mw.libs.confirmEdit.CaptchaInputWidget.prototype.makeCaptchaInterface = function ( captchaData ) {
|
||||
var $captchaImg, msg, question,
|
||||
$captchaDiv, $captchaParagraph;
|
||||
let $captchaImg, msg, question;
|
||||
|
||||
$captchaParagraph = $( '<div>' ).append(
|
||||
const $captchaParagraph = $( '<div>' ).append(
|
||||
$( '<strong>' ).text( mw.msg( 'captcha-label' ) ),
|
||||
document.createTextNode( mw.msg( 'colon-separator' ) )
|
||||
);
|
||||
$captchaDiv = $( '<div>' ).append( $captchaParagraph );
|
||||
const $captchaDiv = $( '<div>' ).append( $captchaParagraph );
|
||||
|
||||
if ( captchaData.url ) {
|
||||
// FancyCaptcha
|
||||
|
|
|
@ -15,7 +15,7 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|||
ve.init.mw.CaptchaSaveErrorHandler.static.name = 'confirmEditCaptchas';
|
||||
|
||||
ve.init.mw.CaptchaSaveErrorHandler.static.matchFunction = function ( data ) {
|
||||
var captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
|
||||
const captchaData = ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' );
|
||||
|
||||
return !!( captchaData && (
|
||||
captchaData.url ||
|
||||
|
@ -26,7 +26,10 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|||
};
|
||||
|
||||
ve.init.mw.CaptchaSaveErrorHandler.static.process = function ( data, target ) {
|
||||
var captchaInput;
|
||||
const captchaInput = new mw.libs.confirmEdit.CaptchaInputWidget(
|
||||
ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' )
|
||||
);
|
||||
ve.targetLinksToNewWindow( captchaInput.$element[ 0 ] );
|
||||
|
||||
function onCaptchaLoad() {
|
||||
target.saveDialog.updateSize();
|
||||
|
@ -34,11 +37,6 @@ mw.loader.using( 'ext.visualEditor.targetLoader' ).then( function () {
|
|||
captchaInput.scrollElementIntoView();
|
||||
}
|
||||
|
||||
captchaInput = new mw.libs.confirmEdit.CaptchaInputWidget(
|
||||
ve.getProp( data, 'visualeditoredit', 'edit', 'captcha' )
|
||||
);
|
||||
ve.targetLinksToNewWindow( captchaInput.$element[ 0 ] );
|
||||
|
||||
captchaInput.on( 'load', onCaptchaLoad );
|
||||
// Save when pressing 'Enter' in captcha field as it is single line.
|
||||
captchaInput.on( 'enter', function () {
|
||||
|
|
Loading…
Reference in a new issue