X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki%2Fmediawiki.htmlform.js;h=594800e15db8260d1e130e3109ba230a27981600;hb=4060f43b43fa63d0084964ed68bbf279fff51443;hp=5027f7a01699663a4e0dc03d4d81973797c637fa;hpb=ab1b1b55fe49316515f7ae876bd6f76592247dad;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki/mediawiki.htmlform.js b/resources/src/mediawiki/mediawiki.htmlform.js index 5027f7a016..594800e15d 100644 --- a/resources/src/mediawiki/mediawiki.htmlform.js +++ b/resources/src/mediawiki/mediawiki.htmlform.js @@ -237,6 +237,7 @@ } ); function enhance( $root ) { + var $matrixTooltips, $autocomplete; /** * @ignore @@ -342,13 +343,30 @@ } ); } - var $matrixTooltips = $root.find( '.mw-htmlform-matrix .mw-htmlform-tooltip' ); + $matrixTooltips = $root.find( '.mw-htmlform-matrix .mw-htmlform-tooltip' ); if ( $matrixTooltips.length ) { mw.loader.using( 'jquery.tipsy', function () { $matrixTooltips.tipsy( { gravity: 's' } ); } ); } + // Set up autocomplete fields + $autocomplete = $root.find( '.mw-htmlform-autocomplete' ); + if ( $autocomplete.length ) { + mw.loader.using( 'jquery.suggestions', function () { + $autocomplete.suggestions( { + fetch: function ( val ) { + var $el = $( this ); + $el.suggestions( 'suggestions', + $.grep( $el.data( 'autocomplete' ), function ( v ) { + return v.indexOf( val ) === 0; + } ) + ); + } + } ); + } ); + } + // Add/remove cloner clones without having to resubmit the form $root.find( '.mw-htmlform-cloner-delete-button' ).click( function ( ev ) { ev.preventDefault();