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 // Set up the help system
18 $( '.config-help-field-data' ).hide()
19 .closest( '.config-help-field-container' ).find( '.config-help-field-hint' )
22 $( this ).closest( '.config-help-field-container' ).find( '.config-help-field-data' )
23 .slideToggle( 'fast' );
26 // Show/hide code for DB-specific options
27 // FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here?
28 $( '.dbRadio' ).each( function () {
29 $( document
.getElementById( $( this ).attr( 'rel' ) ) ).hide();
31 $( document
.getElementById( $( '.dbRadio:checked' ).attr( 'rel' ) ) ).show();
32 $( '.dbRadio' ).click( function () {
33 var $checked
= $( '.dbRadio:checked' ),
34 $wrapper
= $( document
.getElementById( $checked
.attr( 'rel' ) ) );
35 if ( $wrapper
.is( ':hidden' ) ) {
36 $( '.dbWrapper' ).hide( 'slow' );
37 $wrapper
.show( 'slow' );
41 // Scroll to the bottom of upgrade log
42 $( '#config-live-log' ).children( 'textarea' ).each( function () {
43 this.scrollTop
= this.scrollHeight
;
46 // Show/hide Creative Commons thingy
47 $( '.licenseRadio' ).click( function () {
48 var $wrapper
= $( '#config-cc-wrapper' );
49 if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
50 $wrapper
.show( 'slow' );
52 $wrapper
.hide( 'slow' );
56 // Show/hide random stuff (email, upload)
57 $( '.showHideRadio' ).click( function () {
58 var $wrapper
= $( '#' + $( this ).attr( 'rel' ) );
59 if ( $( this ).is( ':checked' ) ) {
60 $wrapper
.show( 'slow' );
62 $wrapper
.hide( 'slow' );
65 $( '.hideShowRadio' ).click( function () {
66 var $wrapper
= $( '#' + $( this ).attr( 'rel' ) );
67 if ( $( this ).is( ':checked' ) ) {
68 $wrapper
.hide( 'slow' );
70 $wrapper
.show( 'slow' );
74 // Hide "other" textboxes by default
75 // Should not be done in CSS for javascript disabled compatibility
76 if ( !$( '#config__NamespaceType_other' ).is( ':checked' ) ) {
77 $( '.enabledByOther' ).closest( '.config-block' ).hide();
80 // Enable/disable "other" textboxes
81 $( '.enableForOther' ).click( function () {
82 var $textbox
= $( document
.getElementById( $( this ).attr( 'rel' ) ) );
83 // FIXME: Ugh, this is ugly
84 if ( $( this ).val() === 'other' ) {
85 $textbox
.prop( 'readonly', false ).closest( '.config-block' ).slideDown( 'fast' );
87 $textbox
.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' );
91 // Synchronize radio button label for sitename with textbox
92 $label
= $( 'label[for="config__NamespaceType_site-name"]' );
93 labelText
= $label
.text();
94 $label
.text( labelText
.replace( '$1', '' ) );
95 $( '#config_wgSitename' ).on( 'keyup change', syncText
).each( syncText
);
97 // Show/Hide memcached servers when needed
98 $( 'input[name$="config__MainCacheType"]' ).change( function () {
99 var $memc
= $( '#config-memcachewrapper' );
100 if ( $( 'input[name$="config__MainCacheType"]:checked' ).val() === 'memcached' ) {
101 $memc
.show( 'slow' );
103 $memc
.hide( 'slow' );
107 function areReqsSatisfied( name
) {
108 var i
, ext
, skin
, node
;
109 if ( !extDependencyMap
[ name
] ) {
113 if ( extDependencyMap
[ name
].extensions
) {
114 for ( i
in extDependencyMap
[ name
].extensions
) {
115 ext
= extDependencyMap
[ name
].extensions
[ i
];
116 node
= document
.getElementById( 'config_ext-' + ext
);
117 if ( !node
|| !node
.checked
) {
122 if ( extDependencyMap
[ name
].skins
) {
123 for ( i
in extDependencyMap
[ name
].skins
) {
124 skin
= extDependencyMap
[ name
].skins
[ i
];
125 node
= document
.getElementById( 'config_skin-' + skin
);
126 if ( !node
|| !node
.checked
) {
135 // Disable checkboxes if the extension has dependencies
136 $( '.mw-ext-with-dependencies input' ).prop( 'disabled', true );
137 $( '.config-ext-input[data-name]' ).on( 'change', function () {
138 $( '.mw-ext-with-dependencies input' ).each( function () {
139 var name
= this.getAttribute( 'data-name' );
140 if ( areReqsSatisfied( name
) ) {
142 this.disabled
= false;
144 // Uncheck and disable the checkbox
145 this.checked
= false;
146 this.disabled
= true;