From a9c86d2767f2df6d2df4e131597543c2dbd74263 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bartosz=20Dziewo=C5=84ski?= Date: Sat, 8 Oct 2016 19:33:21 +0200 Subject: [PATCH] mw.widgets.DateTimeInputWidget: Simplify code for hiding reused $input when infusing This is the standard solution, used also in OO.ui.DropdownInputWidget. Change-Id: I42993bfade56b0461d4dd1a65fb110d605f1acf2 --- .../DateTimeInputWidget.js | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js b/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js index 91f797dad0..a3088ec5ca 100644 --- a/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js +++ b/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js @@ -51,6 +51,11 @@ calendar: {} }, config ); + // See InputWidget#reusePreInfuseDOM about config.$input + if ( config.$input ) { + config.$input.addClass( 'oo-ui-element-hidden' ); + } + if ( $.isPlainObject( config.formatter ) && config.formatter.format === undefined ) { config.formatter.format = '@' + config.type; } @@ -144,19 +149,6 @@ } ); } - // Our form input *should* be type="hidden". But if we're infusing from - // PHP, it's not. - if ( this.$input.attr( 'type' ) !== 'hidden' ) { - try { - this.$input.attr( 'type', 'hidden' ); - } catch ( e ) { - } - // IE <= 8, and IE 9 in quirks mode, doesn't allow changing the - // type, so just hide the field with CSS. IE 9 in quirks mode - // doesn't even throw an error, so do that unconditionally. Sigh. - this.$input.css( 'display', 'none' ); - } - // Initialization this.setTabIndex( -1 ); -- 2.20.1