*/
$.fn.goIn = function ( instantToggle ) {
if ( instantToggle === true ) {
- return $(this).show();
+ return $( this ).show();
}
- return $(this).stop( true, true ).fadeIn();
+ return $( this ).stop( true, true ).fadeIn();
};
/**
*/
$.fn.goOut = function ( instantToggle ) {
if ( instantToggle === true ) {
- return $(this).hide();
+ return $( this ).hide();
}
- return $(this).stop( true, true ).fadeOut();
+ return $( this ).stop( true, true ).fadeOut();
};
/**
* @param {Function} callback Takes one parameter, which is {true} when the
* event is called immediately, and {jQuery.Event} when triggered from an event.
*/
- $.fn.liveAndTestAtStart = function ( callback ){
- $(this)
+ $.fn.liveAndTestAtStart = function ( callback ) {
+ $( this )
.live( 'change', callback )
.each( function () {
callback.call( this, true );
// Animate the SelectOrOther fields, to only show the text field when
// 'other' is selected.
$( '.mw-htmlform-select-or-other' ).liveAndTestAtStart( function ( instant ) {
- var $other = $( '#' + $(this).attr( 'id' ) + '-other' );
+ var $other = $( '#' + $( this ).attr( 'id' ) + '-other' );
$other = $other.add( $other.siblings( 'br' ) );
- if ( $(this).val() === 'other' ) {
+ if ( $( this ).val() === 'other' ) {
$other.goIn( instant );
} else {
$other.goOut( instant );
}
- });
+ } );
} );
'class': 'htmlform-chzn-select mw-input ' + oldClass
} );
$oldContainer.find( 'input' ).each( function () {
- var $oldInput = $(this),
+ var $oldInput = $( this ),
checked = $oldInput.prop( 'checked' ),
$option = $( '<option>' );
$option.prop( 'value', $oldInput.prop( 'value' ) );
$td = $( '<td>' ),
$fieldLabelText = $( '<label>' ),
$container;
- if ( type === 'table' ) {
+ if ( type === 'tr' ) {
addMulti( $oldContainer, $td );
$container = $( '<tr>' );
$container.append( $td );
$fieldLabelText.text( $oldContainer.find( '.mw-label label' ).text() );
$fieldLabel.append( $fieldLabelText );
$container.prepend( $fieldLabel );
- $oldContainer.parent().append( $container );
- $oldContainer.remove();
+ $oldContainer.replaceWith( $container );
return $container;
}
if ( $( '.mw-chosen' ).length ) {
mw.loader.using( 'jquery.chosen', function () {
- var $toConvert,
- $converted;
- $toConvert = $( 'table .mw-chosen' );
- if ( $toConvert.length ) {
- $converted = convertCheckboxesToMulti( $toConvert, 'table' );
- $converted.find( '.htmlform-chzn-select' ).chosen( { width: 'auto' } );
- }
- $toConvert = $( 'div .mw-chosen' );
- if ( $toConvert.length ) {
- $converted = convertCheckboxesToMulti( $toConvert, 'div' );
+ $( '.mw-chosen' ).each( function () {
+ var type = this.nodeName.toLowerCase(),
+ $converted = convertCheckboxesToMulti( $( this ), type );
$converted.find( '.htmlform-chzn-select' ).chosen( { width: 'auto' } );
- }
+ } );
} );
}