Merge "resources: Strip '$' and 'mw' from file closures"
[lhc/web/wiklou.git] / resources / src / mediawiki.htmlform / autocomplete.js
1 /*
2 * HTMLForm enhancements:
3 * Set up autocomplete fields.
4 */
5 ( function () {
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 $el.data( 'autocomplete' ).filter( function ( v ) {
16 return v.indexOf( val ) === 0;
17 } )
18 );
19 }
20 } );
21 } );
22 }
23 } );
24
25 }() );