Merge "Make sure that SQLite uses no prefix"
[lhc/web/wiklou.git] / resources / mediawiki.special / mediawiki.special.recentchanges.js
index 294417c..3cba9d3 100644 (file)
@@ -1,40 +1,37 @@
-/* JavaScript for Special:RecentChanges */
-( function( $ ) {
+/**
+ * JavaScript for Special:RecentChanges
+ */
+( function ( mw, $ ) {
+       var rc,
+               $checkboxes,
+               $select;
 
-       var checkboxes = [ 'nsassociated', 'nsinvert' ];
-
-       mw.special.recentchanges = {
+       rc = {
 
-               /**
-                * @var select {jQuery}
-                */
-               $select: null,
-
-               init: function() {
-                       var rc = this;
-
-                       rc.$select = 
-                               $( 'select#namespace' )
-                                       .change( rc.updateCheckboxes )
-                                       // Trigger once set the initial statuses of the checkboxes.
-                                       .change();
-               },
-       
                /**
                 * 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 = mw.special.recentchanges.$select.find( 'option' ).first().is( ':selected' );
+               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
-                       $.map( checkboxes, function( id ) {
-                               $( '#'+id ).attr( 'disabled', isAllNS );
-                       });
+                       $checkboxes.prop( 'disabled', isAllNS );
                },
+
+               init: function () {
+                       $select = $( '#namespace' );
+                       $checkboxes = $( '#nsassociated, #nsinvert' );
+
+                       // Bind to change event, and trigger once to set the initial state of the checkboxes.
+                       rc.updateCheckboxes();
+                       $select.change( rc.updateCheckboxes );
+               }
        };
 
-       mw.special.recentchanges.init();
+       $( rc.init );
+
+       mw.special.recentchanges = rc;
 
-})( jQuery );
+}( mediaWiki, jQuery ) );