Reverted r75832 per my comments on CR, unanswered for 19 days. Moving all help inform...
[mediawiki.git] / skins / common / config.js
blob10e53bb9faff3e1b3bca9a93415fb28ceb6ae29c
1 (function( $ ) {
2         $( document ).ready( function() {
3                 // Show/hide code for help text
4                 $( '.config-show-help a' ).click( function() {
5                         $(this).parent().siblings( '.config-help-message' ).show( 'slow' );
6                         $(this).parent().siblings( '.config-hide-help' ).show();
7                         $(this).parent().hide();
8                         return false;
9                 } );
10                 $( '.config-hide-help a' ).click( function() {
11                         $(this).parent().siblings( '.config-help-message' ).hide( 'slow' );
12                         $(this).parent().siblings( '.config-show-help' ).show();
13                         $(this).parent().hide();
14                         return false;
15                 } );
16                 
17                 // Show/hide code for DB-specific options
18                 // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here?
19                 $( '.dbRadio' ).each( function() { $( '#' + $(this).attr( 'rel' ) ).hide(); } );
20                 $( '#' + $( '.dbRadio:checked' ).attr( 'rel' ) ).show();
21                 $( '.dbRadio' ).click( function() {
22                         var $checked = $( '.dbRadio:checked' );
23                         var $wrapper = $( '#' + $checked.attr( 'rel' ) );
24                         if ( !$wrapper.is( ':visible' ) ) {
25                                 $( '.dbWrapper' ).hide( 'slow' );
26                                 $wrapper.show( 'slow' );
27                         }
28                 } );
29                 
30                 // Scroll to the bottom of upgrade log
31                 $( "#config-update-log" ).each( function() { this.scrollTop = this.scrollHeight; } );
32                 
33                 // Show/hide Creative Commons thingy
34                 $( '.licenseRadio' ).click( function() {
35                         var $wrapper = $( '#config-cc-wrapper' );
36                         if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
37                                 $wrapper.show( 'slow' );
38                         } else {
39                                 $wrapper.hide( 'slow' );
40                         }
41                 } );
42                 
43                 // Show/hide random stuff (email, upload)
44                 $( '.showHideRadio' ).click( function() {
45                         var $wrapper = $( '#' + $(this).attr( 'rel' ) );
46                         if ( $(this).is( ':checked' ) ) {
47                                 $wrapper.show( 'slow' );
48                         } else {
49                                 $wrapper.hide( 'slow' );
50                         }
51                 } );
52                 $( '.hideShowRadio' ).click( function() {
53                         var $wrapper = $( '#' + $(this).attr( 'rel' ) );
54                         if ( $(this).is( ':checked' ) ) {
55                                 $wrapper.hide( 'slow' );
56                         } else {
57                                 $wrapper.show( 'slow' );
58                         }
59                 } );
61                 // Hide "other" textboxes by default
62                 // Should not be done in CSS for javascript disabled compatibility
63                 $( '.enabledByOther' ).closest( '.config-block' ).hide();
65                 // Enable/disable "other" textboxes
66                 $( '.enableForOther' ).click( function() {
67                         var $textbox = $( '#' + $(this).attr( 'rel' ) );
68                         if ( $(this).val() == 'other' ) { // FIXME: Ugh, this is ugly
69                                 $textbox.removeAttr( 'readonly' ).closest( '.config-block' ).slideDown( 'fast' );
70                         } else {
71                                 $textbox.attr( 'readonly', 'readonly' ).closest( '.config-block' ).slideUp( 'fast' );
72                         }
73                 } );
74                 
75                 // Synchronize radio button label for sitename with textbox
76                 $label = $( 'label[for=config__NamespaceType_site-name]' );
77                 labelText = $label.text();
78                 $label.text( labelText.replace( '$1', '' ) );
79                 $( '#config_wgSitename' ).bind( 'keyup change', syncText ).each( syncText );
80                 function syncText() {
81                         var value = $(this).val()
82                                 .replace( /[\[\]\{\}|#<>%+? ]/g, '_' )
83                                 .replace( /&/, '&amp;' )
84                                 .replace( /__+/g, '_' )
85                                 .replace( /^_+/, '' )
86                                 .replace( /_+$/, '' );
87                         value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 );
88                         $label.text( labelText.replace( '$1', value ) );
89                 }
91                 // Show/Hide memcached servers when needed
92                 $("input[name$='config_wgMainCacheType']").change( function() {
93                         var $memc = $( "#config-memcachewrapper" );
94                         if( $( "input[name$='config_wgMainCacheType']:checked" ).val() == 'memcached' ) {
95                                 $memc.show( 'slow' );
96                         } else {
97                                 $memc.hide( 'slow' );
98                         }
99                 } );
100         } );
101 })(jQuery);