* } );
*
* @class
- * @extends OO.ui.InputWidget
+ * @extends OO.ui.TextInputWidget
* @mixins OO.ui.mixin.IndicatorElement
*
* @constructor
* while the widget is inactive. Should be as unambiguous as possible (for example, prefer to
* spell out the month, rather than rely on the order), even if that makes it longer. When not
* given, the default is language-specific.
+ * @cfg {boolean} [longDisplayFormat=false] If a custom displayFormat is not specified, use
+ * unabbreviated day of the week and month names in the default language-specific displayFormat.
* @cfg {string} [placeholderLabel=No date selected] Placeholder text shown when the widget is not
* selected. Default text taken from message `mw-widgets-dateinput-no-date`.
* @cfg {string} [placeholderDateFormat] User-visible date format string displayed in the textual input
// Config initialization
config = $.extend( {
precision: 'day',
+ longDisplayFormat: false,
required: false,
placeholderLabel: mw.msg( 'mw-widgets-dateinput-no-date' )
}, config );
// Properties (must be set before parent constructor, which calls #setValue)
this.$handle = $( '<div>' );
- this.label = new OO.ui.LabelWidget();
+ this.innerLabel = new OO.ui.LabelWidget();
this.textInput = new OO.ui.TextInputWidget( {
required: config.required,
placeholder: placeholderDateFormat,
this.inTextInput = 0;
this.inputFormat = config.inputFormat;
this.displayFormat = config.displayFormat;
+ this.longDisplayFormat = config.longDisplayFormat;
this.required = config.required;
this.placeholderLabel = config.placeholderLabel;
-
// Validate and set min and max dates as properties
+
if ( config.mustBeAfter !== undefined ) {
mustBeAfter = moment( config.mustBeAfter, 'YYYY-MM-DD' );
if ( mustBeAfter.isValid() ) {
this.mustBeBefore = mustBeBefore;
}
}
-
// Parent constructor
mw.widgets.DateInputWidget.parent.call( this, config );
} );
this.$handle.on( {
click: this.onClick.bind( this ),
- keypress: this.onKeyPress.bind( this )
+ keypress: this.onKeyPress.bind( this ),
+ focus: this.activate.bind( this )
} );
// Initialization
// Move 'tabindex' from this.$input (which is invisible) to the visible handle
this.setTabIndexedElement( this.$handle );
this.$handle
- .append( this.label.$element, this.$indicator )
+ .append( this.innerLabel.$element, this.$indicator )
.addClass( 'mw-widget-dateInputWidget-handle' );
this.calendar.$element
.addClass( 'mw-widget-dateInputWidget-calendar' );
/* Inheritance */
- OO.inheritClass( mw.widgets.DateInputWidget, OO.ui.InputWidget );
+ OO.inheritClass( mw.widgets.DateInputWidget, OO.ui.TextInputWidget );
OO.mixinClass( mw.widgets.DateInputWidget, OO.ui.mixin.IndicatorElement );
/* Methods */
if ( this.getValue() === '' ) {
this.textInput.setValue( '' );
this.calendar.setDate( null );
- this.label.setLabel( this.placeholderLabel );
+ this.innerLabel.setLabel( this.placeholderLabel );
this.$element.addClass( 'mw-widget-dateInputWidget-empty' );
} else {
moment = this.getMoment();
if ( !this.inCalendar ) {
this.calendar.setDate( this.getValue() );
}
- this.label.setLabel( moment.format( this.getDisplayFormat() ) );
+ this.innerLabel.setLabel( moment.format( this.getDisplayFormat() ) );
this.$element.removeClass( 'mw-widget-dateInputWidget-empty' );
}
};
ll = localeData.longDateFormat( 'll' );
format = llll.replace( lll.replace( ll, '' ), '' );
+ if ( this.longDisplayFormat ) {
+ format = format.replace( 'MMM', 'MMMM' ).replace( 'ddd', 'dddd' );
+ }
+
return format;
}
};