aboutsummaryrefslogtreecommitdiffstats
path: root/resources/src
diff options
context:
space:
mode:
authorEd Sanders <esanders@wikimedia.org>2024-06-03 15:36:54 +0100
committerEd Sanders <esanders@wikimedia.org>2024-06-04 13:39:22 +0100
commit43b31fec5da9e89fc820c5645076824b43baac54 (patch)
tree6381820607adaa2b8545847fcf6f2993ee595808 /resources/src
parente505ad0d04743967c5b8e7c22d275b39a8f6db56 (diff)
downloadmediawikicore-43b31fec5da9e89fc820c5645076824b43baac54.tar.gz
mediawikicore-43b31fec5da9e89fc820c5645076824b43baac54.zip
ESLint: Prefer arrow callbacks (autofix) in mediawiki.widgets
Change-Id: Ic07010e5219b04b3b2b156468272d8df5dce233b
Diffstat (limited to 'resources/src')
-rw-r--r--resources/src/mediawiki.widgets.datetime/CalendarWidget.js4
-rw-r--r--resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js4
-rw-r--r--resources/src/mediawiki.widgets.datetime/DiscordianDateTimeFormatter.js4
-rw-r--r--resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js28
-rw-r--r--resources/src/mediawiki.widgets.visibleLengthLimit/mediawiki.widgets.visibleLengthLimit.js2
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js2
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js8
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js10
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js8
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js4
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js2
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js4
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsProvider.js7
-rw-r--r--resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsQueue.js2
-rw-r--r--resources/src/mediawiki.widgets/Table/mw.widgets.RowWidget.js4
-rw-r--r--resources/src/mediawiki.widgets/Table/mw.widgets.TableWidget.js4
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js2
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js70
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.CategoryTagItemWidget.js16
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js8
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js14
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.ExpiryInputWidget.js12
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js8
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.NamespacesMultiselectWidget.js22
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js14
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js4
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js2
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js2
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js2
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js26
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.TitlesMultiselectWidget.js16
-rw-r--r--resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js10
32 files changed, 131 insertions, 194 deletions
diff --git a/resources/src/mediawiki.widgets.datetime/CalendarWidget.js b/resources/src/mediawiki.widgets.datetime/CalendarWidget.js
index 2c48bf9ad4ee..7b6d69b9ab21 100644
--- a/resources/src/mediawiki.widgets.datetime/CalendarWidget.js
+++ b/resources/src/mediawiki.widgets.datetime/CalendarWidget.js
@@ -218,9 +218,7 @@
if ( dates instanceof Date ) {
dates = [ dates ];
} else if ( Array.isArray( dates ) ) {
- dates = dates.filter( function ( dt ) {
- return dt instanceof Date;
- } );
+ dates = dates.filter( ( dt ) => dt instanceof Date );
dates.sort();
} else {
dates = [];
diff --git a/resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js b/resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js
index 0fbd01801d9d..44e1cff9eb00 100644
--- a/resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js
+++ b/resources/src/mediawiki.widgets.datetime/DateTimeFormatter.js
@@ -345,9 +345,7 @@
};
spec.size = Math.max.apply(
// eslint-disable-next-line no-jquery/no-map-util
- null, $.map( spec.values, function ( v ) {
- return v.length;
- } )
+ null, $.map( spec.values, ( v ) => v.length )
);
return spec;
}
diff --git a/resources/src/mediawiki.widgets.datetime/DiscordianDateTimeFormatter.js b/resources/src/mediawiki.widgets.datetime/DiscordianDateTimeFormatter.js
index 0447518b772b..8f920332ffa1 100644
--- a/resources/src/mediawiki.widgets.datetime/DiscordianDateTimeFormatter.js
+++ b/resources/src/mediawiki.widgets.datetime/DiscordianDateTimeFormatter.js
@@ -198,9 +198,7 @@
if ( spec.values ) {
spec.size = Math.max.apply(
// eslint-disable-next-line no-jquery/no-map-util
- null, $.map( spec.values, function ( v ) {
- return v.length;
- } )
+ null, $.map( spec.values, ( v ) => v.length )
);
}
}
diff --git a/resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js b/resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js
index df06028c31e3..a0dd35a752cb 100644
--- a/resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js
+++ b/resources/src/mediawiki.widgets.datetime/ProlepticGregorianDateTimeFormatter.js
@@ -39,28 +39,28 @@
if ( config.fullMonthNames && !config.shortMonthNames ) {
config.shortMonthNames = {};
// eslint-disable-next-line no-jquery/no-each-util
- $.each( config.fullMonthNames, function ( k, v ) {
+ $.each( config.fullMonthNames, ( k, v ) => {
config.shortMonthNames[ k ] = v.slice( 0, 3 );
} );
}
if ( config.shortDayNames && !config.dayLetters ) {
config.dayLetters = [];
// eslint-disable-next-line no-jquery/no-each-util
- $.each( config.shortDayNames, function ( k, v ) {
+ $.each( config.shortDayNames, ( k, v ) => {
config.dayLetters[ k ] = v.slice( 0, 1 );
} );
}
if ( config.fullDayNames && !config.dayLetters ) {
config.dayLetters = [];
// eslint-disable-next-line no-jquery/no-each-util
- $.each( config.fullDayNames, function ( k, v ) {
+ $.each( config.fullDayNames, ( k, v ) => {
config.dayLetters[ k ] = v.slice( 0, 1 );
} );
}
if ( config.fullDayNames && !config.shortDayNames ) {
config.shortDayNames = {};
// eslint-disable-next-line no-jquery/no-each-util
- $.each( config.fullDayNames, function ( k, v ) {
+ $.each( config.fullDayNames, ( k, v ) => {
config.shortDayNames[ k ] = v.slice( 0, 3 );
} );
}
@@ -173,30 +173,30 @@
if ( this.fullMonthNames && !this.shortMonthNames ) {
this.shortMonthNames = {};
// eslint-disable-next-line no-jquery/no-each-util
- $.each( this.fullMonthNames, function ( k, v ) {
+ $.each( this.fullMonthNames, ( k, v ) => {
this.shortMonthNames[ k ] = v.slice( 0, 3 );
- }.bind( this ) );
+ } );
}
if ( this.shortDayNames && !this.dayLetters ) {
this.dayLetters = [];
// eslint-disable-next-line no-jquery/no-each-util
- $.each( this.shortDayNames, function ( k, v ) {
+ $.each( this.shortDayNames, ( k, v ) => {
this.dayLetters[ k ] = v.slice( 0, 1 );
- }.bind( this ) );
+ } );
}
if ( this.fullDayNames && !this.dayLetters ) {
this.dayLetters = [];
// eslint-disable-next-line no-jquery/no-each-util
- $.each( this.fullDayNames, function ( k, v ) {
+ $.each( this.fullDayNames, ( k, v ) => {
this.dayLetters[ k ] = v.slice( 0, 1 );
- }.bind( this ) );
+ } );
}
if ( this.fullDayNames && !this.shortDayNames ) {
this.shortDayNames = {};
// eslint-disable-next-line no-jquery/no-each-util
- $.each( this.fullDayNames, function ( k, v ) {
+ $.each( this.fullDayNames, ( k, v ) => {
this.shortDayNames[ k ] = v.slice( 0, 3 );
- }.bind( this ) );
+ } );
}
if ( !this.fullMonthNames ) {
@@ -413,9 +413,7 @@
if ( spec.values ) {
spec.size = Math.max.apply(
// eslint-disable-next-line no-jquery/no-map-util
- null, $.map( spec.values, function ( v ) {
- return v.length;
- } )
+ null, $.map( spec.values, ( v ) => v.length )
);
}
}
diff --git a/resources/src/mediawiki.widgets.visibleLengthLimit/mediawiki.widgets.visibleLengthLimit.js b/resources/src/mediawiki.widgets.visibleLengthLimit/mediawiki.widgets.visibleLengthLimit.js
index 1d789123daaa..206430930b9c 100644
--- a/resources/src/mediawiki.widgets.visibleLengthLimit/mediawiki.widgets.visibleLengthLimit.js
+++ b/resources/src/mediawiki.widgets.visibleLengthLimit/mediawiki.widgets.visibleLengthLimit.js
@@ -62,7 +62,7 @@
internalVisibleLimit( lengthLimiter, textInputWidget, limit, filterFunction );
// Keep the remaining counter in sync when reason list changed
- dropdownInputWidget.on( 'change', function () {
+ dropdownInputWidget.on( 'change', () => {
textInputWidget.emit( 'change' );
} );
}
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js
index 42b07d1958e0..e03c2d8077df 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsProvider.js
@@ -60,7 +60,7 @@
allParams = $.extend( {}, this.getStaticParams(), this.getUserParams() );
const xhr = $.getJSON( this.getAPIurl(), allParams )
- .done( function ( data ) {
+ .done( ( data ) => {
if ( Array.isArray( data ) && data.length ) {
deferred.resolve( data );
} else {
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js
index bdc37615db1f..d3ed08dc0970 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.APIResultsQueue.js
@@ -69,16 +69,14 @@
if ( this.queue.length < howMany + this.threshold ) {
// Call for more results
fetchingPromise = this.queryProviders( howMany + this.threshold )
- .then( function ( items ) {
+ .then( ( items ) => {
// Add to the queue
me.queue = me.queue.concat.apply( me.queue, items );
} );
}
return $.when( fetchingPromise )
- .then( function () {
- return me.queue.splice( 0, howMany );
- } );
+ .then( () => me.queue.splice( 0, howMany ) );
};
@@ -95,7 +93,7 @@
// Make sure there are resources set up
return this.setup()
- .then( function () {
+ .then( () => {
// Abort previous requests
for ( let i = 0, iLen = queue.providerPromises.length; i < iLen; i++ ) {
queue.providerPromises[ i ].abort();
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js
index f744421b5c74..e626f6d9cc87 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceProvider.js
@@ -80,7 +80,7 @@
action: 'query',
meta: 'siteinfo'
} )
- .then( function ( data ) {
+ .then( ( data ) => {
provider.setImageSizes( data.query.general.imagelimits || [] );
provider.setThumbSizes( data.query.general.thumblimits || [] );
provider.setUserParams( {
@@ -106,7 +106,7 @@
const provider = this;
return this.loadSiteInfo()
- .then( function () {
+ .then( () => {
if ( aborted ) {
return $.Deferred().reject();
}
@@ -114,7 +114,7 @@
return xhr;
} )
.then(
- function ( results ) {
+ ( results ) => {
if ( !results || results.length === 0 ) {
provider.toggleDepleted( true );
return [];
@@ -122,7 +122,7 @@
return results;
},
// Process failed, return an empty promise
- function () {
+ () => {
provider.toggleDepleted( true );
return $.Deferred().resolve( [] );
}
@@ -180,7 +180,7 @@
const api = this.isLocal ? new mw.Api() : new mw.ForeignApi( this.getAPIurl(), { anonymous: true } );
const xhr = api.get( $.extend( {}, this.getStaticParams(), this.getUserParams(), this.getContinueData( howMany ) ) );
return xhr
- .then( function ( data ) {
+ .then( ( data ) => {
const results = [];
if ( data.error ) {
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js
index 45d101080b69..3fe970353d8a 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaResourceQueue.js
@@ -46,12 +46,8 @@
action: 'query',
meta: 'filerepoinfo'
} ).then(
- function ( resp ) {
- return resp.query && resp.query.repos || defaultSource;
- },
- function () {
- return $.Deferred().resolve( defaultSource );
- }
+ ( resp ) => resp.query && resp.query.repos || defaultSource,
+ () => $.Deferred().resolve( defaultSource )
);
}
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js
index c467bb810c45..6dda6adb51f6 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchProvider.js
@@ -57,9 +57,7 @@
* @inheritdoc
*/
mw.widgets.MediaSearchProvider.prototype.sort = function ( results ) {
- return results.sort( function ( a, b ) {
- return a.index - b.index;
- } );
+ return results.sort( ( a, b ) => a.index - b.index );
};
/**
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js
index bb273d5c89ce..60c585901c89 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchQueue.js
@@ -37,7 +37,7 @@
mw.widgets.MediaSearchQueue.prototype.setup = function () {
const queue = this;
- return this.getFileRepos().then( function ( sources ) {
+ return this.getFileRepos().then( ( sources ) => {
if ( queue.providers.length === 0 ) {
// Set up the providers
for ( let i = 0, len = sources.length; i < len; i++ ) {
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js
index 2819c66a1eed..d06bd1c9e1d8 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaSearchWidget.js
@@ -174,7 +174,7 @@
search.noItemsMessage.toggle( false );
this.currentQueue.get( this.constructor.static.limit )
- .then( function ( items ) {
+ .then( ( items ) => {
if ( items.length > 0 ) {
search.processQueueResults( items );
search.currentItemCache = search.currentItemCache.concat( items );
@@ -392,7 +392,7 @@
// Add method to a queue; this queue will only run when the widget
// is visible
- this.layoutQueue.push( function () {
+ this.layoutQueue.push( () => {
const maxRowWidth = search.results.$element.width() - 15;
// Go over the added items
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsProvider.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsProvider.js
index 6b4db30286a2..bd4248adcc02 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsProvider.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsProvider.js
@@ -57,11 +57,10 @@
* @inheritdoc
*/
mw.widgets.MediaUserUploadsProvider.prototype.sort = function ( results ) {
- return results.sort( function ( a, b ) {
+ return results.sort(
// timestamps are strings
- return a.timestamp < b.timestamp ? 1 :
- ( a.timestamp === b.timestamp ? 0 : -1 );
- } );
+ ( a, b ) => a.timestamp < b.timestamp ? 1 : ( a.timestamp === b.timestamp ? 0 : -1 )
+ );
};
/**
diff --git a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsQueue.js b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsQueue.js
index 697394df6e28..72e7afb4f8a7 100644
--- a/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsQueue.js
+++ b/resources/src/mediawiki.widgets/MediaSearch/mw.widgets.MediaUserUploadsQueue.js
@@ -41,7 +41,7 @@
mw.widgets.MediaUserUploadsQueue.prototype.setup = function () {
const queue = this;
- return this.getFileRepos().then( function ( sources ) {
+ return this.getFileRepos().then( ( sources ) => {
if ( queue.providers.length === 0 ) {
// Set up the providers
for ( let i = 0, len = sources.length; i < len; i++ ) {
diff --git a/resources/src/mediawiki.widgets/Table/mw.widgets.RowWidget.js b/resources/src/mediawiki.widgets/Table/mw.widgets.RowWidget.js
index 879593d63c1c..bad8487c1381 100644
--- a/resources/src/mediawiki.widgets/Table/mw.widgets.RowWidget.js
+++ b/resources/src/mediawiki.widgets/Table/mw.widgets.RowWidget.js
@@ -304,7 +304,7 @@ mw.widgets.RowWidget.prototype.onCellChange = function ( input, value ) {
// Right now, the table can't know if it's valid or not because the events
// don't get passed through.
const self = this;
- input.getValidity().done( function () {
+ input.getValidity().done( () => {
self.model.setValue( input.getData(), value );
} );
};
@@ -334,7 +334,7 @@ mw.widgets.RowWidget.prototype.setDisabled = function ( disabled ) {
this.deleteButton.setDisabled( disabled );
}
- this.getItems().forEach( function ( cell ) {
+ this.getItems().forEach( ( cell ) => {
cell.setDisabled( disabled );
} );
};
diff --git a/resources/src/mediawiki.widgets/Table/mw.widgets.TableWidget.js b/resources/src/mediawiki.widgets/Table/mw.widgets.TableWidget.js
index cbc75d9d3df9..0a76c3d40d58 100644
--- a/resources/src/mediawiki.widgets/Table/mw.widgets.TableWidget.js
+++ b/resources/src/mediawiki.widgets/Table/mw.widgets.TableWidget.js
@@ -543,12 +543,12 @@ mw.widgets.TableWidget.prototype.setDisabled = function ( disabled ) {
return;
}
- this.getItems().forEach( function ( row ) {
+ this.getItems().forEach( ( row ) => {
row.setDisabled( disabled );
} );
if ( this.model.getTableProperties().allowRowInsertion ) {
- this.insertionRow.getItems().forEach( function ( row ) {
+ this.insertionRow.getItems().forEach( ( row ) => {
row.setDisabled( disabled );
} );
}
diff --git a/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js
index 87a99feaee70..f4468f763ead 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.CalendarWidget.js
@@ -330,7 +330,7 @@
} else if ( fade === 'next' || fade === 'down' ) {
this.$body.insertAfter( this.$oldBody );
}
- setTimeout( function () {
+ setTimeout( () => {
// The following classes are used here:
// * mw-widget-calendarWidget-body-wrapper-fade-up
// * mw-widget-calendarWidget-body-wrapper-fade-down
diff --git a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
index 1698fb196505..7e7b8b0a6ca1 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryMultiselectWidget.js
@@ -88,7 +88,7 @@
*/
mw.widgets.CategoryMultiselectWidget.prototype.updateMenuItems = function () {
this.getMenu().clearItems();
- this.getNewMenuItems( this.input.$input.val() ).then( function ( items ) {
+ this.getNewMenuItems( this.input.$input.val() ).then( ( items ) => {
const menu = this.getMenu();
// Never show the menu if the input lost focus in the meantime
@@ -97,25 +97,19 @@
}
// Array of strings of the data of OO.ui.MenuOptionsWidgets
- const existingItems = menu.getItems().map( function ( item ) {
- return item.data;
- } );
+ const existingItems = menu.getItems().map( ( item ) => item.data );
// Remove if items' data already exists
- let filteredItems = items.filter( function ( item ) {
- return existingItems.indexOf( item ) === -1;
- } );
+ let filteredItems = items.filter( ( item ) => existingItems.indexOf( item ) === -1 );
// Map to an array of OO.ui.MenuOptionWidgets
- filteredItems = filteredItems.map( function ( item ) {
- return new OO.ui.MenuOptionWidget( {
- data: item,
- label: item
- } );
- } );
+ filteredItems = filteredItems.map( ( item ) => new OO.ui.MenuOptionWidget( {
+ data: item,
+ label: item
+ } ) );
menu.addItems( filteredItems ).toggle( true );
- }.bind( this ) );
+ } );
};
/**
@@ -152,27 +146,19 @@
this.pushPending();
- $.when.apply( $, promises ).done( function ( ...dataSets ) {
+ $.when.apply( $, promises ).done( ( ...dataSets ) => {
// Flatten array
const allData = Array.prototype.concat.apply( [], dataSets );
const categoryNames = allData
// Remove duplicates
- .filter( function ( value, index, self ) {
- return self.indexOf( value ) === index;
- } )
+ .filter( ( value, index, self ) => self.indexOf( value ) === index )
// Get Title objects
- .map( function ( name ) {
- return mw.Title.newFromText( name );
- } )
+ .map( ( name ) => mw.Title.newFromText( name ) )
// Keep only titles from 'Category' namespace
- .filter( function ( title ) {
- return title && title.getNamespaceId() === NS_CATEGORY;
- } )
+ .filter( ( title ) => title && title.getNamespaceId() === NS_CATEGORY )
// Convert back to strings, strip 'Category:' prefix
- .map( function ( title ) {
- return title.getMainText();
- } );
+ .map( ( title ) => title.getMainText() );
deferred.resolve( categoryNames );
@@ -229,9 +215,7 @@
const searchTypeEnumCount = Object.keys( mw.widgets.CategoryMultiselectWidget.SearchType ).length;
// Check if all values are in the SearchType enum
- validSearchTypes = this.searchTypes.every( function ( searchType ) {
- return searchType > -1 && searchType < searchTypeEnumCount;
- } );
+ validSearchTypes = this.searchTypes.every( ( searchType ) => searchType > -1 && searchType < searchTypeEnumCount );
if ( validSearchTypes === false ) {
throw new Error( 'Unknown searchType in searchTypes' );
@@ -292,7 +276,7 @@
namespace: NS_CATEGORY,
limit: this.limit,
search: input
- } ).done( function ( res ) {
+ } ).done( ( res ) => {
const categories = res[ 1 ];
deferred.resolve( categories );
} ).fail( deferred.reject.bind( deferred ) );
@@ -307,10 +291,8 @@
aplimit: this.limit,
apfrom: input,
apprefix: input
- } ).done( function ( res ) {
- const categories = res.query.allpages.map( function ( page ) {
- return page.title;
- } );
+ } ).done( ( res ) => {
+ const categories = res.query.allpages.map( ( page ) => page.title );
deferred.resolve( categories );
} ).fail( deferred.reject.bind( deferred ) );
break;
@@ -326,10 +308,10 @@
action: 'query',
prop: 'info',
titles: 'Category:' + input
- } ).done( function ( res ) {
+ } ).done( ( res ) => {
const categories = [];
- res.query.pages.forEach( function ( page ) {
+ res.query.pages.forEach( ( page ) => {
if ( !page.missing ) {
categories.push( page.title );
}
@@ -352,10 +334,8 @@
cmtype: 'subcat',
cmlimit: this.limit,
cmtitle: 'Category:' + input
- } ).done( function ( res ) {
- const categories = res.query.categorymembers.map( function ( category ) {
- return category.title;
- } );
+ } ).done( ( res ) => {
+ const categories = res.query.categorymembers.map( ( category ) => category.title );
deferred.resolve( categories );
} ).fail( deferred.reject.bind( deferred ) );
break;
@@ -372,14 +352,12 @@
prop: 'categories',
cllimit: this.limit,
titles: 'Category:' + input
- } ).done( function ( res ) {
+ } ).done( ( res ) => {
const categories = [];
- res.query.pages.forEach( function ( page ) {
+ res.query.pages.forEach( ( page ) => {
if ( !page.missing && Array.isArray( page.categories ) ) {
- categories.push.apply( categories, page.categories.map( function ( category ) {
- return category.title;
- } ) );
+ categories.push.apply( categories, page.categories.map( ( category ) => category.title ) );
}
} );
diff --git a/resources/src/mediawiki.widgets/mw.widgets.CategoryTagItemWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CategoryTagItemWidget.js
index 9f760302149e..62a3c16d66b0 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.CategoryTagItemWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.CategoryTagItemWidget.js
@@ -30,7 +30,7 @@
const cache = this;
if ( this.currentRequest ) {
// Don't fire off a million requests at the same time
- this.currentRequest.always( function () {
+ this.currentRequest.always( () => {
cache.currentRequest = null;
cache.processExistenceCheckQueueDebounced();
} );
@@ -38,7 +38,7 @@
}
const queue = this.existenceCheckQueue;
this.existenceCheckQueue = {};
- const titles = Object.keys( queue ).filter( function ( title ) {
+ const titles = Object.keys( queue ).filter( ( title ) => {
if ( hasOwn.call( cache.existenceCache, title ) ) {
queue[ title ].resolve( cache.existenceCache[ title ] );
}
@@ -52,17 +52,17 @@
action: 'query',
prop: [ 'info' ],
titles: titles
- } ).done( function ( response ) {
+ } ).done( ( response ) => {
const
normalized = {},
pages = {};
- ( response.query.normalized || [] ).forEach( function ( data ) {
+ ( response.query.normalized || [] ).forEach( ( data ) => {
normalized[ data.fromencoded ? decodeURIComponent( data.from ) : data.from ] = data.to;
} );
- response.query.pages.forEach( function ( page ) {
+ response.query.pages.forEach( ( page ) => {
pages[ page.title ] = !page.missing;
} );
- titles.forEach( function ( title ) {
+ titles.forEach( ( title ) => {
let normalizedTitle = title;
while ( hasOwn.call( normalized, normalizedTitle ) ) {
normalizedTitle = normalized[ normalizedTitle ];
@@ -138,7 +138,7 @@
this.$link = $( '<a>' )
.text( this.label )
.attr( 'target', '_blank' )
- .on( 'click', function ( e ) {
+ .on( 'click', ( e ) => {
// TagMultiselectWidget really wants to prevent you from clicking the link, don't let it
e.stopPropagation();
} );
@@ -154,7 +154,7 @@
}
this.constructor.static.pageExistenceCaches[ this.apiUrl ]
.checkPageExistence( new ForeignTitle( this.title.getPrefixedText() ) )
- .done( function ( exists ) {
+ .done( ( exists ) => {
widget.setMissing( !exists );
} );
};
diff --git a/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js b/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js
index b8e85210d449..afe99fbe6539 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.CheckMatrixWidget.js
@@ -44,7 +44,7 @@
// Iterate over the columns object (ignore the value)
// eslint-disable-next-line no-jquery/no-each-util
- $.each( this.columns, function ( columnLabel ) {
+ $.each( this.columns, ( columnLabel ) => {
$headRow.append( $( '<th>' ).html( columnLabel ) );
} );
const $thead = $( '<thead>' );
@@ -53,7 +53,7 @@
const $tbody = $( '<tbody>' );
// Build table
// eslint-disable-next-line no-jquery/no-each-util
- $.each( this.rows, function ( rowLabel, rowTag ) {
+ $.each( this.rows, ( rowLabel, rowTag ) => {
const $row = $( '<tr>' ),
labelField = new OO.ui.FieldLayout(
new OO.ui.Widget(), // Empty widget, since we don't have the checkboxes here
@@ -70,7 +70,7 @@
// Columns
// eslint-disable-next-line no-jquery/no-each-util
- $.each( widget.columns, function ( columnLabel, columnTag ) {
+ $.each( widget.columns, ( columnLabel, columnTag ) => {
const thisTag = columnTag + '-' + rowTag,
checkbox = new OO.ui.CheckboxInputWidget( {
value: thisTag,
@@ -149,7 +149,7 @@
if ( this.checkboxes ) {
// Propagate to all checkboxes and update their disabled state
// eslint-disable-next-line no-jquery/no-each-util
- $.each( this.checkboxes, function ( name, checkbox ) {
+ $.each( this.checkboxes, ( name, checkbox ) => {
checkbox.setDisabled( widget.isTagDisabled( name ) );
} );
}
diff --git a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js
index 00952e0b2bd0..327277fc7131 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.DateInputWidget.js
@@ -203,7 +203,7 @@
$overlay.append( this.calendar.$element );
// The text input and calendar are not in DOM order, so fix up focus transitions.
- this.textInput.$input.on( 'keydown', function ( e ) {
+ this.textInput.$input.on( 'keydown', ( e ) => {
if ( e.which === OO.ui.Keys.TAB ) {
if ( e.shiftKey ) {
// Tabbing backward from text input: normal browser behavior
@@ -213,8 +213,8 @@
return false;
}
}
- }.bind( this ) );
- this.calendar.$element.on( 'keydown', function ( e ) {
+ } );
+ this.calendar.$element.on( 'keydown', ( e ) => {
if ( e.which === OO.ui.Keys.TAB ) {
if ( e.shiftKey ) {
// Tabbing backward from calendar: just focus the text input
@@ -226,7 +226,7 @@
this.textInput.$input.trigger( 'focus' );
}
}
- }.bind( this ) );
+ } );
}
// Set handle label and hide stuff
@@ -342,7 +342,7 @@
*/
mw.widgets.DateInputWidget.prototype.onBlur = function () {
const widget = this;
- setTimeout( function () {
+ setTimeout( () => {
const $focussed = $( ':focus' );
// Deactivate unless the focus moved to something else inside this widget
if (
@@ -687,9 +687,9 @@
if ( isValid !== undefined ) {
setFlag( isValid );
} else {
- this.getValidity().then( function () {
+ this.getValidity().then( () => {
setFlag( true );
- }, function () {
+ }, () => {
setFlag( false );
} );
}
diff --git a/resources/src/mediawiki.widgets/mw.widgets.ExpiryInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.ExpiryInputWidget.js
index 00390ae93c76..448d634de060 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.ExpiryInputWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.ExpiryInputWidget.js
@@ -56,7 +56,7 @@
// Events
// Toggle the visible inputs.
- this.inputSwitch.on( 'choose', function ( event ) {
+ this.inputSwitch.on( 'choose', ( event ) => {
switch ( event.getData() ) {
case 'date':
this.dateTimeField.toggle( true );
@@ -67,11 +67,11 @@
this.relativeField.toggle( true );
break;
}
- }.bind( this ) );
+ } );
// When the date time field update, update the relative
// field.
- this.dateTimeField.on( 'change', function ( value ) {
+ this.dateTimeField.on( 'change', ( value ) => {
// Do not alter the visible input.
if ( this.relativeField.isVisible() ) {
return;
@@ -92,11 +92,11 @@
// Set the relative field value. The field only accepts English strings.
this.relativeField.setValue( datetime.utc().locale( 'en' ).format( RFC2822 ) );
- }.bind( this ) );
+ } );
// When the relative field update, update the date time field if it's a
// value that moment understands.
- this.relativeField.on( 'change', function ( event ) {
+ this.relativeField.on( 'change', ( event ) => {
// Emit a change event for this widget.
this.emit( 'change', event );
@@ -114,7 +114,7 @@
} else {
this.dateTimeField.setValue( undefined );
}
- }.bind( this ) );
+ } );
// Initialization
this.$element
diff --git a/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js
index 0515d7a78a69..d4ca8120ed60 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.NamespaceInputWidget.js
@@ -59,7 +59,7 @@
mw.config.get( 'wgFormattedNamespaces' );
// eslint-disable-next-line no-jquery/no-map-util
- const options = $.map( namespaces, function ( name, ns ) {
+ const options = $.map( namespaces, ( name, ns ) => {
if ( ns < mainNamespace || exclude.indexOf( Number( ns ) ) !== -1 ) {
return null; // skip
}
@@ -68,10 +68,10 @@
name = mw.msg( 'blanknamespace' );
}
return { data: ns, label: name };
- } ).sort( function ( a, b ) {
+ } ).sort(
// wgFormattedNamespaces is an object, and so technically doesn't have to be ordered
- return a.data - b.data;
- } );
+ ( a, b ) => a.data - b.data
+ );
if ( config.includeAllValue !== null && config.includeAllValue !== undefined ) {
options.unshift( {
diff --git a/resources/src/mediawiki.widgets/mw.widgets.NamespacesMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.NamespacesMultiselectWidget.js
index ffe7264114d3..a14909b33c7c 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.NamespacesMultiselectWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.NamespacesMultiselectWidget.js
@@ -42,12 +42,10 @@
},
config,
{
- selected: config && config.selected ? config.selected.map( function ( id ) {
- return {
- data: id,
- label: namespaces[ id ]
- };
- } ) : undefined
+ selected: config && config.selected ? config.selected.map( ( id ) => ( {
+ data: id,
+ label: namespaces[ id ]
+ } ) ) : undefined
}
) );
@@ -65,17 +63,13 @@
.appendTo( this.$element );
// Update with preset values
// Set the default value (it might be different from just being empty)
- this.$hiddenInput.prop( 'defaultValue', this.getItems().map( function ( item ) {
- return item.getData();
- } ).join( '\n' ) );
- this.on( 'change', function ( items ) {
- this.$hiddenInput.val( items.map( function ( item ) {
- return item.getData();
- } ).join( '\n' ) );
+ this.$hiddenInput.prop( 'defaultValue', this.getItems().map( ( item ) => item.getData() ).join( '\n' ) );
+ this.on( 'change', ( items ) => {
+ this.$hiddenInput.val( items.map( ( item ) => item.getData() ).join( '\n' ) );
// Trigger a 'change' event as if a user edited the text
// (it is not triggered when changing the value from JS code).
this.$hiddenInput.trigger( 'change' );
- }.bind( this ) );
+ } );
}
};
diff --git a/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js
index a91d9dbe5adf..952f3f6528af 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js
@@ -51,7 +51,7 @@
}
this.setLookupsDisabled( !this.suggestions );
- $form.on( 'submit', function () {
+ $form.on( 'submit', () => {
mw.track( 'mw.widgets.SearchInputWidget', {
action: 'submit-form',
numberOfResults: this.lastLookupItems.length,
@@ -61,7 +61,7 @@
this.$input.val()
)
} );
- }.bind( this ) );
+ } );
this.connect( this, {
change: 'onChange'
@@ -153,10 +153,10 @@
} );
// reuse the searchSuggest function from mw.searchSuggest
- const promise = mw.searchSuggest.request( api, this.getQueryValue(), function () {}, this.limit, this.getNamespace() );
+ const promise = mw.searchSuggest.request( api, this.getQueryValue(), () => {}, this.limit, this.getNamespace() );
// tracking purposes
- promise.done( function ( data, jqXHR ) {
+ promise.done( ( data, jqXHR ) => {
self.requestType = jqXHR.getResponseHeader( 'X-OpenSearch-Type' );
self.searchId = jqXHR.getResponseHeader( 'X-Search-ID' );
} );
@@ -195,7 +195,7 @@
self = this;
// eslint-disable-next-line no-jquery/no-each-util
- $.each( titles, function ( i, result ) {
+ $.each( titles, ( i, result ) => {
items.push( new mw.widgets.TitleOptionWidget(
self.getOptionWidgetData(
result,
@@ -245,9 +245,7 @@
this, arguments
);
- this.lastLookupItems = items.map( function ( item ) {
- return item.data;
- } );
+ this.lastLookupItems = items.map( ( item ) => item.data );
return items;
};
diff --git a/resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js
index 3d396555322d..5c611fca18b1 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.SelectWithInputWidget.js
@@ -54,9 +54,9 @@
// Events
this.dropdowninput.on( 'change', this.onChange.bind( this ) );
- this.textinput.on( 'change', function () {
+ this.textinput.on( 'change', () => {
this.emit( 'change', this.getValue() );
- }.bind( this ) );
+ } );
// Parent constructor
mw.widgets.SelectWithInputWidget.super.call( this, config );
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
index 2cfd4b37083e..9a3a738fdd78 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleInputWidget.js
@@ -135,7 +135,7 @@
// Parent method
value = mw.widgets.TitleInputWidget.super.prototype.cleanUpValue.call( this, value );
- return trimByteLength( this.value, value, this.maxLength, function ( val ) {
+ return trimByteLength( this.value, value, this.maxLength, ( val ) => {
const title = widget.getMWTitle( val );
return title ? title.getMain() : val;
} ).newVal;
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js
index 6db6a698ec24..5e51aae682e9 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleOptionWidget.js
@@ -65,7 +65,7 @@
this.$label.attr( 'tabindex', '-1' );
// Allow opening the link in new tab, but not regular navigation.
- this.$label.on( 'click', function ( e ) {
+ this.$label.on( 'click', ( e ) => {
// Don't interfere with special clicks (e.g. to open in new tab)
if ( !( e.which !== 1 || e.altKey || e.ctrlKey || e.shiftKey || e.metaKey ) ) {
e.preventDefault();
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js
index 1af740289099..29e772fab40f 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleSearchWidget.js
@@ -77,7 +77,7 @@
mw.widgets.TitleSearchWidget.prototype.onQueryChange = function () {
const widget = this;
- this.getRequestData().done( function ( data ) {
+ this.getRequestData().done( ( data ) => {
if ( widget.query.isReadOnly() ) {
// The request object is always abortable, so just
// prevent the results from displaying
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
index 9e771630e013..9163ce107906 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitleWidget.js
@@ -132,11 +132,7 @@
smaxage: 60 * 60 * 24,
// Workaround T97096 by setting uselang=content
uselang: 'content'
- } ).then( function ( data ) {
- return data.query.interwikimap.map( function ( interwiki ) {
- return interwiki.prefix;
- } );
- } );
+ } ).then( ( data ) => data.query.interwikimap.map( ( interwiki ) => interwiki.prefix ) );
}
return cache[ key ];
};
@@ -165,12 +161,10 @@
return fragment.toLowerCase().replace( /_/g, ' ' );
}
- return this.sectionsCache[ normalizedTitleText ].then( function ( response ) {
+ return this.sectionsCache[ normalizedTitleText ].then( ( response ) => {
const sections = OO.getProp( response, 'parse', 'sections' ) || [];
const normalizedFragmentQuery = normalizeFragment( fragmentQuery );
- const results = sections.filter( function ( section ) {
- return normalizeFragment( section.line ).indexOf( normalizedFragmentQuery ) !== -1;
- } ).map( function ( section ) {
+ const results = sections.filter( ( section ) => normalizeFragment( section.line ).indexOf( normalizedFragmentQuery ) !== -1 ).map( ( section ) => {
const fragment = section.linkAnchor.replace( /_/g, ' ' );
// TODO: Make promise abortable
return {
@@ -184,9 +178,7 @@
};
} );
// Sorting also happens later, but we need to do it now before we truncate
- results.sort( function ( a, b ) {
- return a.index - b.index;
- } );
+ results.sort( ( a, b ) => a.index - b.index );
// Fake query result
return {
query: {
@@ -223,7 +215,7 @@
return $.Deferred().resolve( {} ).promise( promiseAbortObject );
}
- return this.getInterwikiPrefixesPromise().then( function ( interwikiPrefixes ) {
+ return this.getInterwikiPrefixesPromise().then( ( interwikiPrefixes ) => {
// Optimization: check we have any prefixes.
if ( interwikiPrefixes.length ) {
const interwiki = query.slice( 0, Math.max( 0, query.indexOf( ':' ) ) );
@@ -243,7 +235,7 @@
// Not a interwiki: do a prefix-search API lookup of the query.
const prefixSearchRequest = api.get( widget.getApiParams( query ) );
promiseAbortObject.abort = prefixSearchRequest.abort.bind( prefixSearchRequest ); // TODO ew
- return prefixSearchRequest.then( function ( prefixSearchResponse ) {
+ return prefixSearchRequest.then( ( prefixSearchResponse ) => {
if ( !widget.showMissing ) {
return prefixSearchResponse;
}
@@ -254,7 +246,7 @@
titles: title ? title.getPrefixedDb() : query
} );
promiseAbortObject.abort = queryTitleRequest.abort.bind( queryTitleRequest );
- return queryTitleRequest.then( function ( queryTitleResponse ) {
+ return queryTitleRequest.then( ( queryTitleResponse ) => {
// By default, return the prefix-search result.
const result = prefixSearchResponse;
if ( prefixSearchResponse.query === undefined ) {
@@ -416,9 +408,7 @@
}
}
- titles.sort( function ( a, b ) {
- return pageData[ a ].index - pageData[ b ].index;
- } );
+ titles.sort( ( a, b ) => pageData[ a ].index - pageData[ b ].index );
// If not found, run value through mw.Title to avoid treating a match as a
// mismatch where normalisation would make them matching (T50476)
diff --git a/resources/src/mediawiki.widgets/mw.widgets.TitlesMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.TitlesMultiselectWidget.js
index e6dea44bf0a0..e3e4eb4a263f 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.TitlesMultiselectWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.TitlesMultiselectWidget.js
@@ -64,17 +64,13 @@
.appendTo( this.$element );
// Update with preset values
// Set the default value (it might be different from just being empty)
- this.$hiddenInput.prop( 'defaultValue', this.getItems().map( function ( item ) {
- return item.getData();
- } ).join( '\n' ) );
- this.on( 'change', function ( items ) {
- this.$hiddenInput.val( items.map( function ( item ) {
- return item.getData();
- } ).join( '\n' ) );
+ this.$hiddenInput.prop( 'defaultValue', this.getItems().map( ( item ) => item.getData() ).join( '\n' ) );
+ this.on( 'change', ( items ) => {
+ this.$hiddenInput.val( items.map( ( item ) => item.getData() ).join( '\n' ) );
// Trigger a 'change' event as if a user edited the text
// (it is not triggered when changing the value from JS code).
this.$hiddenInput.trigger( 'change' );
- }.bind( this ) );
+ } );
}
};
@@ -99,11 +95,11 @@
const widget = this;
this.getRequestData()
- .then( function ( data ) {
+ .then( ( data ) => {
// Reset
widget.menu.clearItems();
widget.menu.addItems( widget.getOptionsFromData( data ) );
- } ).always( function () {
+ } ).always( () => {
// Parent method
mw.widgets.TitlesMultiselectWidget.super.prototype.onInputChange.call( widget );
} );
diff --git a/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js b/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js
index bd41636eca96..5c0a56d04823 100644
--- a/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js
+++ b/resources/src/mediawiki.widgets/mw.widgets.UsersMultiselectWidget.js
@@ -139,13 +139,13 @@
list: 'allusers',
auprefix: inputValue,
aulimit: this.limit
- } ).done( function ( response ) {
+ } ).done( ( response ) => {
let suggestions = response.query.allusers;
const selected = this.getSelectedUsernames();
// Remove usernames, which are already selected from suggestions
- suggestions = suggestions.map( function ( user ) {
+ suggestions = suggestions.map( ( user ) => {
if ( selected.indexOf( user.name ) === -1 ) {
return new OO.ui.MenuOptionWidget( {
data: user.name,
@@ -154,9 +154,7 @@
} );
}
return undefined;
- } ).filter( function ( item ) {
- return item !== undefined;
- } );
+ } ).filter( ( item ) => item !== undefined );
// Remove all items from menu add fill it with new
this.menu.clearItems();
@@ -171,7 +169,7 @@
this.menu.toggle( true );
this.popPending();
- }.bind( this ) ).fail( this.popPending.bind( this ) );
+ } ).fail( this.popPending.bind( this ) );
}
} else {