Merge "Update docs/hooks.txt for ShowSearchHitTitle"
[mediawiki.git] / resources / src / mediawiki / mediawiki.reasonSuggest.js
blob71efdb07f78a46291e119c29e1343e54afd25843
1 /*!
2 * Add autocomplete suggestions for action forms reasons.
3 */
4 ( function ( mw, $ ) {
5         $( function () {
6                 var reasons = mw.config.get( 'reasons' );
8                 // Add relevant suggestion
9                 $( '#mwProtect-reason, #wpReason, #mw-input-wpReason-other' ).suggestions( {
10                         fetch: function () {
11                                 var $this = $( this ), relevantSuggestions;
12                                 relevantSuggestions = $.grep( reasons, function ( reason ) {
13                                         return ( reason.toLowerCase().indexOf( $this.val().toLowerCase() ) > -1 );
14                                 } );
15                                 $this.suggestions( 'suggestions', relevantSuggestions );
16                         },
17                         highlightInput: true
18                 } );
19         } );
20 }( mediaWiki, jQuery ) );