SpecialPageLanguage: Redirect to redirect by adding redirect=no
[lhc/web/wiklou.git] / resources / src / mediawiki / mediawiki.reasonSuggest.js
1 /*!
2 * Add autocomplete suggestions for action forms reasons.
3 */
4 ( function ( mw, $ ) {
5 $( function () {
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' ) ] )
9 .done( function () {
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 );
13 } );
14
15 // Add relevant suggestion
16 $( '#mwProtect-reason, #wpReason, #mw-input-wpReason-other' ).suggestions( {
17 fetch: function () {
18 var $this = $( this ), relevantSuggestions;
19 relevantSuggestions = $.grep( reasons, function ( reason ) {
20 return ( reason.toLowerCase().indexOf( $this.val().toLowerCase() ) > -1 );
21 } );
22 $this.suggestions( 'suggestions', relevantSuggestions );
23 },
24 highlightInput: true
25 } );
26 } );
27 }( mediaWiki, jQuery ) );