| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
$.fn.goIn = function ( instantToggle ) { |
| 13 |
if ( instantToggle === true ) { |
| 14 |
return this.show(); |
| 15 |
} |
| 16 |
return this.stop( true, true ).fadeIn(); |
| 17 |
}; |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
$.fn.goOut = function ( instantToggle ) { |
| 26 |
if ( instantToggle === true ) { |
| 27 |
return this.hide(); |
| 28 |
} |
| 29 |
return this.stop( true, true ).fadeOut(); |
| 30 |
}; |
| 31 |
|
| 32 |
mw.hook( 'htmlform.enhance' ).add( ( $root ) => { |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
function handleSelectOrOther( instant ) { |
| 38 |
const $select = $( this ).find( 'select' ); |
| 39 |
let $other = $( this ).find( 'input' ); |
| 40 |
$other = $other.add( $other.siblings( 'br' ) ); |
| 41 |
if ( $select.val() === 'other' ) { |
| 42 |
$other.goIn( instant ); |
| 43 |
} else { |
| 44 |
$other.goOut( instant ); |
| 45 |
} |
| 46 |
} |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
$root |
| 51 |
.on( 'change', '.mw-htmlform-select-or-other:not(.oo-ui-widget)', handleSelectOrOther ) |
| 52 |
.find( '.mw-htmlform-select-or-other:not(.oo-ui-widget)' ) |
| 53 |
.each( function () { |
| 54 |
handleSelectOrOther.call( this, true ); |
| 55 |
} ); |
| 56 |
} ); |