4854ff4abfc015bb3672d4014ea85d89fadfc0e6
[lhc/web/wiklou.git] / resources / mediawiki.special / mediawiki.special.recentchanges.js
1 /* JavaScript for Special:RecentChanges */
2 ( function( $ ) {
3
4 var checkboxes = [ 'nsassociated', 'nsinvert' ];
5
6 /**
7 * @var select {jQuery}
8 */
9 var $select = null;
10
11 var rc = mw.special.recentchanges = {
12
13 /**
14 * Handler to disable/enable the namespace selector checkboxes when the
15 * special 'all' namespace is selected/unselected respectively.
16 */
17 updateCheckboxes: function() {
18 // The 'all' namespace is the FIRST in the list.
19 var isAllNS = $select.find( 'option' ).first().is( ':selected' );
20
21 // Iterates over checkboxes and propagate the selected option
22 $.each( checkboxes, function( i, id ) {
23 $( '#' + id ).attr( 'disabled', isAllNS );
24 });
25 },
26
27 init: function() {
28 // Populate & bind
29 $select = $( '#namespace' ).change( rc.updateCheckboxes );
30
31 // Trigger once set the initial statuses of the checkboxes.
32 $select.change();
33 }
34 };
35
36 // Run when document is ready
37 $( rc.init );
38
39 })( jQuery );