]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - resources/src/mediawiki/htmlform/autocomplete.js
MediaWiki 1.30.2
[autoinstalls/mediawiki.git] / resources / src / mediawiki / htmlform / autocomplete.js
1 /*
2  * HTMLForm enhancements:
3  * Set up autocomplete fields.
4  */
5 ( function ( mw, $ ) {
6
7         mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
8                 var $autocomplete = $root.find( '.mw-htmlform-autocomplete' );
9                 if ( $autocomplete.length ) {
10                         mw.loader.using( 'jquery.suggestions', function () {
11                                 $autocomplete.suggestions( {
12                                         fetch: function ( val ) {
13                                                 var $el = $( this );
14                                                 $el.suggestions( 'suggestions',
15                                                         $.grep( $el.data( 'autocomplete' ), function ( v ) {
16                                                                 return v.indexOf( val ) === 0;
17                                                         } )
18                                                 );
19                                         }
20                                 } );
21                         } );
22                 }
23         } );
24
25 }( mediaWiki, jQuery ) );