summaryrefslogtreecommitdiff
path: root/www/wiki/resources/src/mediawiki.special/mediawiki.special.revisionDelete.js
blob: cad9db0e9cf67a704e6ea19002acd1e941cff826 (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
26
27
28
29
/*!
 * JavaScript for Special:RevisionDelete
 */
( function ( mw, $ ) {
	var colonSeparator = mw.message( 'colon-separator' ).text(),
		summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
		summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
		$wpRevDeleteReasonList = $( '#wpRevDeleteReasonList' ),
		$wpReason = $( '#wpReason' ),
		filterFn = function ( input ) {
			// Should be built the same as in SpecialRevisionDelete::submit()
			var comment = $wpRevDeleteReasonList.val();
			if ( comment === 'other' ) {
				comment = input;
			} else if ( input !== '' ) {
				// Entry from drop down menu + additional comment
				comment += colonSeparator + input;
			}
			return comment;
		};

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

}( mediaWiki, jQuery ) );