summaryrefslogtreecommitdiff
path: root/skins/common/config.js
diff options
context:
space:
mode:
Diffstat (limited to 'skins/common/config.js')
-rw-r--r--skins/common/config.js66
1 files changed, 36 insertions, 30 deletions
diff --git a/skins/common/config.js b/skins/common/config.js
index 23f7302c..b1e28aba 100644
--- a/skins/common/config.js
+++ b/skins/common/config.js
@@ -1,6 +1,17 @@
-(function( $ ) {
- $( document ).ready( function() {
+( function ( $ ) {
+ $( document ).ready( function () {
+ var $label, labelText;
+ function syncText() {
+ var value = $(this).val()
+ .replace( /[\[\]\{\}|#<>%+? ]/g, '_' )
+ .replace( /&/, '&amp;' )
+ .replace( /__+/g, '_' )
+ .replace( /^_+/, '' )
+ .replace( /_+$/, '' );
+ value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 );
+ $label.text( labelText.replace( '$1', value ) );
+ }
// Set up the help system
$( '.mw-help-field-data' )
@@ -8,7 +19,7 @@
.closest( '.mw-help-field-container' )
.find( '.mw-help-field-hint' )
.show()
- .click( function() {
+ .click( function () {
$(this)
.closest( '.mw-help-field-container' )
.find( '.mw-help-field-data' )
@@ -17,22 +28,26 @@
// Show/hide code for DB-specific options
// FIXME: Do we want slow, fast, or even non-animated (instantaneous) showing/hiding here?
- $( '.dbRadio' ).each( function() { $( '#' + $(this).attr( 'rel' ) ).hide(); } );
- $( '#' + $( '.dbRadio:checked' ).attr( 'rel' ) ).show();
- $( '.dbRadio' ).click( function() {
- var $checked = $( '.dbRadio:checked' );
- var $wrapper = $( '#' + $checked.attr( 'rel' ) );
- if ( !$wrapper.is( ':visible' ) ) {
+ $( '.dbRadio' ).each( function () {
+ $( document.getElementById( $(this).attr( 'rel' ) ) ).hide();
+ } );
+ $( document.getElementById( $( '.dbRadio:checked' ).attr( 'rel' ) ) ).show();
+ $( '.dbRadio' ).click( function () {
+ var $checked = $( '.dbRadio:checked' ),
+ $wrapper = $( document.getElementById( $checked.attr( 'rel' ) ) );
+ if ( $wrapper.is( ':hidden' ) ) {
$( '.dbWrapper' ).hide( 'slow' );
$wrapper.show( 'slow' );
}
} );
// Scroll to the bottom of upgrade log
- $( '#config-live-log' ).find( '> textarea' ).each( function() { this.scrollTop = this.scrollHeight; } );
+ $( '#config-live-log' ).children( 'textarea' ).each( function () {
+ this.scrollTop = this.scrollHeight;
+ } );
// Show/hide Creative Commons thingy
- $( '.licenseRadio' ).click( function() {
+ $( '.licenseRadio' ).click( function () {
var $wrapper = $( '#config-cc-wrapper' );
if ( $( '#config__LicenseCode_cc-choose' ).is( ':checked' ) ) {
$wrapper.show( 'slow' );
@@ -42,7 +57,7 @@
} );
// Show/hide random stuff (email, upload)
- $( '.showHideRadio' ).click( function() {
+ $( '.showHideRadio' ).click( function () {
var $wrapper = $( '#' + $(this).attr( 'rel' ) );
if ( $(this).is( ':checked' ) ) {
$wrapper.show( 'slow' );
@@ -50,7 +65,7 @@
$wrapper.hide( 'slow' );
}
} );
- $( '.hideShowRadio' ).click( function() {
+ $( '.hideShowRadio' ).click( function () {
var $wrapper = $( '#' + $(this).attr( 'rel' ) );
if ( $(this).is( ':checked' ) ) {
$wrapper.hide( 'slow' );
@@ -64,9 +79,10 @@
$( '.enabledByOther' ).closest( '.config-block' ).hide();
// Enable/disable "other" textboxes
- $( '.enableForOther' ).click( function() {
- var $textbox = $( '#' + $(this).attr( 'rel' ) );
- if ( $(this).val() == 'other' ) { // FIXME: Ugh, this is ugly
+ $( '.enableForOther' ).click( function () {
+ var $textbox = $( document.getElementById( $(this).attr( 'rel' ) ) );
+ // FIXME: Ugh, this is ugly
+ if ( $(this).val() === 'other' ) {
$textbox.removeProp( 'readonly' ).closest( '.config-block' ).slideDown( 'fast' );
} else {
$textbox.prop( 'readonly', true ).closest( '.config-block' ).slideUp( 'fast' );
@@ -77,26 +93,16 @@
$label = $( 'label[for=config__NamespaceType_site-name]' );
labelText = $label.text();
$label.text( labelText.replace( '$1', '' ) );
- $( '#config_wgSitename' ).bind( 'keyup change', syncText ).each( syncText );
- function syncText() {
- var value = $(this).val()
- .replace( /[\[\]\{\}|#<>%+? ]/g, '_' )
- .replace( /&/, '&amp;' )
- .replace( /__+/g, '_' )
- .replace( /^_+/, '' )
- .replace( /_+$/, '' );
- value = value.substr( 0, 1 ).toUpperCase() + value.substr( 1 );
- $label.text( labelText.replace( '$1', value ) );
- }
+ $( '#config_wgSitename' ).on( 'keyup change', syncText ).each( syncText );
// Show/Hide memcached servers when needed
- $("input[name$='config_wgMainCacheType']").change( function() {
+ $( 'input[name$="config_wgMainCacheType"]' ).change( function () {
var $memc = $( "#config-memcachewrapper" );
- if( $( "input[name$='config_wgMainCacheType']:checked" ).val() == 'memcached' ) {
+ if( $( 'input[name$="config_wgMainCacheType"]:checked' ).val() === 'memcached' ) {
$memc.show( 'slow' );
} else {
$memc.hide( 'slow' );
}
} );
} );
-})(jQuery);
+}( jQuery ) );