HTMLDateTimeField: Remove hacks for HTML5 form validation attributes
authorBartosz Dziewoński <matma.rex@gmail.com>
Thu, 24 Nov 2016 15:22:29 +0000 (16:22 +0100)
committerBartosz Dziewoński <matma.rex@gmail.com>
Tue, 10 Jan 2017 22:53:33 +0000 (22:53 +0000)
No longer needed after I08244addcf9b6eb96137895f28e7b750914fef5c.
Also remove datetime.js from mediawiki.htmlform module.

Change-Id: Ic2410c689de3f70f573fa1c71456e6d3f334f80b

includes/htmlform/fields/HTMLDateTimeField.php
resources/Resources.php
resources/src/mediawiki/htmlform/datetime.js [deleted file]

index b43080c..7b59a1d 100644 (file)
@@ -52,22 +52,16 @@ class HTMLDateTimeField extends HTMLTextField {
                        $min = $this->parseDate( $this->mParams['min'] );
                        if ( $min ) {
                                $ret['min'] = $this->formatDate( $min );
-                               // Because Html::expandAttributes filters it out
-                               $ret['data-min'] = $ret['min'];
                        }
                }
                if ( in_array( 'max', $list ) && isset( $this->mParams['max'] ) ) {
                        $max = $this->parseDate( $this->mParams['max'] );
                        if ( $max ) {
                                $ret['max'] = $this->formatDate( $max );
-                               // Because Html::expandAttributes filters it out
-                               $ret['data-max'] = $ret['max'];
                        }
                }
 
                $ret['step'] = 1;
-               // Because Html::expandAttributes filters it out
-               $ret['data-step'] = 1;
 
                $ret['type'] = $this->mType;
                $ret['pattern'] = static::$patterns[$this->mType];
index 86673ee..7c00feb 100644 (file)
@@ -1060,7 +1060,6 @@ return [
                        'resources/src/mediawiki/htmlform/autocomplete.js',
                        'resources/src/mediawiki/htmlform/autoinfuse.js',
                        'resources/src/mediawiki/htmlform/checkmatrix.js',
-                       'resources/src/mediawiki/htmlform/datetime.js',
                        'resources/src/mediawiki/htmlform/cloner.js',
                        'resources/src/mediawiki/htmlform/hide-if.js',
                        'resources/src/mediawiki/htmlform/multiselect.js',
diff --git a/resources/src/mediawiki/htmlform/datetime.js b/resources/src/mediawiki/htmlform/datetime.js
deleted file mode 100644 (file)
index 2fd2396..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * HTMLForm enhancements:
- * Add minimal help for date and time fields
- */
-( function ( mw ) {
-
-       mw.hook( 'htmlform.enhance' ).add( function ( $root ) {
-               var supported = {};
-
-               $root
-                       .find( 'input.mw-htmlform-datetime-field' )
-                       .each( function () {
-                               var input,
-                                       type = this.getAttribute( 'type' );
-
-                               if ( type !== 'date' && type !== 'time' && type !== 'datetime' ) {
-                                       // WTF?
-                                       return;
-                               }
-
-                               if ( supported[ type ] === undefined ) {
-                                       // Assume that if the browser implements validation (so it
-                                       // rejects "bogus" as a value) then it supports a proper UI too.
-                                       input = document.createElement( 'input' );
-                                       input.setAttribute( 'type', type );
-                                       input.value = 'bogus';
-                                       supported[ type ] = ( input.value !== 'bogus' );
-                               }
-
-                               if ( supported[ type ] ) {
-                                       if ( !this.getAttribute( 'min' ) ) {
-                                               this.setAttribute( 'min', this.getAttribute( 'data-min' ) );
-                                       }
-                                       if ( !this.getAttribute( 'max' ) ) {
-                                               this.setAttribute( 'max', this.getAttribute( 'data-max' ) );
-                                       }
-                                       if ( !this.getAttribute( 'step' ) ) {
-                                               this.setAttribute( 'step', this.getAttribute( 'data-step' ) );
-                                       }
-                               }
-                       } );
-       } );
-
-}( mediaWiki ) );