2 * Add autocomplete suggestions for action forms reasons.
6 var api
= new mw
.Api(), reasons
= [];
7 // These messages can be really big, so its loaded on-the-go
8 api
.loadMessagesIfMissing( [ mw
.config
.get( 'reasons' ) ] )
10 // Convert from string to array, first index is unneeded
11 reasons
= mw
.msg( mw
.config
.get( 'reasons' ) ).split( '\n** ' );
12 reasons
.splice( 0, 1 );
15 // Add relevant suggestion
16 $( '#mwProtect-reason, #wpReason, #mw-input-wpReason-other' ).suggestions( {
18 var $this = $( this ), relevantSuggestions
;
19 relevantSuggestions
= $.grep( reasons
, function ( reason
) {
20 return ( reason
.toLowerCase().indexOf( $this.val().toLowerCase() ) > -1 );
22 $this.suggestions( 'suggestions', relevantSuggestions
);
27 }( mediaWiki
, jQuery
) );