]> scripts.mit.edu Git - autoinstalls/mediawiki.git/blob - mw-config/config.js
MediaWiki 1.30.2-scripts2
[autoinstalls/mediawiki.git] / mw-config / config.js
1 ( function ( $ ) {
2         $( function () {
3                 var $label, labelText;
4
5                 function syncText() {
6                         var value = $( this ).val()
7                                 .replace( /[\[\]{}|#<>%+? ]/g, '_' ) // eslint-disable-line no-useless-escape
8                                 .replace( /&/, '&amp;' )
9                                 .replace( /__+/g, '_' )
10                                 .replace( /^_+/, '' )
11                                 .replace( /_+$/, '' );
12                         value = value.charAt( 0 ).toUpperCase() + value.slice( 1 );
13                         $label.text( labelText.replace( '$1', value ) );
14                 }
15
16                 // Set up the help system
17                 $( '.config-help-field-data' ).hide()
18                         .closest( '.config-help-field-container' ).find( '.config-help-field-hint' )
19                         .show()
20                         .click( function () {
21                                 $( this ).closest( '.config-help-field-container' ).find( '.config-help-field-data' )
22                                         .slideToggle( 'fast' );
23                         } );
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 () {
28                         $( document.getElementById( $( this ).attr( 'rel' ) ) ).hide();
29                 } );
30                 $( document.getElementById( $( '.dbRadio:checked' ).attr( 'rel' ) ) ).show();
31                 $( '.dbRadio' ).click( function () {
32                         var $checked = $( '.dbRadio:checked' ),
33                                 $wrapper = $( document.getElementById( $checked.attr( 'rel' ) ) );
34                         if ( $wrapper.is( ':hidden' ) ) {
35                                 $( '.dbWrapper' ).hide( 'slow' );
36                                 $wrapper.show( 'slow' );
37                         }
38                 } );
39
40                 // Scroll to the bottom of upgrade log
41                 $( '#config-live-log' ).children( 'textarea' ).each( function () {
42                         this.scrollTop = this.scrollHeight;
43                 } );
44
45                 // Show/hide Creative Commons thingy
46                 $( '.licenseRadio' ).click( function () {
47                         var $wrapper = $( '#config-cc-wrapper' );
48                         if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
49                                 $wrapper.show( 'slow' );
50                         } else {
51                                 $wrapper.hide( 'slow' );
52                         }
53                 } );
54
55                 // Show/hide random stuff (email, upload)
56                 $( '.showHideRadio' ).click( function () {
57                         var $wrapper = $( '#' + $( this ).attr( 'rel' ) );
58                         if ( $( this ).is( ':checked' ) ) {
59                                 $wrapper.show( 'slow' );
60                         } else {
61                                 $wrapper.hide( 'slow' );
62                         }
63                 } );
64                 $( '.hideShowRadio' ).click( function () {
65                         var $wrapper = $( '#' + $( this ).attr( 'rel' ) );
66                         if ( $( this ).is( ':checked' ) ) {
67                                 $wrapper.hide( 'slow' );
68                         } else {
69                                 $wrapper.show( 'slow' );
70                         }
71                 } );
72
73                 // Hide "other" textboxes by default
74                 // Should not be done in CSS for javascript disabled compatibility
75                 $( '.enabledByOther' ).closest( '.config-block' ).hide();
76
77                 // Enable/disable "other" textboxes
78                 $( '.enableForOther' ).click( function () {
79                         var $textbox = $( document.getElementById( $( this ).attr( 'rel' ) ) );
80                         // FIXME: Ugh, this is ugly
81                         if ( $( this ).val() === 'other' ) {
82                                 $textbox.removeProp( 'readonly' ).closest( '.config-block' ).slideDown( 'fast' );
83                         } else {
84                                 $textbox.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' );
85                         }
86                 } );
87
88                 // Synchronize radio button label for sitename with textbox
89                 $label = $( 'label[for=config__NamespaceType_site-name]' );
90                 labelText = $label.text();
91                 $label.text( labelText.replace( '$1', '' ) );
92                 $( '#config_wgSitename' ).on( 'keyup change', syncText ).each( syncText );
93
94                 // Show/Hide memcached servers when needed
95                 $( 'input[name$="config__MainCacheType"]' ).change( function () {
96                         var $memc = $( '#config-memcachewrapper' );
97                         if ( $( 'input[name$="config__MainCacheType"]:checked' ).val() === 'memcached' ) {
98                                 $memc.show( 'slow' );
99                         } else {
100                                 $memc.hide( 'slow' );
101                         }
102                 } );
103         } );
104 }( jQuery ) );