Merge new-installer branch to trunk
[lhc/web/wiklou.git] / skins / common / config.js
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 } );
60
61 // Enable/disable "other" textboxes
62 $( '.enableForOther' ).click( function() {
63 var $textbox = $( '#' + $(this).attr( 'rel' ) );
64 if ( $(this).val() == 'other' ) { // FIXME: Ugh, this is ugly
65 $textbox.removeAttr( 'disabled' );
66 } else {
67 $textbox.attr( 'disabled', 'disabled' );
68 }
69 } );
70
71 // Synchronize radio button label for sitename with textbox
72 $label = $( 'label[for=config__NamespaceType_site-name]' );
73 labelText = $label.text();
74 $label.text( labelText.replace( '$1', '' ) );
75 $( '#config_wgSitename' ).bind( 'keyup change', syncText ).each( syncText );
76 function syncText() {
77 var value = $(this).val()
78 .replace( /[\[\]\{\}|#<>%+? ]/g, '_' )
79 .replace( /&/, '&amp;' )
80 .replace( /__+/g, '_' )
81 .replace( /^_+/, '' )
82 .replace( /_+$/, '' );
83 value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 );
84 $label.text( labelText.replace( '$1', value ) );
85 }
86
87 } );
88 })(jQuery);