X-Git-Url: https://git.cyclocoop.org/%7B%7B%20url_for%28%27votes%27%2C%20votes=%27waiting%27%29%20%7D%7D?a=blobdiff_plain;f=resources%2Fsrc%2Fmediawiki.widgets.datetime%2FDateTimeInputWidget.js;h=3e4c5e27671cf66db04fcd3b039768d2cef765c7;hb=e968a1f431ad058dcb14adb2757bde5664b99a79;hp=e9bedf5b32940e3a476f20d6f96511b01742bc79;hpb=b01d54e5981da34bf0ce6856e56d3841d71e8686;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js b/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js index e9bedf5b32..3e4c5e2767 100644 --- a/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js +++ b/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js @@ -390,6 +390,10 @@ $field = $( '' ) .width( sz ) .data( 'mw-widgets-datetime-dateTimeInputWidget-placeholder', placeholder ); + if ( spec.type !== 'static' ) { + $field.prop( 'tabIndex', -1 ); + $field.on( 'focus', this.onFieldFocus.bind( this, $field ) ); + } if ( spec.type === 'static' ) { $field.text( spec.value ); } else { @@ -628,6 +632,8 @@ * @param {jQuery.Event} e Focus event */ mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldFocus = function ( $field ) { + var spec = $field.data( 'mw-widgets-datetime-dateTimeInputWidget-fieldSpec' ); + if ( !this.isDisabled() ) { if ( this.getValueAsDate() === null ) { this.setValue( this.formatter.getDefaultDate() ); @@ -637,7 +643,7 @@ } if ( this.calendar ) { - this.calendar.toggle( true ); + this.calendar.toggle( !!spec.calendarComponent ); } } };