summaryrefslogtreecommitdiff
path: root/resources/mediawiki.special/mediawiki.special.recentchanges.js
blob: 7996d935bdf0e6f50b27a1c23021285676b6f1b1 (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
39
/* JavaScript for Special:RecentChanges */
( function ( mw, $ ) {

	var checkboxes = [ 'nsassociated', 'nsinvert' ];

	/**
	 * @var select {jQuery}
	 */
	var $select = null;

	var rc = mw.special.recentchanges = {

		/**
		 * Handler to disable/enable the namespace selector checkboxes when the
		 * special 'all' namespace is selected/unselected respectively.
		 */
		updateCheckboxes: function () {
			// The option element for the 'all' namespace has an empty value
			var isAllNS = $select.find('option:selected').val() === '';

			// Iterates over checkboxes and propagate the selected option
			$.each( checkboxes, function ( i, id ) {
				$( '#' + id ).prop( 'disabled', isAllNS );
			});
		},

		init: function () {
			// Populate
			$select = $( '#namespace' );

			// Bind to change event, and trigger once to set the initial state of the checkboxes.
			$select.change( rc.updateCheckboxes ).change();
		}
	};

	// Run when document is ready
	$( rc.init );

}( mediaWiki, jQuery ) );