summaryrefslogtreecommitdiff
path: root/www/wiki/resources/src/mediawiki.special/mediawiki.special.edittags.js
blob: 4f51e9b761aa614f38bfe3be34dbc5109558451b (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
30
31
32
33
34
35
36
37
38
/*!
 * JavaScript for Special:EditTags
 */
( function ( mw, $ ) {
	$( function () {
		var summaryCodePointLimit = mw.config.get( 'wgCommentCodePointLimit' ),
			summaryByteLimit = mw.config.get( 'wgCommentByteLimit' ),
			$wpReason = $( '#wpReason' ),
			$tagList = $( '#mw-edittags-tag-list' );

		if ( $tagList.length ) {
			$tagList.chosen( {
				/* eslint-disable camelcase */
				placeholder_text_multiple: mw.msg( 'tags-edit-chosen-placeholder' ),
				no_results_text: mw.msg( 'tags-edit-chosen-no-results' )
				/* eslint-enable camelcase */
			} );
		}

		$( '#mw-edittags-remove-all' ).on( 'change', function ( e ) {
			$( '.mw-edittags-remove-checkbox' ).prop( 'checked', e.target.checked );
		} );
		$( '.mw-edittags-remove-checkbox' ).on( 'change', function ( e ) {
			if ( !e.target.checked ) {
				$( '#mw-edittags-remove-all' ).prop( 'checked', false );
			}
		} );

		// Limit to bytes or UTF-8 codepoints, depending on MediaWiki's configuration
		// use maxLength because it's leaving room for log entry text.
		if ( summaryCodePointLimit ) {
			$wpReason.codePointLimit();
		} else if ( summaryByteLimit ) {
			$wpReason.byteLimit();
		}
	} );

}( mediaWiki, jQuery ) );