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=91f797dad088fdc9939d5fa2765f55a933934a41;hb=e968a1f431ad058dcb14adb2757bde5664b99a79;hp=01d344279871245271180b1db5fe400d6eeef71f;hpb=86dc85e6fed673f73946b6e71737c4883c123175;p=lhc%2Fweb%2Fwiklou.git diff --git a/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js b/resources/src/mediawiki.widgets.datetime/DateTimeInputWidget.js index 01d3442798..3e4c5e2767 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; } @@ -172,7 +177,7 @@ /* Static properties */ - mw.widgets.datetime.DateTimeInputWidget[ 'static' ].supportsSimpleLabel = false; + mw.widgets.datetime.DateTimeInputWidget.static.supportsSimpleLabel = false; /* Events */ @@ -385,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 { @@ -578,6 +587,7 @@ * @private * @param {jQuery} $field * @param {jQuery.Event} e Key down event + * @return {boolean} False to cancel the default event */ mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldKeyDown = function ( $field, e ) { var spec = $field.data( 'mw-widgets-datetime-dateTimeInputWidget-fieldSpec' ); @@ -622,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() ); @@ -631,7 +643,7 @@ } if ( this.calendar ) { - this.calendar.toggle( true ); + this.calendar.toggle( !!spec.calendarComponent ); } } }; @@ -699,6 +711,7 @@ * @private * @param {jQuery} $field * @param {jQuery.Event} e Change event + * @return {boolean} False to cancel the default event */ mw.widgets.datetime.DateTimeInputWidget.prototype.onFieldWheel = function ( $field, e ) { var delta = 0,