Merging resourceloader branch into trunk. Full documentation is at http://www.mediawi...
[lhc/web/wiklou.git] / resources / mediawiki.views / mediawiki.views.install.js
1 /*
2 * Web-installer progressive enhancement (ported from skins/common/config.js)
3 *
4 * Makes elements in the configuration form interactive and hides portions of the form when not in-use
5 */
6
7 ( function( $, mw ) {
8
9 /* Initialization */
10
11 $( document ).ready( function() {
12 // Show/hide code for help text
13 $( '.config-show-help a' ).click( function() {
14 $(this).parent().siblings( '.config-help-message' ).show( 'slow' );
15 $(this).parent().siblings( '.config-hide-help' ).show();
16 $(this).parent().hide();
17 return false;
18 } );
19 $( '.config-hide-help a' ).click( function() {
20 $(this).parent().siblings( '.config-help-message' ).hide( 'slow' );
21 $(this).parent().siblings( '.config-show-help' ).show();
22 $(this).parent().hide();
23 return false;
24 } );
25 // Show/hide code for DB-specific options
26 // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here?
27 $( '.dbRadio' ).each( function() { $( '#' + $(this).attr( 'rel' ) ).hide(); } );
28 $( '#' + $( '.dbRadio:checked' ).attr( 'rel' ) ).show();
29 $( '.dbRadio' ).click( function() {
30 var $checked = $( '.dbRadio:checked' );
31 var $wrapper = $( '#' + $checked.attr( 'rel' ) );
32 if ( !$wrapper.is( ':visible' ) ) {
33 $( '.dbWrapper' ).hide( 'slow' );
34 $wrapper.show( 'slow' );
35 }
36 } );
37 // Scroll to the bottom of upgrade log
38 $( "#config-update-log" ).each( function() { this.scrollTop = this.scrollHeight; } );
39 // Show/hide Creative Commons thingy
40 $( '.licenseRadio' ).click( function() {
41 var $wrapper = $( '#config-cc-wrapper' );
42 if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
43 $wrapper.show( 'slow' );
44 } else {
45 $wrapper.hide( 'slow' );
46 }
47 } );
48 // Show/hide random stuff (email, upload)
49 $( '.showHideRadio' ).click( function() {
50 var $wrapper = $( '#' + $(this).attr( 'rel' ) );
51 if ( $(this).is( ':checked' ) ) {
52 $wrapper.show( 'slow' );
53 } else {
54 $wrapper.hide( 'slow' );
55 }
56 } );
57 $( '.hideShowRadio' ).click( function() {
58 var $wrapper = $( '#' + $(this).attr( 'rel' ) );
59 if ( $(this).is( ':checked' ) ) {
60 $wrapper.hide( 'slow' );
61 } else {
62 $wrapper.show( 'slow' );
63 }
64 } );
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( 'disabled' );
70 } else {
71 $textbox.attr( 'disabled', 'disabled' );
72 }
73 } );
74 // Synchronize radio button label for sitename with textbox
75 $label = $( 'label[for=config__NamespaceType_site-name]' );
76 labelText = $label.text();
77 $label.text( labelText.replace( '$1', '' ) );
78 $( '#config_wgSitename' ).bind( 'keyup change', syncText ).each( syncText );
79 function syncText() {
80 var value = $(this).val()
81 .replace( /[\[\]\{\}|#<>%+? ]/g, '_' )
82 .replace( /&/, '&amp;' )
83 .replace( /__+/g, '_' )
84 .replace( /^_+/, '' )
85 .replace( /_+$/, '' );
86 value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 );
87 $label.text( labelText.replace( '$1', value ) );
88 }
89 // Show/Hide memcached servers when needed
90 $( "input[name$='config_wgMainCacheType']" ).change( function() {
91 var $memc = $( "#config-memcachewrapper" );
92 if ( $( "input[name$='config_wgMainCacheType']:checked" ).val() == 'memcached' ) {
93 $memc.show( 'slow' );
94 } else {
95 $memc.hide( 'slow' );
96 }
97 } );
98 } );
99
100 } )( jQuery, mediaWiki );