Localisation updates from https://translatewiki.net.
[mediawiki.git] / resources / src / mediawiki.htmlform / autocomplete.js
blob18e417896ae84db17f0b5d51ba56b4dd4bdd417e
1 /*
2  * HTMLForm enhancements:
3  * Set up autocomplete fields.
4  */
5 mw.hook( 'htmlform.enhance' ).add( ( $root ) => {
6         const $autocomplete = $root.find( '.mw-htmlform-autocomplete' );
7         if ( $autocomplete.length ) {
8                 mw.loader.using( 'jquery.suggestions', () => {
9                         $autocomplete.suggestions( {
10                                 fetch: function ( val ) {
11                                         const $el = $( this );
12                                         $el.suggestions( 'suggestions',
13                                                 $el.data( 'autocomplete' ).filter( ( v ) => v.indexOf( val ) === 0 )
14                                         );
15                                 }
16                         } );
17                 } );
18         }
19 } );