* Added tipsy library
[lhc/web/wiklou.git] / skins / common / config.js
1 (function( $ ) {
2 $( document ).ready( function() {
3
4 // Generate the tool tips
5 $( '.mw-help-field-hint' ).tipsy( { gravity : 'se', opacity: '0.9' } );
6
7 // Show/hide code for DB-specific options
8 // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here?
9 $( '.dbRadio' ).each( function() { $( '#' + $(this).attr( 'rel' ) ).hide(); } );
10 $( '#' + $( '.dbRadio:checked' ).attr( 'rel' ) ).show();
11 $( '.dbRadio' ).click( function() {
12 var $checked = $( '.dbRadio:checked' );
13 var $wrapper = $( '#' + $checked.attr( 'rel' ) );
14 if ( !$wrapper.is( ':visible' ) ) {
15 $( '.dbWrapper' ).hide( 'slow' );
16 $wrapper.show( 'slow' );
17 }
18 } );
19
20 // Scroll to the bottom of upgrade log
21 $( "#config-update-log" ).each( function() { this.scrollTop = this.scrollHeight; } );
22
23 // Show/hide Creative Commons thingy
24 $( '.licenseRadio' ).click( function() {
25 var $wrapper = $( '#config-cc-wrapper' );
26 if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
27 $wrapper.show( 'slow' );
28 } else {
29 $wrapper.hide( 'slow' );
30 }
31 } );
32
33 // Show/hide random stuff (email, upload)
34 $( '.showHideRadio' ).click( function() {
35 var $wrapper = $( '#' + $(this).attr( 'rel' ) );
36 if ( $(this).is( ':checked' ) ) {
37 $wrapper.show( 'slow' );
38 } else {
39 $wrapper.hide( 'slow' );
40 }
41 } );
42 $( '.hideShowRadio' ).click( function() {
43 var $wrapper = $( '#' + $(this).attr( 'rel' ) );
44 if ( $(this).is( ':checked' ) ) {
45 $wrapper.hide( 'slow' );
46 } else {
47 $wrapper.show( 'slow' );
48 }
49 } );
50
51 // Enable/disable "other" textboxes
52 $( '.enableForOther' ).click( function() {
53 var $textbox = $( '#' + $(this).attr( 'rel' ) );
54 if ( $(this).val() == 'other' ) { // FIXME: Ugh, this is ugly
55 $textbox.removeAttr( 'disabled' );
56 } else {
57 $textbox.attr( 'disabled', 'disabled' );
58 }
59 } );
60
61 // Synchronize radio button label for sitename with textbox
62 $label = $( 'label[for=config__NamespaceType_site-name]' );
63 labelText = $label.text();
64 $label.text( labelText.replace( '$1', '' ) );
65 $( '#config_wgSitename' ).bind( 'keyup change', syncText ).each( syncText );
66 function syncText() {
67 var value = $(this).val()
68 .replace( /[\[\]\{\}|#<>%+? ]/g, '_' )
69 .replace( /&/, '&amp;' )
70 .replace( /__+/g, '_' )
71 .replace( /^_+/, '' )
72 .replace( /_+$/, '' );
73 value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 );
74 $label.text( labelText.replace( '$1', value ) );
75 }
76
77 // Show/Hide memcached servers when needed
78 $("input[name$='config_wgMainCacheType']").change( function() {
79 var $memc = $( "#config-memcachewrapper" );
80 if( $( "input[name$='config_wgMainCacheType']:checked" ).val() == 'memcached' ) {
81 $memc.show( 'slow' );
82 } else {
83 $memc.hide( 'slow' );
84 }
85 } );
86 } );
87 })(jQuery);