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