From 205231d7da7617357228d0939159f0459857f214 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Thu, 24 Nov 2016 16:22:29 +0100 Subject: [PATCH] HTMLDateTimeField: Remove hacks for HTML5 form validation attributes No longer needed after I08244addcf9b6eb96137895f28e7b750914fef5c. Also remove datetime.js from mediawiki.htmlform module. Change-Id: Ic2410c689de3f70f573fa1c71456e6d3f334f80b --- .../htmlform/fields/HTMLDateTimeField.php | 6 --- resources/Resources.php | 1 - resources/src/mediawiki/htmlform/datetime.js | 44 ------------------- 3 files changed, 51 deletions(-) delete mode 100644 resources/src/mediawiki/htmlform/datetime.js diff --git a/includes/htmlform/fields/HTMLDateTimeField.php b/includes/htmlform/fields/HTMLDateTimeField.php index b43080cefb..7b59a1d6df 100644 --- a/includes/htmlform/fields/HTMLDateTimeField.php +++ b/includes/htmlform/fields/HTMLDateTimeField.php @@ -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]; diff --git a/resources/Resources.php b/resources/Resources.php index 86673ee5a1..7c00feb052 100644 --- a/resources/Resources.php +++ b/resources/Resources.php @@ -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 index 2fd239696b..0000000000 --- a/resources/src/mediawiki/htmlform/datetime.js +++ /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 ) ); -- 2.20.1