config.js 3.3 KB

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