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 $( '.enabledByOther' ).closest( '.config-block' ).hide();
78 // Enable/disable "other" textboxes
79 $( '.enableForOther' ).click( function () {
80 var $textbox
= $( document
.getElementById( $( this ).attr( 'rel' ) ) );
81 // FIXME: Ugh, this is ugly
82 if ( $( this ).val() === 'other' ) {
83 $textbox
.prop( 'readonly', false ).closest( '.config-block' ).slideDown( 'fast' );
85 $textbox
.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' );
89 // Synchronize radio button label for sitename with textbox
90 $label
= $( 'label[for=config__NamespaceType_site-name]' );
91 labelText
= $label
.text();
92 $label
.text( labelText
.replace( '$1', '' ) );
93 $( '#config_wgSitename' ).on( 'keyup change', syncText
).each( syncText
);
95 // Show/Hide memcached servers when needed
96 $( 'input[name$="config__MainCacheType"]' ).change( function () {
97 var $memc
= $( '#config-memcachewrapper' );
98 if ( $( 'input[name$="config__MainCacheType"]:checked' ).val() === 'memcached' ) {
101 $memc
.hide( 'slow' );
105 function areReqsSatisfied( name
) {
106 var i
, ext
, skin
, node
;
107 if ( !extDependencyMap
[ name
] ) {
111 if ( extDependencyMap
[ name
].extensions
) {
112 for ( i
in extDependencyMap
[ name
].extensions
) {
113 ext
= extDependencyMap
[ name
].extensions
[ i
];
114 node
= document
.getElementById( 'config_ext-' + ext
);
115 if ( !node
|| !node
.checked
) {
120 if ( extDependencyMap
[ name
].skins
) {
121 for ( i
in extDependencyMap
[ name
].skins
) {
122 skin
= extDependencyMap
[ name
].skins
[ i
];
123 node
= document
.getElementById( 'config_skin-' + skin
);
124 if ( !node
|| !node
.checked
) {
133 // Disable checkboxes if the extension has dependencies
134 $( '.mw-ext-with-dependencies input' ).prop( 'disabled', true );
135 $( 'input[data-name]' ).change( function () {
136 $( '.mw-ext-with-dependencies input' ).each( function () {
137 var $this = $( this ),
138 name
= $this.data( 'name' );
139 if ( areReqsSatisfied( name
) ) {
141 $this.prop( 'disabled', false );
143 // Disable the checkbox, and uncheck it if it is checked
144 $this.prop( 'disabled', true );
145 if ( $this.prop( 'checked' ) ) {
146 $this.prop( 'checked', false );