Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5952014
selectorother.js
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
selectorother.js
View Options
/*
* HTMLForm enhancements:
* Animate the SelectOrOther fields, to only show the text field when 'other' is selected.
*/
/**
* jQuery plugin to fade or snap to visible state.
*
* @param {boolean} [instantToggle=false]
* @return {jQuery}
*/
$
.
fn
.
goIn
=
function
(
instantToggle
)
{
if
(
instantToggle
===
true
)
{
return
this
.
show
();
}
return
this
.
stop
(
true
,
true
).
fadeIn
();
};
/**
* jQuery plugin to fade or snap to hiding state.
*
* @param {boolean} [instantToggle=false]
* @return {jQuery}
*/
$
.
fn
.
goOut
=
function
(
instantToggle
)
{
if
(
instantToggle
===
true
)
{
return
this
.
hide
();
}
return
this
.
stop
(
true
,
true
).
fadeOut
();
};
mw
.
hook
(
'htmlform.enhance'
).
add
(
(
$root
)
=>
{
/**
* @ignore
* @param {boolean|jQuery.Event} instant
*/
function
handleSelectOrOther
(
instant
)
{
const
$select
=
$
(
this
).
find
(
'select'
);
let
$other
=
$
(
this
).
find
(
'input'
);
$other
=
$other
.
add
(
$other
.
siblings
(
'br'
)
);
if
(
$select
.
val
()
===
'other'
)
{
$other
.
goIn
(
instant
);
}
else
{
$other
.
goOut
(
instant
);
}
}
// Exclude OOUI widgets, since they're infused and SelectWithInputWidget
// is responsible for this logic.
$root
.
on
(
'change'
,
'.mw-htmlform-select-or-other:not(.oo-ui-widget)'
,
handleSelectOrOther
)
.
find
(
'.mw-htmlform-select-or-other:not(.oo-ui-widget)'
)
.
each
(
function
()
{
handleSelectOrOther
.
call
(
this
,
true
);
}
);
}
);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Oct 3 2026, 01:11 (4 w, 4 d ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
34/d7/8e80b1f827c93012ae2d8e727e6c
Default Alt Text
selectorother.js (1 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment