2 * HTMLForm enhancements:
3 * Animate the SelectOrOther fields, to only show the text field when 'other' is selected.
8 * @class jQuery.plugin.htmlform
12 * jQuery plugin to fade or snap to visible state.
14 * @param {boolean} [instantToggle=false]
18 $.fn
.goIn = function ( instantToggle
) {
19 if ( instantToggle
=== true ) {
22 return this.stop( true, true ).fadeIn();
26 * jQuery plugin to fade or snap to hiding state.
28 * @param {boolean} [instantToggle=false]
32 $.fn
.goOut = function ( instantToggle
) {
33 if ( instantToggle
=== true ) {
36 return this.stop( true, true ).fadeOut();
39 mw
.hook( 'htmlform.enhance' ).add( function ( $root
) {
42 * @param {boolean|jQuery.Event} instant
44 function handleSelectOrOther( instant
) {
45 var $other
= $root
.find( '#' + $( this ).attr( 'id' ) + '-other' );
46 $other
= $other
.add( $other
.siblings( 'br' ) );
47 if ( $( this ).val() === 'other' ) {
48 $other
.goIn( instant
);
50 $other
.goOut( instant
);
55 .on( 'change', '.mw-htmlform-select-or-other', handleSelectOrOther
)
57 handleSelectOrOther
.call( this, true );
61 }( mediaWiki
, jQuery
) );