X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.special.apisandbox%2Fapisandbox.js;h=83a39d477d5830823332a512b13f511dad6e6d92;hb=082f16e322919f997ce20b75f5ca15d231c63ee3;hp=48b3269bfaeb4a42c0a93cef667d88eb54ce894b;hpb=e2e9117a51f5c08e32817f474e1c7b2882307785;p=lhc%2Fweb%2Fwiklou.git
diff --git a/resources/src/mediawiki.special.apisandbox/apisandbox.js b/resources/src/mediawiki.special.apisandbox/apisandbox.js
index 48b3269bfa..83a39d477d 100644
--- a/resources/src/mediawiki.special.apisandbox/apisandbox.js
+++ b/resources/src/mediawiki.special.apisandbox/apisandbox.js
@@ -1,4 +1,3 @@
-/* eslint-disable no-restricted-properties */
( function () {
'use strict';
var ApiSandbox, Util, WidgetMethods, Validators,
@@ -34,11 +33,11 @@
this.checkbox = new OO.ui.CheckboxInputWidget( config.checkbox )
.on( 'change', this.onCheckboxChange, [], this );
- OptionalWidget[ 'super' ].call( this, config );
+ OptionalWidget.super.call( this, config );
// Forward most methods for convenience
for ( k in this.widget ) {
- if ( $.isFunction( this.widget[ k ] ) && !this[ k ] ) {
+ if ( typeof this.widget[ k ] === 'function' && !this[ k ] ) {
this[ k ] = this.widget[ k ].bind( this.widget );
}
}
@@ -71,12 +70,12 @@
};
OptionalWidget.prototype.onOverlayClick = function () {
this.setDisabled( false );
- if ( $.isFunction( this.widget.focus ) ) {
+ if ( typeof this.widget.focus === 'function' ) {
this.widget.focus();
}
};
OptionalWidget.prototype.setDisabled = function ( disabled ) {
- OptionalWidget[ 'super' ].prototype.setDisabled.call( this, disabled );
+ OptionalWidget.super.prototype.setDisabled.call( this, disabled );
this.widget.setDisabled( this.isDisabled() );
this.checkbox.setSelected( !this.isDisabled() );
this.$cover.toggle( this.isDisabled() );
@@ -91,7 +90,7 @@
},
setApiValue: function ( v ) {
if ( v === undefined ) {
- v = this.paramInfo[ 'default' ];
+ v = this.paramInfo.default;
}
this.setValue( v );
},
@@ -175,7 +174,7 @@
var menu = this.getMenu();
if ( v === undefined ) {
- v = this.paramInfo[ 'default' ];
+ v = this.paramInfo.default;
}
if ( v === undefined ) {
menu.selectItem();
@@ -205,7 +204,7 @@
}
},
getApiValueForTemplates: function () {
- return this.isDisabled() ? this.parseApiValue( this.paramInfo[ 'default' ] ) : this.getValue();
+ return this.isDisabled() ? this.parseApiValue( this.paramInfo.default ) : this.getValue();
},
getApiValue: function () {
var items = this.getValue();
@@ -217,7 +216,7 @@
},
setApiValue: function ( v ) {
if ( v === undefined ) {
- v = this.paramInfo[ 'default' ];
+ v = this.paramInfo.default;
}
this.setValue( this.parseApiValue( v ) );
},
@@ -267,12 +266,12 @@
submoduleWidget: {
single: function () {
- var v = this.isDisabled() ? this.paramInfo[ 'default' ] : this.getApiValue();
+ var v = this.isDisabled() ? this.paramInfo.default : this.getApiValue();
return v === undefined ? [] : [ { value: v, path: this.paramInfo.submodules[ v ] } ];
},
multi: function () {
var map = this.paramInfo.submodules,
- v = this.isDisabled() ? this.paramInfo[ 'default' ] : this.getApiValue();
+ v = this.isDisabled() ? this.paramInfo.default : this.getApiValue();
return v === undefined || v === '' ? [] : String( v ).split( '|' ).map( function ( v ) {
return { value: v, path: map[ v ] };
} );
@@ -525,6 +524,7 @@
break;
case 'namespace':
+ // eslint-disable-next-line jquery/no-map-util
items = $.map( mw.config.get( 'wgFormattedNamespaces' ), function ( name, ns ) {
if ( ns === '0' ) {
name = mw.message( 'blanknamespace' ).text();
@@ -662,7 +662,9 @@
$.extend( finalWidget, WidgetMethods.optionalWidget );
if ( widget.getSubmodules ) {
finalWidget.getSubmodules = widget.getSubmodules.bind( widget );
- finalWidget.on( 'disable', function () { setTimeout( ApiSandbox.updateUI ); } );
+ finalWidget.on( 'disable', function () {
+ setTimeout( ApiSandbox.updateUI );
+ } );
}
if ( widget.getApiValueForTemplates ) {
finalWidget.getApiValueForTemplates = widget.getApiValueForTemplates.bind( widget );
@@ -670,7 +672,7 @@
finalWidget.setDisabled( true );
}
- widget.setApiValue( pi[ 'default' ] );
+ widget.setApiValue( pi.default );
return finalWidget;
},
@@ -975,6 +977,7 @@
// OO.ui.ButtonWidget doesn't take focus itself (T128054)
$focus = $( '#mw-apisandbox-ui' ).find( document.activeElement );
if ( $focus.length ) {
+ // eslint-disable-next-line jquery/no-event-shorthand
$focus[ 0 ].blur();
}
@@ -1205,14 +1208,14 @@
.text( data )
.appendTo( $result );
}
- if ( paramsAreForced || data[ 'continue' ] ) {
+ if ( paramsAreForced || data.continue ) {
$result.append(
$( '
' ).append(
new OO.ui.ButtonWidget( {
label: mw.message( 'apisandbox-continue' ).text()
} ).on( 'click', function () {
- ApiSandbox.sendRequest( $.extend( {}, baseRequestParams, data[ 'continue' ] ) );
- } ).setDisabled( !data[ 'continue' ] ).$element,
+ ApiSandbox.sendRequest( $.extend( {}, baseRequestParams, data.continue ) );
+ } ).setDisabled( !data.continue ).$element,
( clear = new OO.ui.ButtonWidget( {
label: mw.message( 'apisandbox-continue-clear' ).text()
} ).on( 'click', function () {
@@ -1353,7 +1356,7 @@
this.templatedItemsCache = {};
this.tokenWidget = null;
this.indentLevel = config.indentLevel ? config.indentLevel : 0;
- ApiSandbox.PageLayout[ 'super' ].call( this, config.key, config );
+ ApiSandbox.PageLayout.super.call( this, config.key, config );
this.loadParamInfo();
};
OO.inheritClass( ApiSandbox.PageLayout, OO.ui.PageLayout );
@@ -1368,10 +1371,10 @@
function widgetLabelOnClick() {
var f = this.getField();
- if ( $.isFunction( f.setDisabled ) ) {
+ if ( typeof f.setDisabled === 'function' ) {
f.setDisabled( false );
}
- if ( $.isFunction( f.focus ) ) {
+ if ( typeof f.focus === 'function' ) {
f.focus();
}
}
@@ -1566,7 +1569,7 @@
// it makes it too hard to read and our "disabled"
// isn't really disabled.
widgetField.onFieldDisable( false );
- widgetField.onFieldDisable = $.noop;
+ widgetField.onFieldDisable = function () {};
widgetField.apiParamIndex = ppi.index;
@@ -1597,7 +1600,7 @@
}
toRemove = {};
- // eslint-disable-next-line no-restricted-properties
+ // eslint-disable-next-line jquery/no-each-util
$.each( this.templatedItemsCache, function ( k, el ) {
if ( el.widget.isElementAttached() ) {
toRemove[ k ] = el;
@@ -1615,7 +1618,7 @@
};
} );
doProcess = function ( placeholder, target ) {
- var values, container, index, usedVars, done;
+ var values, container, index, usedVars, done, items, i;
target = prefix + target;
@@ -1646,11 +1649,13 @@
done = $.isEmptyObject( p.vars );
if ( done ) {
container = Util.apiBool( p.info.deprecated ) ? that.deprecatedItemsFieldset : that.itemsFieldset;
- index = container.getItems().findIndex( function ( el ) {
- return el.apiParamIndex !== undefined && el.apiParamIndex > p.info.index;
- } );
- if ( index < 0 ) {
- index = undefined;
+ items = container.getItems();
+ index = undefined;
+ for ( i = 0; i < items.length; i++ ) {
+ if ( items[ i ].apiParamIndex !== undefined && items[ i ].apiParamIndex > p.info.index ) {
+ index = i;
+ break;
+ }
}
}
values.forEach( function ( value ) {
@@ -1684,6 +1689,7 @@
}
} else {
newVars = {};
+ // eslint-disable-next-line jquery/no-each-util
$.each( p.vars, function ( k, v ) {
newVars[ k ] = v.replace( placeholder, value );
} );
@@ -1699,9 +1705,11 @@
};
while ( toProcess.length ) {
p = toProcess.shift();
+ // eslint-disable-next-line jquery/no-each-util
$.each( p.vars, doProcess );
}
+ // eslint-disable-next-line jquery/no-map-util
toRemove = $.map( toRemove, function ( el, name ) {
delete that.widgets[ name ];
return [ el.widgetField, el.helpField ];
@@ -1749,7 +1757,7 @@
widget = Util.createWidgetForParameter( {
name: name,
type: 'string',
- 'default': ''
+ default: ''
}, {
nooptional: true
} );
@@ -1798,7 +1806,7 @@
for ( i = 0; i < pi.parameters.length; i++ ) {
if ( pi.parameters[ i ].name === 'action' ) {
pi.parameters[ i ].required = true;
- delete pi.parameters[ i ][ 'default' ];
+ delete pi.parameters[ i ].default;
}
if ( pi.parameters[ i ].name === 'format' ) {
tmp = pi.parameters[ i ].type;
@@ -1806,7 +1814,7 @@
availableFormats[ tmp[ j ] ] = true;
}
pi.parameters[ i ].type = tmp.filter( filterFmModules );
- pi.parameters[ i ][ 'default' ] = 'json';
+ pi.parameters[ i ].default = 'json';
pi.parameters[ i ].required = true;
}
}
@@ -1936,6 +1944,7 @@
}
that.deprecatedItemsFieldset = new OO.ui.FieldsetLayout().addItems( deprecatedItems ).toggle( false );
+ // eslint-disable-next-line jquery/no-animate-toggle
tmp = $( '