Merge "Display "Printable version" links in toolbox on special pages"
[lhc/web/wiklou.git] / resources / mediawiki.special / mediawiki.special.recentchanges.js
index 4854ff4..d1c1354 100644 (file)
@@ -1,39 +1,34 @@
-/* JavaScript for Special:RecentChanges */
-( function( $ ) {
+/**
+ * JavaScript for Special:RecentChanges
+ */
+( function ( mw, $ ) {
+       var rc, $checkboxes, $select;
 
-       var checkboxes = [ 'nsassociated', 'nsinvert' ];
-
-       /**
-        * @var select {jQuery}
-        */
-       var $select = null;
-
-       var rc = mw.special.recentchanges = {
-       
+       rc = {
                /**
                 * Handler to disable/enable the namespace selector checkboxes when the
                 * special 'all' namespace is selected/unselected respectively.
                 */
-               updateCheckboxes: function() {
-                       // The 'all' namespace is the FIRST in the list.
-                       var isAllNS = $select.find( 'option' ).first().is( ':selected' );
+               updateCheckboxes: function () {
+                       // The option element for the 'all' namespace has an empty value
+                       var isAllNS = $select.val() === '';
 
                        // Iterates over checkboxes and propagate the selected option
-                       $.each( checkboxes, function( i, id ) {
-                               $( '#' + id ).attr( 'disabled', isAllNS );
-                       });
+                       $checkboxes.prop( 'disabled', isAllNS );
                },
 
-               init: function() {
-                       // Populate & bind
-                       $select = $( '#namespace' ).change( rc.updateCheckboxes );
+               init: function () {
+                       $select = $( '#namespace' );
+                       $checkboxes = $( '#nsassociated, #nsinvert' );
 
-                       // Trigger once set the initial statuses of the checkboxes.
-                       $select.change();
+                       // Bind to change event, and trigger once to set the initial state of the checkboxes.
+                       rc.updateCheckboxes();
+                       $select.change( rc.updateCheckboxes );
                }
        };
 
-       // Run when document is ready
-       $( rc.init );
+       $( document ).ready( rc.init );
+
+       mw.special.recentchanges = rc;
 
-})( jQuery );
+}( mediaWiki, jQuery ) );