expandFrom = 'left';
// Catch invalid values, default to 'auto'
- } else if ( $.inArray( expandFrom, [ 'left', 'right', 'start', 'end', 'auto' ] ) === -1 ) {
+ } else if ( [ 'left', 'right', 'start', 'end', 'auto' ].indexOf( expandFrom ) === -1 ) {
expandFrom = 'auto';
}
];
if ( context.data.keypressedCount === 0 &&
e.which === context.data.keypressed &&
- $.inArray( e.which, allowed ) !== -1
+ allowed.indexOf( e.which ) !== -1
) {
$.suggestions.keypress( e, context, context.data.keypressed );
}
function uniqueElements( array ) {
var uniques = [];
- $.each( array, function ( i, elem ) {
- if ( elem !== undefined && $.inArray( elem, uniques ) === -1 ) {
+ array.forEach( function ( elem ) {
+ if ( elem !== undefined && uniques.indexOf( elem ) === -1 ) {
uniques.push( elem );
}
} );
cell = this;
// Get current column index
columns = config.headerToColumns[ $cell.data( 'headerIndex' ) ];
- newSortList = $.map( columns, function ( c ) {
- // jQuery "helpfully" flattens the arrays...
- return [ [ c, $cell.data( 'order' ) ] ];
+ newSortList = columns.map( function ( c ) {
+ return [ c, $cell.data( 'order' ) ];
} );
// Index of first column belonging to this header
i = columns[ 0 ];
mw.util.getParamValue( 'undo' ) !== null ||
// Pressing "show changes" and "preview" also signify that the user will
// probably save the page soon
- $.inArray( $form.find( '#mw-edit-mode' ).val(), [ 'preview', 'diff' ] ) > -1
+ [ 'preview', 'diff' ].indexOf( $form.find( '#mw-edit-mode' ).val() ) > -1
) {
checkStash();
}
for ( j = 0; j < tmp.length; j++ ) {
availableFormats[ tmp[ j ] ] = true;
}
- pi.parameters[ i ].type = $.grep( tmp, filterFmModules );
+ pi.parameters[ i ].type = tmp.filter( filterFmModules );
pi.parameters[ i ][ 'default' ] = 'json';
pi.parameters[ i ].required = true;
}
// Hide the 'wrappedhtml' parameter on format modules
if ( pi.group === 'format' ) {
- pi.parameters = $.grep( pi.parameters, function ( p ) {
+ pi.parameters = pi.parameters.filter( function ( p ) {
return p.name !== 'wrappedhtml';
} );
}
popup: {
width: 'auto',
padded: true,
- $content: $( '<ul>' ).append( $.map( pi.helpurls, function ( link ) {
+ $content: $( '<ul>' ).append( pi.helpurls.map( function ( link ) {
return $( '<li>' ).append( $( '<a>' )
.attr( { href: link, target: '_blank' } )
.text( link )
popup: {
width: 'auto',
padded: true,
- $content: $( '<ul>' ).append( $.map( pi.examples, function ( example ) {
+ $content: $( '<ul>' ).append( pi.examples.map( function ( example ) {
var a = $( '<a>' )
.attr( 'href', '#' + example.query )
.html( example.description );
expiryValue = expiryWidget.dropdowninput.getValue(),
// infinityValues are the values the SpecialBlock class accepts as infinity (sf. wfIsInfinity)
infinityValues = [ 'infinite', 'indefinite', 'infinity', 'never' ],
- isIndefinite = $.inArray( expiryValue, infinityValues ) !== -1 ||
- ( expiryValue === 'other' && $.inArray( expiryWidget.textinput.getValue(), infinityValues ) !== -1 );
+ isIndefinite = infinityValues.indexOf( expiryValue ) !== -1 ||
+ ( expiryValue === 'other' && infinityValues.indexOf( expiryWidget.textinput.getValue() ) !== -1 );
if ( enableAutoblockField ) {
enableAutoblockField.toggle( !( isNonEmptyIp ) );
if (
mw.config.get( 'wgCheckFileExtensions' ) &&
mw.config.get( 'wgStrictFileExtensions' ) &&
- mw.config.get( 'wgFileExtensions' ) &&
+ Array.isArray( mw.config.get( 'wgFileExtensions' ) ) &&
$( this ).attr( 'id' ) !== 'wpUploadFileURL'
) {
if (
fname.lastIndexOf( '.' ) === -1 ||
- $.inArray(
- fname.slice( fname.lastIndexOf( '.' ) + 1 ).toLowerCase(),
- $.map( mw.config.get( 'wgFileExtensions' ), function ( element ) {
- return element.toLowerCase();
- } )
- ) === -1
+ mw.config.get( 'wgFileExtensions' ).map( function ( element ) {
+ return element.toLowerCase();
+ } ).indexOf( fname.slice( fname.lastIndexOf( '.' ) + 1 ).toLowerCase() ) === -1
) {
// Not a valid extension
// Clear the upload and set mw-upload-permitted to error
function fileIsPreviewable( file ) {
var known = [ 'image/png', 'image/gif', 'image/jpeg', 'image/svg+xml' ],
tooHuge = 10 * 1024 * 1024;
- return ( $.inArray( file.type, known ) !== -1 ) && file.size > 0 && file.size < tooHuge;
+ return ( known.indexOf( file.type ) !== -1 ) && file.size > 0 && file.size < tooHuge;
}
/**
'import',
'options'
];
- if ( $.inArray( action, csrfActions ) !== -1 ) {
+ if ( csrfActions.indexOf( action ) !== -1 ) {
mw.track( 'mw.deprecate', 'apitoken_' + action );
mw.log.warn( 'Use of the "' + action + '" token is deprecated. Use "csrf" instead.' );
return 'csrf';
startTagName = startTagName.toLowerCase();
endTagName = endTagName.toLowerCase();
- if ( startTagName !== endTagName || $.inArray( startTagName, settings.allowedHtmlElements ) === -1 ) {
+ if ( startTagName !== endTagName || settings.allowedHtmlElements.indexOf( startTagName ) === -1 ) {
return false;
}
for ( i = 0, len = attributes.length; i < len; i += 2 ) {
attributeName = attributes[ i ];
- if ( $.inArray( attributeName, settings.allowedHtmlCommonAttributes ) === -1 &&
- $.inArray( attributeName, settings.allowedHtmlAttributesByElement[ startTagName ] || [] ) === -1 ) {
+ if ( settings.allowedHtmlCommonAttributes.indexOf( attributeName ) === -1 &&
+ ( settings.allowedHtmlAttributesByElement[ startTagName ] || [] ).indexOf( attributeName ) === -1 ) {
return false;
}
}
// Try the cache
if ( cache[ url ] ) {
// Update access freshness
- cacheOrder.splice( $.inArray( url, cacheOrder ), 1 );
+ cacheOrder.splice( cacheOrder.indexOf( url ), 1 );
cacheOrder.push( url );
return $.Deferred().resolve( cache[ url ] ).promise();
}
function among( actual, expected, message ) {
if ( Array.isArray( expected ) ) {
- assert.ok( $.inArray( actual, expected ) !== -1, message + ' (got ' + actual + '; expected one of ' + expected.join( ', ' ) + ')' );
+ assert.ok( expected.indexOf( actual ) !== -1, message + ' (got ' + actual + '; expected one of ' + expected.join( ', ' ) + ')' );
} else {
assert.equal( actual, expected, message );
}
// Requests are POST, match requestBody instead of url
this.server.respond( function ( request ) {
- if ( $.inArray( request.requestBody, [
+ if ( [
// simple
'action=options&format=json&formatversion=2&change=foo%3Dbar&token=%2B%5C',
// two options
'action=options&format=json&formatversion=2&change=foo&token=%2B%5C',
// reset an option, not bundleable
'action=options&format=json&formatversion=2&optionname=foo%7Cbar%3Dquux&token=%2B%5C'
- ] ) !== -1 ) {
+ ].indexOf( request.requestBody ) !== -1 ) {
assert.ok( true, 'Repond to ' + request.requestBody );
request.respond( 200, { 'Content-Type': 'application/json' },
'{ "options": "success" }' );
// Requests are POST, match requestBody instead of url
this.server.respond( function ( request ) {
- if ( $.inArray( request.requestBody, [
+ if ( [
// simple
'action=options&format=json&formatversion=2&change=foo%3Dbar&token=%2B%5C',
// two options
'action=options&format=json&formatversion=2&change=foo&token=%2B%5C',
// reset an option, not bundleable
'action=options&format=json&formatversion=2&optionname=foo%7Cbar%3Dquux&token=%2B%5C'
- ] ) !== -1 ) {
+ ].indexOf( request.requestBody ) !== -1 ) {
assert.ok( true, 'Repond to ' + request.requestBody );
request.respond(
200,
}
function sequenceBodies( status, headers, bodies ) {
- jQuery.each( bodies, function ( i, body ) {
+ bodies.forEach( function ( body, i ) {
bodies[ i ] = [ status, headers, body ];
} );
return sequence( bodies );
]
];
- $.each( testCases, function () {
+ testCases.forEach( function ( testCase ) {
var
- key = this[ 0 ],
- input = this[ 1 ],
- output = this[ 2 ];
+ key = testCase[ 0 ],
+ input = testCase[ 1 ],
+ output = testCase[ 2 ];
mw.messages.set( key, input );
assert.htmlEqual(
formatParse( key ),
]
];
- $.each( testCases, function () {
+ testCases.forEach( function ( testCase ) {
var
- key = this[ 0 ],
- input = this[ 1 ],
- output = this[ 2 ],
+ key = testCase[ 0 ],
+ input = testCase[ 1 ],
+ output = testCase[ 2 ],
paramHref = key.slice( 0, 8 ) === 'wikilink' ? 'Example' : 'http://example.com',
paramText = 'Text';
mw.messages.set( key, input );