Ticking 'Search in all namespaces' in prefs should disable other checkboxes
authortonythomas01 <01tonythomas@gmail.com>
Fri, 31 Jan 2014 18:51:35 +0000 (00:21 +0530)
committerBartosz Dziewoński <matma.rex@gmail.com>
Mon, 24 Feb 2014 14:46:55 +0000 (15:46 +0100)
Ticking 'Search in all namespaces' will disable all other checkboxes
below. They will regain their original state once it is unticked.

Bug: 60285
Change-Id: Ie62b9186e98dd770de4282ea57d7248158a6e782

resources/mediawiki.special/mediawiki.special.preferences.js

index 0078724..7f1fd43 100644 (file)
@@ -4,7 +4,8 @@
 jQuery( function ( $ ) {
        var $preftoc, $preferences, $fieldsets, $legends,
                hash, labelFunc,
-               $tzSelect, $tzTextbox, $localtimeHolder, servertime;
+               $tzSelect, $tzTextbox, $localtimeHolder, servertime,
+               $checkBoxes;
 
        labelFunc = function () {
                return this.id.replace( /^mw-prefsection/g, 'preftab' );
@@ -253,4 +254,18 @@ jQuery( function ( $ ) {
                        sessionStorage.setItem( 'mediawikiPreferencesTab', storageData );
                } );
        }
+
+       // To disable all 'namespace' checkboxes in Search preferences
+       // when 'Search in all namespaces' checkbox is ticked.
+       $checkBoxes = $( '#mw-htmlform-advancedsearchoptions input[id^=mw-input-wpsearchnamespaces]' );
+       if ( $( '#mw-input-wpsearcheverything' ).prop( 'checked' ) ) {
+               $checkBoxes.prop( 'disabled', true );
+       }
+       $( '#mw-input-wpsearcheverything' ).change( function () {
+               if ( $( this ).prop( 'checked' ) ) {
+                       $checkBoxes.prop( 'disabled', true );
+               } else {
+                       $checkBoxes.prop( 'disabled', false );
+               }
+       } );
 } );