2 * HTMLForm enhancements:
3 * Add minimal help for date and time fields
7 mw
.hook( 'htmlform.enhance' ).add( function ( $root
) {
11 .find( 'input.mw-htmlform-datetime-field' )
14 type
= this.getAttribute( 'type' );
16 if ( type
!== 'date' && type
!== 'time' && type
!== 'datetime' ) {
21 if ( supported
[ type
] === undefined ) {
22 // Assume that if the browser implements validation (so it
23 // rejects "bogus" as a value) then it supports a proper UI too.
24 input
= document
.createElement( 'input' );
25 input
.setAttribute( 'type', type
);
26 input
.value
= 'bogus';
27 supported
[ type
] = ( input
.value
!== 'bogus' );
30 if ( supported
[ type
] ) {
31 if ( !this.getAttribute( 'min' ) ) {
32 this.setAttribute( 'min', this.getAttribute( 'data-min' ) );
34 if ( !this.getAttribute( 'max' ) ) {
35 this.setAttribute( 'max', this.getAttribute( 'data-max' ) );
37 if ( !this.getAttribute( 'step' ) ) {
38 this.setAttribute( 'step', this.getAttribute( 'data-step' ) );