summaryrefslogtreecommitdiff
path: root/www/wiki/resources/src/mediawiki.special/mediawiki.special.userrights.js
blob: 487e63a67d0978af0aa5826355598218d98e8513 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*!
 * JavaScript for Special:UserRights
 */
( function ( mw, $ ) {
	var convertmessagebox = require( 'mediawiki.notification.convertmessagebox' ),
		summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
		summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
		$wpReason = $( '#wpReason' );

	// Replace successbox with notifications
	convertmessagebox();

	// Dynamically show/hide the "other time" input under each dropdown
	$( '.mw-userrights-nested select' ).on( 'change', function ( e ) {
		$( e.target.parentNode ).find( 'input' ).toggle( $( e.target ).val() === 'other' );
	} );

	// Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration
	if ( summaryCodePointLimit ) {
		$wpReason.codePointLimit( summaryCodePointLimit );
	} else if ( summaryByteLimit ) {
		$wpReason.byteLimit( summaryByteLimit );
	}

}( mediaWiki, jQuery ) );