/* JavaScript for Special:RecentChanges */
-( function( $, mw ) {
-
-mw.special.recentchanges = {
- // -- Variables
- 'select' : false,
- 'checkboxes' : [ 'nsassociated', 'nsinvert' ],
-
- // -- Methods
- 'init' : function() {
- this.select = $( 'select#namespace' );
-
- // Register an onChange trigger for the <select> element
- this.select.change( function() {
- mw.special.recentchanges.updateCheckboxes();
- });
- // on load, trigger the event to eventually update checkboxes statuses
- this.select.change();
- },
-
+( function ( mw, $ ) {
+
+ var checkboxes = [ 'nsassociated', 'nsinvert' ];
+
/**
- * handler to disable/enable the namespace selector checkboxes when the
- * special 'all' namespace is selected/unselected respectively.
+ * @var select {jQuery}
*/
- 'updateCheckboxes' : function() {
- // The 'all' namespace is the FIRST in the list.
- var isAllNS = this.select.find( 'option' ).first().is( ':selected' );
+ 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' );
- // Iterates over checkboxes and propagate the selected option
- $.map( this.checkboxes, function(id) {
- $( 'input#'+id ).attr( 'disabled', isAllNS );
- });
- },
-};
+ // Bind to change event, and trigger once to set the initial state of the checkboxes.
+ $select.change( rc.updateCheckboxes ).change();
+ }
+ };
-mw.special.recentchanges.init();
+ // Run when document is ready
+ $( rc.init );
-}(jQuery, mediaWiki ) );
+}( mediaWiki, jQuery ) );