mw.widgets.DateInputWidget(configopt)

new mw.widgets.DateInputWidget(configopt) #

Creates an mw.widgets.DateInputWidget object.

Parameters:

Name Type Attributes Description
config Object <optional>

Configuration options

Properties
Name Type Attributes Default Description
precision string <optional>
'day'

Date precision to use, 'day' or 'month'

value string <optional>

Day or month date (depending on precision), in the format 'YYYY-MM-DD' or 'YYYY-MM'. If not given or empty string, no date is selected.

inputFormat string <optional>

Date format string to use for the textual input field. Displayed while the widget is active, and the user can type in a date in this format. Should be short and easy to type. When not given, defaults to 'YYYY-MM-DD' or 'YYYY-MM', depending on precision.

displayFormat string <optional>

Date format string to use for the clickable label. Displayed 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.

longDisplayFormat boolean <optional>
false

If a custom displayFormat is not specified, use unabbreviated day of the week and month names in the default language-specific displayFormat.

placeholderLabel string <optional>
No date selected

Placeholder text shown when the widget is not selected. Default text taken from message mw-widgets-dateinput-no-date.

placeholderDateFormat string <optional>

User-visible date format string displayed in the textual input field when it's empty. Should be the same as inputFormat, but translated to the user's language. When not given, defaults to a translated version of 'YYYY-MM-DD' or 'YYYY-MM', depending on precision.

required boolean <optional>
false

Mark the field as required. Implies indicator: 'required'.

mustBeAfter string <optional>

Validates the date to be after this. In the 'YYYY-MM-DD' format.

mustBeBefore string <optional>

Validates the date to be before this. In the 'YYYY-MM-DD' format.

$overlay jQuery <optional>

Render the calendar into a separate layer. This configuration is useful in cases where the expanded calendar is larger than its container. The specified overlay layer is usually on top of the container and has a larger area. By default, the calendar uses relative positioning.

calendar Object <optional>

Configuration options for the this input's CalendarWidget.

Mixes In:
Source:
Creates an mw.widgets.DateInputWidget object.

Extends

Methods

getInputElement()protected #

getMoment() → {Object} #

Get the Moment object for current value.

Source:

Returns:

Moment object

Type
Object
Get the Moment object for current value.

getValidity() → {jQuery.Promise} #

Get the validity of current value.

This method returns a promise that resolves if the value is valid and rejects if it isn't. Uses #validateDate.

Source:

Returns:

A promise that resolves if the value is valid, rejects if not.

Type
jQuery.Promise
Get the validity of current value.

setValidityFlag(isValidopt) #

Sets the 'invalid' flag appropriately.

Parameters:

Name Type Attributes Description
isValid boolean <optional>

Optionally override validation result

Source:
Sets the 'invalid' flag appropriately.

Events

deactivate(userSelected) #

Fired when the widget is deactivated (when the calendar is closed). This can happen because the user selected a value, or because the user blurred the widget.

Parameters:

Name Type Description
userSelected boolean

Whether the deactivation happened because the user selected a value

Source:
Fired when the widget is deactivated (when the calendar is closed).