Merge "resourceloader: Remove support for $context === null in getContentObj"
[lhc/web/wiklou.git] / resources / src / mediawiki.special.recentchanges.js
1 /*!
2 * JavaScript for Special:RecentChanges
3 */
4 ( function () {
5 var rc, $checkboxes, $select, namespaceDropdown;
6
7 /**
8 * @class mw.special.recentchanges
9 * @singleton
10 */
11 rc = {
12 /**
13 * Handler to hide/show the namespace selector checkboxes when the
14 * special 'all' namespace is selected/unselected respectively.
15 */
16 updateCheckboxes: function () {
17 // The option element for the 'all' namespace has an empty value
18 var value = $select.val(),
19 isAllNS = value === 'all' || value === '';
20
21 // Iterates over checkboxes and propagate the selected option
22 $checkboxes.toggleClass( 'mw-input-hidden', isAllNS );
23 },
24
25 init: function () {
26 $select = $( 'select#namespace' );
27 $checkboxes = $( '#nsassociated, #nsinvert, .contribs-ns-filters' )
28 .closest( '.mw-input-with-label' );
29
30 if ( $select.length === 0 ) {
31 $select = $( '#namespace select' );
32 if ( $select.length > 0 ) {
33 namespaceDropdown = OO.ui.infuse( $( '#namespace' ).closest( '[data-ooui]' ) );
34 namespaceDropdown.on( 'change', rc.updateCheckboxes );
35 }
36 } else {
37 // Bind to change event of the checkboxes.
38 // The initial state is already set in HTML.
39 $select.on( 'change', rc.updateCheckboxes );
40 }
41 }
42 };
43
44 $( rc.init );
45
46 module.exports = rc;
47
48 }() );