1 /* global extDependencyMap */
7 var value
= $( this ).val()
8 .replace( /[\[\]{}|#<>%+? ]/g, '_' ) // eslint-disable-line no-useless-escape
9 .replace( /&/, '&' )
10 .replace( /__+/g, '_' )
12 .replace( /_+$/, '' );
13 value
= value
.charAt( 0 ).toUpperCase() + value
.slice( 1 );
14 $label
.text( labelText
.replace( '$1', value
) );
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 () {
20 $( document
.getElementById( $( this ).attr( 'rel' ) ) ).hide();
22 $( document
.getElementById( $( '.dbRadio:checked' ).attr( 'rel' ) ) ).show();
23 $( '.dbRadio' ).on( 'click', function () {
24 var $checked
= $( '.dbRadio:checked' ),
25 $wrapper
= $( document
.getElementById( $checked
.attr( 'rel' ) ) );
26 if ( $wrapper
.is( ':hidden' ) ) {
27 // FIXME: Use CSS transition
28 // eslint-disable-next-line no-jquery/no-animate-toggle
29 $( '.dbWrapper' ).hide( 'slow' );
30 // eslint-disable-next-line no-jquery/no-animate-toggle
31 $wrapper
.show( 'slow' );
35 // Scroll to the bottom of upgrade log
36 $( '#config-live-log' ).children( 'textarea' ).each( function () {
37 this.scrollTop
= this.scrollHeight
;
40 // Show/hide Creative Commons thingy
41 $( '.licenseRadio' ).on( 'click', function () {
42 var $wrapper
= $( '#config-cc-wrapper' );
43 if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
44 // FIXME: Use CSS transition
45 // eslint-disable-next-line no-jquery/no-animate-toggle
46 $wrapper
.show( 'slow' );
48 // eslint-disable-next-line no-jquery/no-animate-toggle
49 $wrapper
.hide( 'slow' );
53 // Show/hide random stuff (email, upload)
54 $( '.showHideRadio' ).on( 'click', function () {
55 var $wrapper
= $( '#' + $( this ).attr( 'rel' ) );
56 if ( $( this ).is( ':checked' ) ) {
57 // FIXME: Use CSS transition
58 // eslint-disable-next-line no-jquery/no-animate-toggle
59 $wrapper
.show( 'slow' );
61 // eslint-disable-next-line no-jquery/no-animate-toggle
62 $wrapper
.hide( 'slow' );
65 $( '.hideShowRadio' ).on( 'click', function () {
66 var $wrapper
= $( '#' + $( this ).attr( 'rel' ) );
67 if ( $( this ).is( ':checked' ) ) {
68 // FIXME: Use CSS transition
69 // eslint-disable-next-line no-jquery/no-animate-toggle
70 $wrapper
.hide( 'slow' );
72 // eslint-disable-next-line no-jquery/no-animate-toggle
73 $wrapper
.show( 'slow' );
77 // Hide "other" textboxes by default
78 // Should not be done in CSS for javascript disabled compatibility
79 if ( !$( '#config__NamespaceType_other' ).is( ':checked' ) ) {
80 $( '.enabledByOther' ).closest( '.config-block' ).hide();
83 // Enable/disable "other" textboxes
84 $( '.enableForOther' ).on( 'click', function () {
85 var $textbox
= $( document
.getElementById( $( this ).attr( 'rel' ) ) );
86 // FIXME: Ugh, this is ugly
87 if ( $( this ).val() === 'other' ) {
88 // FIXME: Use CSS transition
89 // eslint-disable-next-line no-jquery/no-slide
90 $textbox
.prop( 'readonly', false ).closest( '.config-block' ).slideDown( 'fast' );
92 // eslint-disable-next-line no-jquery/no-slide
93 $textbox
.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' );
97 // Synchronize radio button label for sitename with textbox
98 $label
= $( 'label[for="config__NamespaceType_site-name"]' );
99 labelText
= $label
.text();
100 $label
.text( labelText
.replace( '$1', '' ) );
101 $( '#config_wgSitename' ).on( 'keyup change', syncText
).each( syncText
);
103 // Show/Hide memcached servers when needed
104 $( 'input[name$="config__MainCacheType"]' ).on( 'change', function () {
105 var $memc
= $( '#config-memcachewrapper' );
106 if ( $( 'input[name$="config__MainCacheType"]:checked' ).val() === 'memcached' ) {
107 // FIXME: Use CSS transition
108 // eslint-disable-next-line no-jquery/no-animate-toggle
109 $memc
.show( 'slow' );
111 // eslint-disable-next-line no-jquery/no-animate-toggle
112 $memc
.hide( 'slow' );
116 function areReqsSatisfied( name
) {
117 var i
, ext
, skin
, node
;
118 if ( !extDependencyMap
[ name
] ) {
122 if ( extDependencyMap
[ name
].extensions
) {
123 for ( i
in extDependencyMap
[ name
].extensions
) {
124 ext
= extDependencyMap
[ name
].extensions
[ i
];
125 node
= document
.getElementById( 'config_ext-' + ext
);
126 if ( !node
|| !node
.checked
) {
131 if ( extDependencyMap
[ name
].skins
) {
132 for ( i
in extDependencyMap
[ name
].skins
) {
133 skin
= extDependencyMap
[ name
].skins
[ i
];
134 node
= document
.getElementById( 'config_skin-' + skin
);
135 if ( !node
|| !node
.checked
) {
144 // Disable checkboxes if the extension has dependencies
145 $( '.mw-ext-with-dependencies input' ).prop( 'disabled', true );
146 $( '.config-ext-input[data-name]' ).on( 'change', function () {
147 $( '.mw-ext-with-dependencies input' ).each( function () {
148 var name
= this.getAttribute( 'data-name' );
149 if ( areReqsSatisfied( name
) ) {
151 this.disabled
= false;
153 // Uncheck and disable the checkbox
154 this.checked
= false;
155 this.disabled
= true;